0

I changed my compileSDK API version from 22 to 25 with all corresponding libraries. Now my signed app crashes.

Here is me stacktrace:

02-25 11:52:07.407 23491-23491/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.App.Main, PID: 23491
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.App.Main/com.package.Main.MainActivity}: android.view.InflateException: Binary XML file line #88: Binary XML file line #88: Error inflating class Button
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2788)
                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1503)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:154)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6209)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                    Caused by: android.view.InflateException: Binary XML file line #88: Binary XML file line #88: Error inflating class Button
                                                    Caused by: android.view.InflateException: Binary XML file line #88: Error inflating class Button
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void tv.a()' on a null object reference
                                                       at android.support.v7.widget.AppCompatButton.setBackgroundDrawable(SourceFile:88)
                                                       at android.view.View.setBackground(View.java:18187)
                                                       at android.view.View.<init>(View.java:4584)
                                                       at android.widget.TextView.<init>(TextView.java:710)
                                                       at android.widget.Button.<init>(Button.java:109)
                                                       at android.widget.Button.<init>(Button.java:105)
                                                       at android.support.v7.widget.AppCompatButton.<init>(SourceFile:66)
                                                       at android.support.v7.widget.AppCompatButton.<init>(SourceFile:62)
                                                       at pg.a(SourceFile:14109)
                                                       at gh.onCreateView(SourceFile:47)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                                                       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                                                       at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
                                                       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                                                       at pg.b(SourceFile:288)
                                                       at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:140)
                                                       at com.package.Main.MainActivity.onCreate(SourceFile:113)
                                                       at android.app.Activity.performCreate(Activity.java:6745)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2788)
                                                       at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1503)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:154)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6209)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Here is my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.package.Main"
        versionCode 46
        versionName '1.1.7'
        minSdkVersion 14
        targetSdkVersion 25
        project.ext.set("archivesBaseName", "app-" + defaultConfig.versionName);
        multiDexEnabled true
    }
    buildTypes {
        release {
            println "Running proguard"
            minifyEnabled true
            shrinkResources true
            proguardFiles 'proguard-project.txt'
        }
        debug {
            minifyEnabled false
        }
    }
    lintOptions {
        abortOnError false
    }
    productFlavors {
    }

    useLibrary 'org.apache.http.legacy'
}

dependencies {
    compile 'com.android.support:support-v4:25.2.0'
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
}

Here is the Button, the app is crashed on:

   <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/bg_color"
        android:gravity="center_horizontal"
        xmlns:ads="http://schemas.android.com/apk/res-auto">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/buttonConnect"
            android:layout_width="match_parent"
            android:layout_height="@dimen/action_measure_height"
            style="@style/YellowButton"
            android:layout_marginBottom="@dimen/action_margin_horizontal"
            android:layout_marginTop="@dimen/action_margin_horizontal"
            android:text="@string/button_connect"/>

        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="@string/admob_publisher_id"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_alignWithParentIfMissing="true"
            android:gravity="center" />

    </RelativeLayout>
</LinearLayout>

Here is gradle setting:

  dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }

I tried all recommendations, found on this site, but no one worked. Looks like, it crashes on every button found in resources. Any ideas, how to fix this?

  • 1
    Possible duplicate of [What is a NullPointerException, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Code-Apprentice Feb 25 '17 at 17:33
  • Are all of your classes in one file? – Code-Apprentice Feb 25 '17 at 17:34
  • All I did, is changed API from 22 to 25. Not signed app works fine. – user56926 Feb 25 '17 at 17:38
  • are you using version control? Can you revert the changes? – Code-Apprentice Feb 25 '17 at 17:43
  • I can revert, but I need version 25 to implement new features. – user56926 Feb 25 '17 at 17:48
  • What happens if you disable proguard? – Code-Apprentice Feb 25 '17 at 18:15
  • Could you lose the `shrinkResources true` and see if that helps? If it does we can then enable it again with some extra work.. – nana Feb 25 '17 at 18:34
  • Juts found out that there is some resource ID conflict in the project. For example: `code` 621|int drawable |abc_vector_test| 0x7f02004f 675|public| |static| |final| |int| |abc_vector_test| |=| |0x7f020052|; 2748|public| |static| |final| |int| |abc_vector_test|=|0x7f02004f|; 653|int drawable |abc_vector_test| 0x7f020052 478|int drawable |abc_vector_test| 0x7f02004f 2807|public| |static| |final| |int| |abc_vector_test|=|0x7f020052|; 641|public| |static| |final| |int| |abc_vector_test| |=| |0x7f02004f|; This resource has same ID in different R-files. Not sure, how to fix it yet. – user56926 Feb 27 '17 at 13:40

0 Answers0