【发布时间】:2017-07-12 15:02:20
【问题描述】:
Firebase 崩溃报告捕获的异常:
异常 java.lang.RuntimeException:无法启动活动 组件信息{com.talmir.mickinet/com.talmir.mickinet.activities.HomeActivity}: android.content.res.Resources$NotFoundException:资源 ID 0x7f080058 android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2249) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2299) android.app.ActivityThread.access$700 (ActivityThread.java:154) android.app.ActivityThread$H.handleMessage ...
由 android.content.res.Resources$NotFoundException 引起:资源 ID 0x7f080058 android.content.res.Resources.getValue (Resources.java:1883) android.support.v7.widget.AppCompatDrawableManager.c (SourceFile:332) android.support.v7.widget.AppCompatDrawableManager.a (SourceFile:197) android.support.v7.widget.AppCompatDrawableManager.getDrawable ...
HomeActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home); // line 238
FirebaseCrash.log("HomeActivity");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
if (!canAccessCamera() || !canAccessExternalStorage() || !canAccessContacts())
requestPermissions(INITIAL_PERMISSIONS, INITIAL_REQUEST);
copyRawFile(R.raw.file_receive);
// other codes...
activity_home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.talmir.mickinet.activities.HomeActivity"
android:background="@color/snow">
<fragment
android:id="@+id/frag_list"
class="com.talmir.mickinet.fragments.DeviceListFragment"
android:layout_width="match_parent"
android:layout_height="@dimen/phone_list_height">
</fragment>
<fragment
android:id="@+id/frag_detail"
class="com.talmir.mickinet.fragments.DeviceDetailFragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
</fragment>
</RelativeLayout>
AndroidManifest.xml
<activity
android:name=".activities.HomeActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
build.gradle
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
// my config
}
}
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.talmir.mickinet"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
signingConfig signingConfigs.config
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
jniDebuggable false
signingConfig signingConfigs.config
renderscriptDebuggable false
zipAlignEnabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'com.android.support:support-vector-drawable:25.3.1'
implementation 'com.google.firebase:firebase-crash:11.0.2'
}
apply plugin: 'com.google.gms.google-services'
我测试的内容: this、this、this、this 一个。 this link 中的问题看起来比其他问题更接近我的问题。
此外,API 23 和 API 17(都是物理设备)中安装了相同的应用程序,但仅在 API 17(启动时)中出现错误。
主要问题:
为什么会发生这个异常,我该如何解决?
【问题讨论】:
-
我认为你的activity_home.xml中有错误,粘贴xml文件
-
如果与布局文件有关的错误,应该提到239行而不是238行。请仔细阅读问题。另一方面,如果与布局文件中的内容有关,则问题也应该出现在两个智能手机上。
-
@MirjalalTalishinski 是否也会在另一台 API 级别 17 的设备上崩溃?
-
@MirjalalTalishinski Resources$NotFoundException 很可能发生在 xml 文件中
-
@MirjalalTalishinski 也许您为 api 级别 17 设备指定了不同的布局 XML?
标签: java android android-6.0-marshmallow android-lifecycle android-4.2-jelly-bean