2015-10-14 86 views
1

以下错误运行发行版本我的应用程序时出现,但调试版本:Android的运行时错误与发行版本,但没有调试版本

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); 

我也利用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' 
} 

在此之前(如果我恢复到旧版本),这是/是所有罚款。

编辑...回答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' 
} 
+1

你试过一个干净的和构建?过去我也遇到同样的问题,clean-build帮助了我。 – Dilberted

+0

您的buildConfigField是否在调试版本和发布版本类型中指定? – jyanks

+0

回复@枯草清理和建设 - 我会给它一个去。我认为这是根据这里描述的内容:http://stackoverflow.com/questions/16636848/equivalent-of-clean-build-in-android-studio? – drmrbrewer

回答

1

尝试清理并生成项目。这应该解决问题