5

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?

Mirjalal
  • 1,292
  • 1
  • 17
  • 40

2 Answers2

2

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.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
Mohad12211
  • 353
  • 3
  • 9
  • does it happen with all of your applications? – Mirjalal Jul 12 '17 at 16:44
  • i didnt check that but i tried all the solutions and no one works .. also your exception is exactly same of me .. try to do this – Mohad12211 Jul 12 '17 at 16:45
  • @Mohad12211 I don't think this Exception has anything to do with Android Studio. :( – Willi Mentzel Jul 12 '17 at 16:48
  • Just try, and make sure that you change the class path in the dependencies to : classpath 'com.android.tools.build:gradle:2.3.2' // change 2.3.2 to the version you use. – Mohad12211 Jul 12 '17 at 16:51
  • @MirjalalTalishinski I dont think you tried my answer, just try. Iam sure 90% that this is the problem – Mohad12211 Jul 12 '17 at 17:06
  • @WilliMentzel i thought like you, but i tried all the solutions and none of them work, i tried this and it works – Mohad12211 Jul 12 '17 at 17:10
  • @Mohad12211 no actually I tested it. I did not change my android studio version but downgraded gradle version from `3.0.0-alpha6` to `2.3.3` and now everything working **perfectly!** Thanks a lot. You saved my time! :) – Mirjalal Jul 12 '17 at 17:28
  • 1
    @MirjalalTalishinski never use an alpha version in production ;) – Willi Mentzel Jul 12 '17 at 17:41
  • 1
    @WilliMentzel I got it now :) This will not happen second time again :D Thanks to you too)) – Mirjalal Jul 12 '17 at 17:48
1

I also had the same issue today. After some research, I found this:

android.enableAapt2=false

Add this line into your "gradle.properties" file.

Reference is here.

I think it's caused by a bug in latest version (3.0 Canary 6) of Android Studio.

Improved incremental resource processing with AAPT2. To enable AAPT2, add the following to your gradle.properties file: android.enableAapt2=true

The text above is from android studio preview link.

Panch
  • 11
  • 3