简体   繁体   中英

Migrating to android studio 3.0.1

Hello i am trying to migrate my project to android 3.0.1 how ever i get below error :

Error:(1, 0) Unable to find method 'org.gradle.api.Project.getPluginManager()Lorg/gradle/api/plugins/PluginManager;'. Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

I tried to add google() to repositories but got no where

my gradle build is :

apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example.flashlight"
    minSdkVersion 14
    targetSdkVersion 14
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

Maybe the current gradle files are incompatible with your latest Android Studio version. You can just delete the .gradle folder as it is always created when the tasks are run. Deleting the folder will cause all the dependencies to download again (which will take some time) and then you can try to re-run the application.
You need internet connection for syncing and downloading the gradle files. Let me know if the error still persists.

This code is tested and it works :

change your gradle file like this :

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.0'

defaultConfig {
    applicationId "com.example.flashlight"
    minSdkVersion 15
    targetSdkVersion 25
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

 dependencies {
compile 'com.android.support:support-v4:25.0.0'
compile 'com.google.android.gms:play-services:+'
}

alse in gradle-wrapper.properties file make distribution url :

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

in build.gradle change com.android.tools.build:gradle version to :

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

Finaly probleme solved , it was just a litlle probleme of gradle version , seems i had to update the source code manualy . thanks guys

Change your gradle-wrapper.properties to:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM