当前位置: 首页 > 知识库问答 >
问题:

当提升到目标SdkVersion 28,没有找到类"com.google.android.gms.common.R$string"路径: DexPathList

越伯寅
2023-03-14

当我尝试将我的targetSdkVersion从27更新到28时,我得到错误:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.baus_systems.inventorycount, PID: 2594
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/R$string;
    at com.google.android.gms.common.internal.StringResourceValueReader.<init>(Unknown Source:4)
    at com.google.firebase.FirebaseOptions.fromResource(com.google.firebase:firebase-common@@19.0.0:156)
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.0.0:240)
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@19.0.0:51)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1922)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1897)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@19.0.0:45)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6708)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6255)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6151)
    at android.app.ActivityThread.access$1100(ActivityThread.java:208)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:205)
    at android.app.ActivityThread.main(ActivityThread.java:6991)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.R$string" on path: DexPathList[[zip file "/data/app/com.baus_systems.inventorycount-y-SEoNnBinme-b9ebwn0xg==/base.apk"],nativeLibraryDirectories=[/data/app/com.baus_systems.inventorycount-y-SEoNnBinme-b9ebwn0xg==/lib/arm, /data/app/com.baus_systems.inventorycount-y-SEoNnBinme-b9ebwn0xg==/base.apk!/lib/armeabi-v7a, /system/lib, /product/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at com.google.android.gms.common.internal.StringResourceValueReader.<init>(Unknown Source:4) 
    at com.google.firebase.FirebaseOptions.fromResource(com.google.firebase:firebase-common@@19.0.0:156) 
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.0.0:240) 
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@19.0.0:51) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1922) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1897) 
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@19.0.0:45) 
    at android.app.ActivityThread.installProvider(ActivityThread.java:6708) 
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6255) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6151) 
    at android.app.ActivityThread.access$1100(ActivityThread.java:208) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:205) 
    at android.app.ActivityThread.main(ActivityThread.java:6991) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884) 

这是我构建的依赖项部分。格拉德尔:

dependencies {
    def lifecycle_version = "1.1.1"
//    def multidex_version = "2.0.1"
//    implementation 'androidx.multidex:multidex:2.0.1'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.annotation:annotation:1.0.2'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
    testImplementation 'junit:junit:4.12'
    implementation('androidx.constraintlayout:constraintlayout:1.1.3')
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel:2.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    implementation 'com.google.firebase:firebase-ml-vision:18.0.2'
    implementation 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
    implementation 'com.google.firebase:firebase-ml-model-interpreter:16.2.4'
    implementation 'com.drewnoakes:metadata-extractor:2.11.0'
    // AWS Mobile Client
    implementation('com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar') { transitive = true }
    // AWS Core
    implementation('com.amazonaws:aws-android-sdk-core:2.3.+')
    // AWS S3
    implementation('com.amazonaws:aws-android-sdk-s3:2.3.+')
    // AWS Cognito
    implementation('com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.3.+')
    implementation 'com.amazonaws:aws-android-sdk-cognitoauth:2.4.7@aar'
    //AWS Lambda
    implementation('com.amazonaws:aws-android-sdk-lambda:2.2.+')

    implementation project(':plugin')
}

我已经尝试更新Firebase依赖关系到最新版本(这需要更新minSdkVersion从15到16),这没有效果(我不确定这是否是一个可行的选择,因为我似乎记得我的同事说一些关于条形码扫描不被支持,如果我把这些版本太高)。更新所有依赖项都没有错误地导致应用程序崩溃,我还没有弄清楚哪些是罪魁祸首;我决定尽可能多地关注这个问题,而不是无缘无故地招致更多麻烦。我已经尝试了几种不同的方法来启用Multidex,正如我在某个地方看到的那样;它们似乎都没有帮助。还有一些其他的东西我也尝试过,并且丢失了页面,但是我尝试过的都没有帮助。

如果您能帮助我解决此错误,我将不胜感激,因为在升级到28之前,我无法在Play Store中更新应用程序。

共有1个答案

吕英豪
2023-03-14

正如在该问题下的评论中所提到的,该问题最终导致Gradle超过3.6。0,不引发targetSdkVersion。但格雷德尔有什么问题?

这个答案让我更新了我的Firebase和ObjectBox版本,我认为这是以前做过的,但显然不是。但这导致了androidx类型的问题。appcompat。资源。R$attr被多次定义,它拒绝清理、重建和使缓存无效。这一点最终被删除。gradle文件夹以及清理和重建。

但是还有一个问题:Invoke-海关只支持从android O开始。我仍然不知道那是什么意思,但是设置

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

以我的身材。正如这里所说,格雷德尔似乎已经让我克服了这一点。

 类似资料: