You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Android Studio编译旧Gradle项目报错:找不到getPluginManager方法求助

Let’s break down why you’re hitting this getPluginManager() error and fix it step by step:

The core issue here is a mismatch between your Android Gradle Plugin version and the Gradle runtime version. You upgraded the Android plugin to 3.0.1, but this plugin requires Gradle 4.1 or higher to run—and the getPluginManager() method you’re missing was introduced in Gradle 2.10. If your project is still using an older Gradle version (like the one paired with plugin 1.2.3), this method won’t exist, hence the error.

Step 1: Upgrade Gradle Wrapper to a compatible version

First, you need to align your Gradle runtime with the Android plugin version:

  • Open gradle/wrapper/gradle-wrapper.properties in your project root.
  • Update the distributionUrl to point to Gradle 4.1 (the minimum compatible version for plugin 3.0.1) or a later compatible version (up to 5.6.4 works well):
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
    
  • Alternatively, use Android Studio’s UI: Go to File > Project Structure > Project, then select "4.1" from the Gradle version dropdown.

Step 2: Update your app module’s build.gradle for compatibility

Your current app build.gradle uses outdated settings that won’t play nice with Android Plugin 3.0.1. Here’s what to adjust:

  1. Replace all compile dependencies with implementation (the 3.0+ plugin recommends this over the deprecated compile keyword).
  2. Upgrade compileSdkVersion and buildToolsVersion—plugin 3.0.1 has limited support for very old SDK versions like 14. A safe choice is compileSdkVersion 26 with buildToolsVersion "26.0.2".
  3. Update targetSdkVersion to match your new compileSdkVersion (this improves compatibility and security).
  4. Upgrade your Google Play Services Ads dependency—version 7.5.0 is too old for SDK 26. Use version 11.0.4 (the first version compatible with SDK 26) or higher.

Here’s your modified app build.gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId 'com.aabcdata.learn.german.hd'
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 6
        versionName '1.5'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}
dependencies {
    implementation files('libs/FlurryAnalytics_3.3.2.jar')
    implementation 'com.google.android.gms:play-services-ads:11.0.4'
    implementation files('libs/AppTracker.jar')
    implementation files('libs/presage-lib-1.6.0.jar')
}

Step 3: Clean and rebuild your project

  • Run ./gradlew clean build in your terminal, or use Android Studio’s Build > Clean Project followed by Build > Rebuild Project.
  • If you still run into issues, try another Invalidate Caches / Restart (File > Invalidate Caches... > Check "Invalidate and Restart").

Step 4: Check for other incompatible plugins

If you have any other third-party plugins in your root build.gradle (under dependencies.classpath), make sure they’re compatible with Gradle 4.1+ and Android Plugin 3.0.1. Old plugins might rely on deprecated Gradle APIs that break the build.

内容的提问来源于stack exchange,提问作者Pedro Santangelo

火山引擎 最新活动