android - support libraries 23.2.0 cause app to cr

2019-01-22 21:08发布

My app works well with support libraries 23.1.0 or 23.1.1, but when i start using 23.2.0 it crashes on launch. I use five support libraries, but the ones that seem to make it crash are these two:

com.android.support:appcompat-v7:23.2.0

com.android.support:design:23.2.0

I have this issue on my galaxy nexus (API 17) but not on my Nexus 7 (API 22). Does anyone know what might be the problem? Here is my gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.ikarirobotics.aichordfinder"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-annotations:23.2.0'
    compile "com.android.support:appcompat-v7:23.2.0"
    compile 'com.android.support:design:23.2.0'
    compile 'com.android.support:cardview-v7:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'
}

My layout is only a frame where i place the currently appropriate fragment:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="HomeActivity"
    tools:ignore="MergeRootFrame" />

Using the debugger I was able to discover that the crash happens when the main activity calls setContentView():

java.lang.reflect.InvocationTargetException

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ikarirobotics.aichordfinder/com.ikarirobotics.aichordfinder.HomeActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar

My activity extends AppCompatActivity and i make use of the support action bar. Any ideas on how to fix this problem? :(

5条回答
甜甜的少女心
2楼-- · 2019-01-22 21:36

@CesarPim yes it is, I have a same problem for CheckBox, although I can fix that problem by creating abc_btn_check_material.xml inside drawable folder and adding following lines I can't be sure where it will break next. You can find drawables and selector code on this link: https://github.com/NativeScript/nativescript-plugin-appcompat/tree/master/platforms/android/appcompat/res/drawable

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:drawable="@drawable/abc_btn_check_to_on_mtrl_015" />
    <item android:drawable="@drawable/abc_btn_check_to_on_mtrl_000" />
</selector>
查看更多
做个烂人
3楼-- · 2019-01-22 21:37

As predicted by some of the people here, the problem disappeared as i began using the 23.2.1 support libraries. Thank you all for the support.

查看更多
甜甜的少女心
4楼-- · 2019-01-22 21:38

There seems to be a drawable mutation bug as being worked on Google with the 23.2.0 release. See the issue here. Reverting back to 23.1.1 should be fine until the next bugfix release.

查看更多
做自己的国王
5楼-- · 2019-01-22 21:44

Just had the problem myself. A quick update via the SDK Manager seems to have solved the issue.

On a side note, none of my build.gradle dependencies actually used the 23.2.0, but I still received the error. Trying to 'downgrade' to 23.1.1 was not an option for me as I already was using that version.

查看更多
Anthone
6楼-- · 2019-01-22 21:47

Same thing happens to me. I partially fixed it reverting to 23.1.1 on support:design.

查看更多
登录 后发表回答