我正在开发一个启动MainActivity
的应用程序,并检查用户是否已登录共享首选项,如果他已登录,则会将他带到OfferSelect
活动。
问题是它在setContentView(R.layout.main)
给出错误时停止
10-27 22:34:38.850: E/AndroidRuntime(689): FATAL EXCEPTION: main
10-27 22:34:38.850: E/AndroidRuntime(689): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.countryselect/com.example.countryselect.OfferSelect}: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.internal.widget.ActionBarOverlayLayout
10-27 22:34:38.850: E/AndroidRuntime(689): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.os.Looper.loop(Looper.java:137)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-27 22:34:38.850: E/AndroidRuntime(689): at java.lang.reflect.Method.invokeNative(Native Method)
10-27 22:34:38.850: E/AndroidRuntime(689): at java.lang.reflect.Method.invoke(Method.java:511)
10-27 22:34:38.850: E/AndroidRuntime(689): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
10-27 22:34:38.850: E/AndroidRuntime(689): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
10-27 22:34:38.850: E/AndroidRuntime(689): at dalvik.system.NativeStart.main(Native Method)
10-27 22:34:38.850: E/AndroidRuntime(689): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.internal.widget.ActionBarOverlayLayout
10-27 22:34:38.850: E/AndroidRuntime(689): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:273)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:225)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
10-27 22:34:38.850: E/AndroidRuntime(689): at com.example.countryselect.OfferSelect.onCreate(OfferSelect.java:158)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.app.Activity.performCreate(Activity.java:4470)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-27 22:34:38.850: E/AndroidRuntime(689): ... 11 more
10-27 22:34:38.850: E/AndroidRuntime(689): Caused by: java.lang.reflect.InvocationTargetException
10-27 22:34:38.850: E/AndroidRuntime(689): at java.lang.reflect.Constructor.constructNative(Native Method)
10-27 22:34:38.850: E/AndroidRuntime(689): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
10-27 22:34:38.850: E/AndroidRuntime(689): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
10-27 22:34:38.850: E/AndroidRuntime(689): ... 22 more
10-27 22:34:38.850: E/AndroidRuntime(689): Caused by: java.lang.NoClassDefFoundError: android.support.v7.internal.widget.ActionBarOverlayLayout$1
10-27 22:34:38.850: E/AndroidRuntime(689): at android.support.v7.internal.widget.ActionBarOverlayLayout.<init>(ActionBarOverlayLayout.java:91)
10-27 22:34:38.850: E/AndroidRuntime(689): ... 25 more`
我的OfferSelect
onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getOverflowMenu();
try
{
startLongRunningOperation();
}
catch (Exception e){
}
}
}
我的main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/main_layout4" >
<LinearLayout
android:id="@+id/main_layout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<requestFocus />
</LinearLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
答案 0 :(得分:5)
VM无法找到android.support.v7.internal.widget.ActionBarOverlayLayout
检查您的apcompat_v7是否已正确导入。同时从libs文件夹中删除android-support-v4.jar。此支持库的不同版本也可能导致此问题。