Failed to apply plugin Android Gradle plugin 3.0.0

2019-03-11 13:59发布

Using the latest Android Studio 3.0 Canary 5

Here's the error:

Error:(1, 1) A problem occurred evaluating project ':app'.

Failed to apply plugin [class 'com.android.build.gradle.api.AndroidBasePlugin'] Android Gradle plugin 3.0.0-alpha5 must not be applied to project [path_to_my_project] since version 3.0.0-alpha5 was already applied to this project

Tried: cleaning, rebuilding, opening/closing. Not working.

any ideas ?

[LATER EDIT] Solution: Migrate to Canary 8+ and all should be ok.

7条回答
对你真心纯属浪费
2楼-- · 2019-03-11 14:37

This worked for me:

Deactivate Configuration On Demand

In gradle.properties:

org.gradle.configureondemand=false

Then stop the daemon in a terminal window:

gradlew.bat --stop

Now everything works again.

Versions used:

  • Android Studio 3.0 Canary 5
  • gradle: gradle-4.1-milestone-1
  • android gradle plugin: com.android.tools.build:gradle:3.0.0-alpha5

UPDATE
After upgrading to Android Studio 3.0 Beta 2 I can reactivate Configuration on Demand and everything works fine.

查看更多
走好不送
3楼-- · 2019-03-11 14:44

I already tried all the solutions including Clean, Rebuild, Invalidate Project

But nothing is working but i figured it out.

For temporary just downgrade your gradle plugin version to stable version

classpath 'com.android.tools.build:gradle:2.3.2'

Replace your alpha line with this line. And have fun.. :)

查看更多
forever°为你锁心
4楼-- · 2019-03-11 14:48

I had the same issue, I closed Android Studio and opened again, I noticed that it automatically applied these changes to the following files and everything worked fine:

build.gradle: changed the class path of Gradle from:

dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
    }

to

dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
    }

gradle-wrapper.properties: from

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

to

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
查看更多
对你真心纯属浪费
5楼-- · 2019-03-11 14:57

I got the issue and realized the issue related with caches. You have to invalidate caches of Android studio by select File-> Invalidate Caches/Restart. It worked for me. The issue was resolved.

查看更多
趁早两清
6楼-- · 2019-03-11 14:58

from this thread on reddit: https://www.reddit.com/r/androiddev/comments/6kjl8b/android_studio_30_canary_5_is_now_available/djmuv0o/ killing daemons fixed the problem for me.

./gradlew --stop
查看更多
欢心
7楼-- · 2019-03-11 14:59

Migrating the gradle version from 3.0.0-alpha5 to 3.0.0-alpha7 saved my day !!

查看更多
登录 后发表回答