更新appcompat API版本后签名APK崩溃

时间:2017-02-25 17:23:31

标签: android android-appcompat

我将所有相应库的compileSDK API版本从22更改为25。现在我签名的应用程序崩溃了。

这是我的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)

这是我的build.gradle文件:

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'
}

这是按钮,应用程序崩溃了:

   <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>

这是gradle设置:

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

我尝试了在本网站上找到的所有建议,但没人工作。 看起来,它会在资源中找到的每个按钮上崩溃。 任何想法,如何解决这个问题?

0 个答案:

没有答案