简体   繁体   English

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

[英]Android runtime error with release version but not debug version

The following error is occurring when running the release version of my app, but not the debug version: 运行我的应用的发行版而不是 调试版时,发生以下错误:

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

Any ideas why? 有什么想法吗? I have my suspicion that it may have something to do with the fact that I'm using BuildConfig values in my code, and there is at least one suggestion that such values are not being generated in the release version, but I've tried changing BuildConfig.VERSION_NAME in the following to a straight string value, and still it crashes. 我怀疑这可能与我在代码中使用BuildConfig值有关,并且至少有一种建议认为发行版中不会生成这些值,但是我尝试更改在下面的BuildConfig.VERSION_NAME中,将其转换为直接的字符串值,但仍然崩溃。

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

I also make use of buildConfigField in my build.gradle : 我还在buildConfigField中使用了build.gradle

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

which I access all over the place as BuildConfig.APP_TYPE . 我可以BuildConfig.APP_TYPE在整个地方访问它。

Incidentally, this issue (crashing with release but but debug version) only started happening when I updated everything I could in my build.gradle files to the latest versions, eg 顺便说一句,这个问题(与版本崩溃,但调试版本崩溃)仅在我将build.gradle文件中的所有内容更新为最新版本时才开始发生。

app-level: 应用级:

buildToolsVersion "23.0.1"
compileSdkVersion 23
defaultConfig {
    targetSdkVersion 23
}

top-level: 顶层:

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

Before that (and if I revert to older versions), it was/is all fine. 在此之前(如果我恢复使用较旧的版本),一切都很好。

EDIT... to answer the comment below , here is my complete app-level build.gradle file: 编辑...来回答下面评论 ,这是我完整的应用程序级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'
}

Try to clean and build the project. 尝试清理并构建项目。 That should fix the issue 那应该解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android调试/发布版本的应用程序 - Android debug / release version of application 如何在Android设备上管理调试和发布版本? - how to manage debug and release version on android device? Android Studio:运行/调试应用程序的发布版本 - Android Studio: run/debug release version of app Yelp API搜索在Android调试版本中有效,但在发行版本中无效 - Yelp API search working in Android debug version but not in release version Android Studio - Google Maps API 适用于调试版本,但不适用于发布版本 - Android Studio - Google Maps API works for debug version but not for release version 如何使用“mapping.txt”文件进行Android Release版本的调试和错误异常处理 - How to use “mapping.txt” file for debug and error-exception handler for Release version in Android Android Retrofit:发布版和调试版都响应200,但发布版返回空值 - Android Retrofit: Response 200 in both release and debug version but release version have empty value returned 发行版比调试版更灵活 - Release version much snappier than debug version 发布,调试版本和授权Google? - Release, debug version and Authorization Google? android 应用新版本发布时的错误展示 - Error showcase on android app new version release
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM