问题:

使用 implementation ‘androidx.appcompat:appcompat:1.7.0’
出现无法运行的问题,编译都没有问题

AGPBI: {“kind”:“error”,“text”:“java.lang.NullPointerException”,“sources”:[{“file”:“C:\Users\10557\.gradle\caches\transforms-4\1edd4499edd7eb0b525a2dccf436f680\transformed\appcompat-resources-1.7.0-runtime.jar”}],“tool”:“D8”}
AGPBI: {“kind”:“error”,“text”:“java.lang.NullPointerException”,“sources”:[{“file”:“C:\Users\10557\.gradle\caches\transforms-4\15b33227282e2c4d2dffa561de8fe63f\transformed\appcompat-1.7.0-runtime.jar”}],“tool”:“D8”}
Execution failed for task ‘:app:mergeExtDexDebug’.
Could not resolve all files for configuration ‘:app:debugRuntimeClasspath’.
Failed to transform appcompat-resources-1.7.0.aar (androidx.appcompat:appcompat-resources:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
Execution failed for DexingWithClasspathTransform: C:\Users\10557.gradle\caches\transforms-4\1edd4499edd7eb0b525a2dccf436f680\transformed\appcompat-resources-1.7.0-runtime.jar.
Error while dexing.
Failed to transform appcompat-1.7.0.aar (androidx.appcompat:appcompat:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
Execution failed for DexingWithClasspathTransform: C:\Users\10557.gradle\caches\transforms-4\15b33227282e2c4d2dffa561de8fe63f\transformed\appcompat-1.7.0-runtime.jar.
Error while dexing.

解决方案:

把所有的版本修改为1.6.1即可(就很离谱)
implementation ‘androidx.appcompat:appcompat:1.6.1’
在gradle.properties中

android.useAndroidX=true
#android.enableJetifier=true

android.enableBuildCache=false
android.injected.testOnly=false
org.gradle.warning.mode=all
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐