java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV11

java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV11

我正在使用我的应用程序 AppCompat 来处理 material-design。 运行 应用失败,然后在继承自 AppCompactActivity 的 MainActivity class 的 onCreate 中显示以下错误:

java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV11

目前我的应用程序还使用 Facebook SDK 和 Google Play 服务。我搜索了一个解决方案,但找不到工作:(。有人可以帮助我感谢他。我留下了完整的错误日志。

PD: 我正在使用 eclipse。

05-20 13:51:46.039: E/AndroidRuntime(23589): FATAL EXCEPTION: main
05-20 13:51:46.039: E/AndroidRuntime(23589): Process: com.tauro.videochat, PID: 23589
05-20 13:51:46.039: E/AndroidRuntime(23589): java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV11
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:77)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:414)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:57)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at com.tauro.MainActivity.onCreate(MainActivity.java:82)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.Activity.performCreate(Activity.java:5990)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread.access0(ActivityThread.java:151)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.os.Handler.dispatchMessage(Handler.java:102)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.os.Looper.loop(Looper.java:135)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread.main(ActivityThread.java:5254)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at java.lang.reflect.Method.invoke(Native Method)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at java.lang.reflect.Method.invoke(Method.java:372)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

版次:

Logcat满

05-20 13:51:42.944: I/art(23589): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV7>
05-20 13:51:42.945: I/art(23589): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV7>
05-20 13:51:42.945: I/art(23589): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV11>
05-20 13:51:42.946: I/art(23589): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV11>
05-20 13:51:42.947: I/art(23589): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV7>
05-20 13:51:42.947: I/art(23589): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV11>
05-20 13:51:42.948: I/art(23589): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV7>
05-20 13:51:42.948: I/art(23589): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatDelegateImplV11>
05-20 13:51:42.949: D/AndroidRuntime(23589): Shutting down VM
05-20 13:51:46.039: E/AndroidRuntime(23589): FATAL EXCEPTION: main
05-20 13:51:46.039: E/AndroidRuntime(23589): Process: com.tauro.videochat, PID: 23589
05-20 13:51:46.039: E/AndroidRuntime(23589): java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV11
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:77)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:414)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:57)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at com.tauro.MainActivity.onCreate(MainActivity.java:82)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.Activity.performCreate(Activity.java:5990)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread.access0(ActivityThread.java:151)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.os.Handler.dispatchMessage(Handler.java:102)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.os.Looper.loop(Looper.java:135)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at android.app.ActivityThread.main(ActivityThread.java:5254)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at java.lang.reflect.Method.invoke(Native Method)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at java.lang.reflect.Method.invoke(Method.java:372)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
05-20 13:51:46.039: E/AndroidRuntime(23589):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

我也有同样的错误!它也没有给您明确的问题原因。这是多么痛苦啊。我花了一整天的时间试图找出解决办法。这是我发现的 -- Google Play 服务是一个庞大的代码库。对于我使用的所有其他通用库,我达到了 65k 方法的 dex 限制。这导致了我遇到的错误(也可能是你的错误)。

降低它的一些技巧:

  1. 选择性地选择您要使用的 Google Play 服务。 Directions here
  2. 如果这不起作用,请尝试对您的应用程序进行多索引处理。 Directions here。注意:如果您 运行 遇到问题,请尝试扩展 MultiDexApplication 而不是 Application。
  3. 清理项目,重新启动 Eclipse,and/or重新启动计算机。这修复了与上述 dex 问题无关的类似问题。

将 compatibility-v4 v21 添加到您的构建中。

我将其添加为 Maven 依赖项:

<dependency>
    <groupId>android.support</groupId>
    <artifactId>compatibility-v4</artifactId>
    <version>22.1.1</version>
</dependency>