Meituan-Dianping / walle

Android Signature V2 Scheme签名下的新一代渠道包打包神器
Apache License 2.0
6.79k stars 1.08k forks source link

Gradle Plugin Error: NoClassDefFoundError: com/android/builder/Version #176

Closed dongorigin closed 6 years ago

dongorigin commented 6 years ago

Android Gradle Plugin 3.0.1 Gradle 4.4 Walle 1.1.5

Caused by: java.lang.NoClassDefFoundError: com/android/builder/Version
        at com.meituan.android.walle.GradlePlugin.apply(GradlePlugin.groovy:24)
        at com.meituan.android.walle.GradlePlugin.apply(GradlePlugin.groovy)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:42)
        at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:50)
        at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:165)
        at org.gradle.api.internal.plugins.DefaultPluginManager.access$200(DefaultPluginManager.java:47)
        at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:252)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:125)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:120)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:38)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:86)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:143)
        at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
        at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
        at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
        at build_f2jiok4xgl83a260df4fsv3ai.run(/Users/dong/AndroidStudioProjects/magnet_android/app/build.gradle:5)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)
achellies commented 6 years ago

在本地测试没有发现问题,下面是在开源的demo上的改动

diff --git a/app/build.gradle b/app/build.gradle
index abf802a..82136df 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,10 +6,11 @@ buildscript {
     repositories {
         mavenLocal()
         jcenter()
+        google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.0'
-        classpath "com.meituan.android.walle:plugin:latest.integration"
+        classpath 'com.android.tools.build:gradle:3.0.1'
+        classpath "com.meituan.android.walle:plugin:1.1.5"
     }
 }

diff --git a/build.gradle b/build.gradle
index 1761502..ef41b45 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,10 +3,11 @@ buildscript {
     repositories {
         mavenLocal()
         jcenter()
+        google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.0'
-        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
+        classpath 'com.android.tools.build:gradle:3.0.1'
+        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
         classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
     }
 }
@@ -15,6 +16,7 @@ allprojects {
     repositories {
         mavenLocal()
         jcenter()
+        google()
     }

     tasks.withType(Javadoc).all {
diff --git a/gradle.properties b/gradle.properties
index e4092f0..5af9d35 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -17,5 +17,5 @@
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
 # org.gradle.parallel=true

-VERSION_NAME=1.1.5
+VERSION_NAME=1.1.6-SNAPSHOT
 GROUP=com.meituan.android.walle
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f469fe2..8fc4615 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,3 +1,4 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+#distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
dongorigin commented 6 years ago

与Realm plugin有关,依赖Realm 4.3.1后报错,回退到4.2后正常。但是暂时没想到两者可能关联的地方,为什么会导致walle找不到class?有什么排查的方向可供参考吗?

achellies commented 6 years ago

我试试realm4.3.1的版本

achellies commented 6 years ago

代码修复了,等待用新版本吧

dongorigin commented 6 years ago

是因为Android Gradle Plugin 3.0修改了源码导致的吗?请问在哪里可以看到相关源码?

achellies commented 6 years ago

v1.1.6 版本发布了,可以支持了 Gradle Plugin的源码去Google那里找吧

LiLeiAndroid commented 6 years ago

这个问题依然存在,请问是如何解决的?谢谢