[Android Studio] Update the gradle plugin (AGP) 7.+ to 8.+ for Flamingo and above

Flamingo version launch map

  • It looks like a flamingo practicing Shaolin Kungfu by the river
    insert image description here

step

  • Use the AGP update assistant first, and the following notification will appear when the Flamingo version 7.0 project is opened
    insert image description here
  • Click the Start AGP Upgrade Assistant button and follow the prompts for automatic updates
  • If you still have problems after updating, you can check whether the following configurations are consistent
  • build.gradle(module)
android {
    
    
    namespace ''//add
    defaultConfig {
    
    
        applicationId ''
    }
 }
  • AndroidManifest.xml cancels the package attribute
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:label="@string/app_name"></application>
</manifest>
  • gradle.properties
android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.defaults.buildfeatures.buildconfig=true
android.enableBuildConfigAsBytecode=true
android.defaults.buildfeatures.aidl=true
android.defaults.buildfeatures.renderScript=true
android.enableR8.fullMode=false

buildconfig is closed by default, you need to enable
aidl, it is closed by default, you need to enable
R8 from the default compatible Proguard mode to the default full mode, you need to disable the full mode and return to compatibility

It’s really okay to update blindly, saying it’s for optimization, don’t you consider compatibility? Every time there is an update, there are various compatibility issues, and there is no optimization. Besides, these dispensable optimization options, we can enable them if we want, there is no need for you to help us enable "以为我们好的名义,人性化的"them

  • build.gradle
plugins {
    id 'com.android.application' version '8.0.2' apply false
    id 'com.android.library' version '8.0.2' apply false
}
  • gradle/wrapper/gradle-wrapper.properties
#Sun May 28 15:37:54 CST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

  • Sync Project with Gradle Files
    insert image description here

reference

Guess you like

Origin blog.csdn.net/qq_26914291/article/details/131068855