版本为但非调试版本的Android运行时错误
在运行我的应用程序的发行版而不是调试版时,出现以下错误:版本为但非调试版本的Android运行时错误,android,build.gradle,buildconfig,Android,Build.gradle,Buildconfig,在运行我的应用程序的发行版而不是调试版时,出现以下错误: 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
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\u NAME
更改为一个直字符串值,但它仍然崩溃
((TextView) findViewById(R.id.app_version)).setText(BuildConfig.VERSION_NAME);
我还在我的build.gradle
中使用buildConfigField
:
buildConfigField "String", "APP_TYPE", "\"devfree\""
我以BuildConfig.APP\u 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'
}
尝试清理并构建项目。这应该可以解决问题您是否尝试过干净的内部构造?我在过去也遇到过同样的问题,clean build帮助了我。在调试和发布构建类型中是否都指定了buildConfigField?Re@Dilberted clean and build--我会试试看。我假设它与这里描述的内容是一样的:?Re@jyanks——我编辑了我的问题,以给出
build.gradle
文件中的更多内容。无论是否为发行版和开发指定了buildConfigField
,如果现在是问题,那么它以前应该是问题?@drmrbrewer您在BuildConfig类中看到了什么?其中是否定义了任何资源?如果可能,请将内容粘贴在此处。