android-支持库23.2.0导致应用程序崩溃
我的应用程序与支持库23.1.0或23.1.1配合良好,但是当我开始使用23.2.0时,它在启动时崩溃. 我使用了五个支持库,但似乎使它崩溃的是以下两个:
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:appcompat-v7:23.2.0
com.android.support:design:23.2.0
com.android.support:design:23.2.0
我在我的银河系(API 17)上有此问题,但在Nexus 7(API 22)上却没有. 有谁知道可能是什么问题? 这是我的gradle文件:
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" />
使用调试器,我可以发现崩溃是在主活动调用setContentView()时发生的:
Using the debugger I was able to discover that the crash happens when the main activity calls setContentView():
java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
java.lang.RuntimeException:无法启动活动ComponentInfo {com.ikarirobotics.aichordfinder/com.ikarirobotics.aichordfinder.HomeActivity}:android.view.InflateException:二进制XML文件第36行:膨胀类android.support的错误. v7.widget.Toolbar
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
我的活动扩展了AppCompatActivity,我使用了支持操作栏.关于如何解决此问题的任何想法? :(
My activity extends AppCompatActivity and i make use of the support action bar. Any ideas on how to fix this problem? :(
正如这里一些人所预测的那样,随着我开始使用23.2.1支持库,问题消失了. 谢谢大家的支持.
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.