每当我第一次运行该应用程序时,我都会得到以下异常
com.mypckg.myapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mypckg.myapp, PID: 6460
android.content.res.Resources$NotFoundException: Resource ID #0x20c0016
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:237)
at android.content.res.Resources.getInteger(Resources.java:1127)
at org.chromium.ui.base.DeviceFormFactor.isTablet(chromium-TrichromeWebViewGoogle.aab-stable-438907233:2)
at Vm.a(chromium-TrichromeWebViewGoogle.aab-stable-438907233:2)
at Lc.run(chromium-TrichromeWebViewGoogle.aab-stable-438907233:3)
at org.chromium.content.browser.BrowserStartupControllerImpl.e(chromium-TrichromeWebViewGoogle.aab-stable-438907233:10)
at org.chromium.content.browser.BrowserStartupControllerImpl.g(chromium-TrichromeWebViewGoogle.aab-stable-438907233:7)
at t6.run(chromium-TrichromeWebViewGoogle.aab-stable-438907233:20)
at org.chromium.base.ThreadUtils.f(chromium-TrichromeWebViewGoogle.aab-stable-438907233:2)
at sp0.j(chromium-TrichromeWebViewGoogle.aab-stable-438907233:32)
at rp0.run(chromium-TrichromeWebViewGoogle.aab-stable-438907233:2)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)然后,当我第二次、第三次打开应用程序时,它工作得很好。
我猜这可能是由于某些库造成的,所以下面是我的app.gradle文件
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 29
buildToolsVersion "30.0.1"
defaultConfig {
applicationId "com.mypckg.myapp"
minSdkVersion 19
targetSdkVersion 29
versionCode 16
versionName "1.0.17"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", "MyApp"+ versionName +"_"+new Date().format( 'yyyy-MM-dd HH:mm' ))
}
buildTypes {
debug {
buildConfigField "String", 'BASE_URL', '"https://baseurl.com/"'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField "String", 'BASE_URL', '"https://baseurl.com/"'
}
}
viewBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
def room_version = '2.2.6'
def retrofitVersion = '2.8.1'
def okhttpVersion = '4.5.0'
def daggerVersion = '2.31.2'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.material:material:1.4.0-alpha01'
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0"
implementation 'androidx.fragment:fragment-ktx:1.3.0'
implementation "com.github.doyaaaaaken:kotlin-csv-jvm:0.11.0"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation "com.google.dagger:dagger:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
implementation "com.google.dagger:hilt-android:2.31.2-alpha"
kapt "com.google.dagger:hilt-android-compiler:2.31.2-alpha"
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha03'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
implementation 'com.github.quickpermissions:quickpermissions-kotlin:0.4.0'
implementation 'com.facebook.android:audience-network-sdk:5.10.0'
implementation platform('com.google.firebase:firebase-bom:26.6.0')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}这是我的项目级build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.31"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "http://jitpack.io/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}任何帮助都将不胜感激。谢谢
发布于 2021-07-26 03:40:23
我也有同样的问题,因为我将MobileAds.initialize从应用程序类移到了另一个类。您可以尝试在应用程序类中初始化MobileAds.initialize
发布于 2021-12-12 19:49:52
三星开发者论坛也提到了这个问题,但没有提供解决方案。请参阅https://forum.developer.samsung.com/t/android-content-res-resources-notfoundexception-in-org-chromium-ui-base-deviceformfactor-istablet/17544/4
关于这个问题还有更多的信息吗?我也在我的应用程序中看到了它。起初,我只在搭载安卓12的三星S21手机上看到了它,现在我也得到了一部搭载安卓12的Pixel3手机和几部搭载安卓11…的三星S21手机崩溃的报告这种情况最常发生在这个调用中:
String uas = WebSettings.getDefaultUserAgent(context);我怀疑只有在还没有创建WebView控件时调用时才会发生这种情况,因为到目前为止,我还没有在应用程序中发现类似的调用崩溃,当时控件是在应用程序中创建的。用try - catch包围这一行并没有什么帮助,因为崩溃似乎发生在另一个线程中。
格雷格
https://stackoverflow.com/questions/66527794
复制相似问题