更新到Android支持库版本22.2后,不再运行所有项目,甚至是空项目。我使用ADT插件在Eclipse中工作。
代码示例。
MainActivity :
package com.example.test;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml中:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
启动应用程序后,我在LogCat中收到以下错误:
06-06 22:17:15.911: D/AndroidRuntime(13239): Shutting down VM
06-06 22:17:15.912: E/AndroidRuntime(13239): FATAL EXCEPTION: main
06-06 22:17:15.912: E/AndroidRuntime(13239): Process: com.example.test, PID: 13239
06-06 22:17:15.912: E/AndroidRuntime(13239): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test/com.example.test.MainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class android.support.v7.internal.widget.NativeActionModeAwareLayout
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.app.ActivityThread.access$800(ActivityThread.java:144)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.os.Handler.dispatchMessage(Handler.java:102)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.os.Looper.loop(Looper.java:135)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.app.ActivityThread.main(ActivityThread.java:5221)
06-06 22:17:15.912: E/AndroidRuntime(13239): at java.lang.reflect.Method.invoke(Native Method)
06-06 22:17:15.912: E/AndroidRuntime(13239): at java.lang.reflect.Method.invoke(Method.java:372)
06-06 22:17:15.912: E/AndroidRuntime(13239): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
06-06 22:17:15.912: E/AndroidRuntime(13239): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
06-06 22:17:15.912: E/AndroidRuntime(13239): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:117)
06-06 22:17:15.912: E/AndroidRuntime(13239): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class android.support.v7.internal.widget.NativeActionModeAwareLayout
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:890)
06-06 22:17:15.912: E/AndroidRuntime(13239): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
06-06 22:17:15.912: E/AndroidRuntime(13239): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:656)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.parseInclude(Unknown Source)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
06-06 22:17:15.912: E/AndroidRuntime(13239): at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
06-06 22:17:15.912: E/AndroidRuntime(13239): at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:656)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.inflate(Unknown Source)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:299)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
06-06 22:17:15.912: E/AndroidRuntime(13239): at com.example.test.MainActivity.onCreate(MainActivity.java:11)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.app.Activity.performCreate(Activity.java:5933)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
06-06 22:17:15.912: E/AndroidRuntime(13239): ... 11 more
06-06 22:17:15.912: E/AndroidRuntime(13239): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.widget.NativeActionModeAwareLayout" on path: DexPathList[[zip file "/data/app/com.example.test-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
06-06 22:17:15.912: E/AndroidRuntime(13239): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-06 22:17:15.912: E/AndroidRuntime(13239): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-06 22:17:15.912: E/AndroidRuntime(13239): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.createView(LayoutInflater.java:571)
06-06 22:17:15.912: E/AndroidRuntime(13239): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
06-06 22:17:15.912: E/AndroidRuntime(13239): ... 30 more
06-06 22:17:15.912: E/AndroidRuntime(13239): Suppressed: java.lang.ClassNotFoundException: android.support.v7.internal.widget.NativeActionModeAwareLayout
06-06 22:17:15.912: E/AndroidRuntime(13239): at java.lang.Class.classForName(Native Method)
06-06 22:17:15.912: E/AndroidRuntime(13239): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
06-06 22:17:15.912: E/AndroidRuntime(13239): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
06-06 22:17:15.912: E/AndroidRuntime(13239): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
06-06 22:17:15.912: E/AndroidRuntime(13239): ... 33 more
06-06 22:17:15.912: E/AndroidRuntime(13239): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
答案 0 :(得分:1)
将此添加到依赖项
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.0'
如果它不工作将jar库添加到你的lib文件夹并重建你的项目,然后删除jar库并运行你的项目。
jar文件位于此文件夹路径
中C:\用户\ Lakshan \应用程序数据\本地\的Android \ SDK \额外\机器人\支持
转到design和v7文件夹并将两个jar文件复制到项目中。
如果您无法在此路径中找到jar文件,请在sdk中更新您的附加内容。特别是Android支持库。