问题
Getting issue when trying to build apk.
Android studio version - 4.0 (recently updated AS)
This process shows the error in build - :app:processDebugResources Android resource linking failed AAPT: unknown option '--no-proguard-location-reference'.
aapt2 link [options] -o arg --manifest arg files...
Options: -o arg Output path. --manifest arg Path to the Android manifest to build. -I arg Adds an Android APK to link against. -A arg An assets directory to include in the APK
Trying to build apk by with Build APK option from Build Menu in android studio
Gradle project file
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
回答1:
if you have : "_internal_aapt2_binary" in gradle file (for earlier versions of gradle) then just remove that.
configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
config.resolutionStrategy.eachDependency { details ->
details.useVersion("3.5.0-alpha03-5252756")
}
}
回答2:
There was some issue with proguard rules, in some rules there were some extra space and in other rules, i just have to delete them and re-write them manually instead of copy-paste from web page.
Strange issue, took a lot of time to identify such silly issues, @android should do something about such proguard issues, at least spaces at the end could be trimmed automatically.
来源:https://stackoverflow.com/questions/62350512/android-resource-linking-failed-aapt-unknown-option-no-proguard-location-ref