gpt4 book ai didi

Android 运行时错误与发布版本但不是调试版本

转载 作者:行者123 更新时间:2023-11-29 20:21:20 24 4
gpt4 key购买 nike

在运行我的应用程序的发布 版本时出现以下错误,但不是调试 版本:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cloud3squared.meteogram/com.cloud3squared.meteogram.Meteogram}: android.content.res.Resources$NotFoundException: String resource ID #0x7f0901e4
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f0901e4
at android.content.res.Resources.getText(Resources.java:340)
at android.content.res.Resources.getString(Resources.java:426)
at android.content.Context.getString(Context.java:377)
at com.cloud3squared.meteogram.MeteogramWidgetConfigureActivity.a(Unknown Source)
at com.cloud3squared.meteogram.ak.a(Unknown Source)
at com.cloud3squared.meteogram.Meteogram.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
... 10 more

有什么想法吗?我怀疑这可能与我在代码中使用 BuildConfig 值有关,并且有 at least one suggestion。这些值不会在发布版本中生成,但我尝试将下面的 BuildConfig.VERSION_NAME 更改为直接字符串值,但它仍然崩溃。

((TextView) findViewById(R.id.app_version)).setText(BuildConfig.VERSION_NAME);

我还在我的 build.gradle 中使用了 buildConfigField:

buildConfigField "String", "APP_TYPE", "\"devfree\""

我以 BuildConfig.APP_TYPE 访问所有地方。

顺便说一句,这个问题(发布时崩溃但调试版本)只有在我将 build.gradle 文件中的所有内容更新到最新版本时才开始发生,例如

应用级:

buildToolsVersion "23.0.1"
compileSdkVersion 23
defaultConfig {
targetSdkVersion 23
}

顶级:

dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}

在那之前(如果我恢复到旧版本),一切都很好。

编辑...回答 comment below ,这是我完整的应用级 build.gradle 文件:

android {
signingConfigs {
development {
keyAlias 'xxx'
keyPassword 'yyy'
storeFile file('C:/Users/xxx/yyy.jks')
storePassword 'zzz'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.cloud3squared.meteogram"
minSdkVersion 16
targetSdkVersion 23
versionCode 144
versionName "1.7.14"
signingConfig signingConfigs.development
}
productFlavors {
pro {
applicationId "com.cloud3squared.meteogram.pro"
buildConfigField "String", "APP_TYPE", "\"pro\""
}
free {
applicationId "com.cloud3squared.meteogram"
buildConfigField "String", "APP_TYPE", "\"free\""
}
devpro {
applicationId "com.cloud3squared.meteogram.devpro"
buildConfigField "String", "APP_TYPE", "\"devpro\""
}
devfree {
applicationId "com.cloud3squared.meteogram.devfree"
buildConfigField "String", "APP_TYPE", "\"devfree\""
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

repositories { mavenCentral() }

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-location:8.1.0'
compile project(':ambilwarna')
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile project(':devmilColor')
compile 'com.google.guava:guava:18.0'
}

最佳答案

尝试清理并构建项目。这应该可以解决问题

关于Android 运行时错误与发布版本但不是调试版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33137158/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com