棒棒糖只会崩溃 "Failed resolution of: Landroid/support/v7/appcompat/R$styleable"

Lollipop only crash "Failed resolution of: Landroid/support/v7/appcompat/R$styleable"

我只在 Lollipop 中启动我的应用程序时遇到此崩溃。其他版本工作正常,例如4.4

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/appcompat/R$styleable;

怎么了?

编辑 1:

android:minSdkVersion="8"
android:targetSdkVersion="22"

values/styles.xml:

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:editTextStyle">@style/EditTextStyle</item>

</style>

<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="EditTextStyle" parent="Widget.AppCompat.EditText"/>
</resources>

values-v21/styles.xml:

<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="android:colorAccent">@color/colorPrimary</item>
    <item name="android:colorPrimary">@color/colorPrimary</item>
    <item name="android:colorPrimaryDark">@color/colorPrimary</item>
    <item name="android:windowActionBar">false</item>
</style>

<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>

您正在使用 AppCompat 主题,因此您应该从 values-v21

中主题内的命名空间中删除 android

此外,它不需要 values-v21 样式。

您可能正在使用 Android SDK 目录中的 AppCompat 库。 只需复制库文件夹并将其放在您的项目附近,然后从新位置将其重新导入 Eclipse。