Search code examples
javaandroidandroid-6.0-marshmallowandroid-lifecycleandroid-4.2-jelly-bean

super.onCreate(savedInstanceState) crashes in first run


Exception that caught by Firebase Crash Reporting:

Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.talmir.mickinet/com.talmir.mickinet.activities.HomeActivity}: android.content.res.Resources$NotFoundException: Resource 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 ...

Caused by android.content.res.Resources$NotFoundException: Resource 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'

What I tested: this, this, this, this one(s). The question in this link looks like more close to my problem than others.

Moreover, the same application installed in API 23 and API 17 (both are physical devices), but error occurs only in API 17 (when it launches).

Main question:

Why this exception happens and how can I solve it?


Solution

  • This exception happens to me when I update the Android Studio from Canary 5 to canary 6

    I return to Android Studio 2.3.2 and changed the class path back to Gradle 2.3.2 and the problem was solved.

    Update: I tried with 3 of my applications and I get the same error, but solved it like described.