Skip to content

Commit

Permalink
fix gradle 3.1 bug
Browse files Browse the repository at this point in the history
Signed-off-by: hedex <hedexmail@gmail.com>
  • Loading branch information
hedex committed Apr 11, 2018
1 parent d6e6a4b commit 7a9572f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,32 @@ class RobustApkHashAction implements Action<Project> {

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
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7a9572f

Please sign in to comment.