Android Studio - Failed to apply plugin [id 'com.android.application']

后端 未结 17 1987
故里飘歌
故里飘歌 2020-12-08 12:38

I am working on an app. In my app there is no error in code but when I try to run my project it gives following errors.

Error:(1, 1) A problem occurred e

相关标签:
17条回答
  • 2020-12-08 13:15

    As in Accepted post, the problem solved with updating gradle to 4.4.1.

    1. Get Latest Gradle 4.4.1 from here
    2. Extract and put it in "C:\Program Files\Android\Android Studio\gradle"
    3. Then from android studio go to "File -> Settings -> Build, Excecution, Deployment -> Gradle", from Project-level settings: Select Use local gradle Distribution and give the above
      address(folder with name "gradle-4.4.1" in "C:\Program Files\ ...")
    4. Then make project.

    My Problem solved this way.

    0 讨论(0)
  • 2020-12-08 13:19

    Delete gradle cache files. It can be in path like C:\Users\username\.gradle\caches for Windows users. For UNIX based operating systems it will be ~/.gradle/caches.

    0 讨论(0)
  • 2020-12-08 13:19

    i fixed it by upgrade to gradle-5.6.4-all.zip in project\gradle\wrapper\gradle-wrapper.properties

    #Wed Mar 11 15:20:29 WAT 2020
    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
    
    
    0 讨论(0)
  • 2020-12-08 13:24

    In my case, if your version of build tools in the build.gradle file in the root folder like :

    classpath 'com.android.tools.build:gradle:3.x.x' <--- version of tools

    is not supported by the Gradle installed in your project, you can check the build tools/plugin supported versions here, and make sure that the version installed in your project is supported by that version of Gradle.

    You don't need to upgrade Gradle, you just check if it supports the plugin installed in your project or not.

    0 讨论(0)
  • 2020-12-08 13:24

    Inside my project there is a .gradle folder which had cached the previous gradle version I was using (5.4.1) and gradle kept using that instead of my newly downloaded one (5.6.4).

    Simply:

    1. Close Android Studio
    2. Delete the older gradle version folders from your project.
    3. Restart Android Studio. Everything should be working correctly

    In case this didn't work you can also try the following:

    • Delete all versions in project .gradle folder so only the new one is redownloaded by AS when reopening the IDE.
    • Check your project settings for gradle build version and make sure it is set to the latest one.
    • Check that other modules aren't using older versions of the gradle build. You can search for this using project search (Ctrl+Shift+F) for "distributionUrl" and making sure that all modules have the latest version.
    • Delete .gradle/caches under your root gradle folder, usually C://Users/{you}/.gradle
    • try gradle build --stacktrace, --info, --scan or --debug in your AS terminal to get help and more info to debug your problem.
    0 讨论(0)
  • 2020-12-08 13:27

    When I had this problem was beacuse my directory had non ASCII characteres. Try changing it

    0 讨论(0)
提交回复
热议问题