簡體   English   中英

Android運行時錯誤,發布版本,但不是調試版本

[英]Android runtime error with release version but not 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

有什么想法嗎? 我懷疑這可能與我在代碼中使用BuildConfig值有關,並且至少有一種建議認為發行版中不會生成這些值,但是我嘗試更改在下面的BuildConfig.VERSION_NAME中,將其轉換為直接的字符串值,但仍然崩潰。

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

我還在buildConfigField中使用了build.gradle

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'
}

在此之前(如果我恢復使用較舊的版本),一切都很好。

編輯...來回答下面評論 ,這是我完整的應用程序級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'
}

嘗試清理並構建項目。 那應該解決問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM