diff --git a/gradle-plugin/src/main/groovy/robust/gradle/plugin/RobustApkHashAction.groovy b/gradle-plugin/src/main/groovy/robust/gradle/plugin/RobustApkHashAction.groovy index 2d876d0c..32fa366e 100755 --- a/gradle-plugin/src/main/groovy/robust/gradle/plugin/RobustApkHashAction.groovy +++ b/gradle-plugin/src/main/groovy/robust/gradle/plugin/RobustApkHashAction.groovy @@ -204,11 +204,32 @@ class RobustApkHashAction implements Action { public static boolean isGradlePlugin300orAbove() { try { - String gradlePluginVersion = com.android.builder.Version.ANDROID_GRADLE_PLUGIN_VERSION + String gradlePluginVersion = getGradlePluginVersion() return gradlePluginVersion.compareTo("3.0.0") >= 0; } catch (Throwable throwable) { } return false; } + + static String getGradlePluginVersion() { + String version = null + try { + def clazz = Class.forName("com.android.builder.Version") + def field = clazz.getDeclaredField("ANDROID_GRADLE_PLUGIN_VERSION") + field.setAccessible(true) + version = field.get(null) + } catch (Exception ignore) { + } + if (version == null) { + try { + def clazz = Class.forName("com.android.builder.model.Version") + def field = clazz.getDeclaredField("ANDROID_GRADLE_PLUGIN_VERSION") + field.setAccessible(true) + version = field.get(null) + } catch (Exception ignore) { + } + } + return version + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 0e4991cb..c7998d02 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,6 +16,6 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=0.4.80 +VERSION_NAME=0.4.81 GROUP=com.meituan.robust