错误膨胀jfeinstein滑动菜单类

时间:2013-08-20 09:52:43

标签: android android-sliding

我有一个应用程序,其中有一个滑动菜单。我使用jfeinstein的库实现了它。它一直工作到昨天,但现在已经停止工作了。我甚至没有对代码进行任何更改。这是错误报告:

08-20 15:02:52.060: E/AndroidRuntime(32366): FATAL EXCEPTION: main
08-20 15:02:52.060: E/AndroidRuntime(32366): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.cvapp/com.cvapp.SecondActivity}: android.view.InflateException:  Binary XML file line #2: Error inflating class  com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.os.Looper.loop(Looper.java:137)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.app.ActivityThread.main(ActivityThread.java:4898)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at java.lang.reflect.Method.invokeNative(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at java.lang.reflect.Method.invoke(Method.java:511)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at dalvik.system.NativeStart.main(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityHelper.onCreate(SlidingActivityHelper.java:45)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity.onCreate(SlidingActivity.java:22)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.cvapp.SecondActivity.onCreate(SecondActivity.java:19)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.app.Activity.performCreate(Activity.java:5206)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
08-20 15:02:52.060: E/AndroidRuntime(32366):    ... 11 more
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: java.lang.reflect.InvocationTargetException
08-20 15:02:52.060: E/AndroidRuntime(32366):    at java.lang.reflect.Constructor.constructNative(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-20 15:02:52.060: E/AndroidRuntime(32366):    ... 21 more
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: java.lang.NoClassDefFoundError: android.support.v4.view.ViewConfigurationCompat
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.initCustomViewAbove(CustomViewAbove.java:167)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:157)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:152)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:209)
08-20 15:02:52.060: E/AndroidRuntime(32366):    at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:192)
08-20 15:02:52.060: E/AndroidRuntime(32366):    ... 24 more

这是我的代码:

主:

package com.cvapp;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;


public class SecondActivity extends SlidingActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    setBehindContentView(R.layout.activity_menu1);
    getSlidingMenu().setBehindOffset(100);

    SlidingMenu menu = getSlidingMenu();
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    setOnClickListener();
}
   @Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.second, menu);
    return true;
}

}

的xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="@drawable/pic9"
        android:clickable="true"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".SecondActivity" >

     <TextView
         android:id="@+id/textView2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentTop="true"
         android:layout_marginLeft="16dp"
         android:layout_marginTop="27dp"
         android:text="Hello"
         android:textColor="#000000"
         android:textSize="16sp"
         android:textStyle="bold" />

</RelativeLayout>

如果有帮助,我已按照this教程设置了滑动菜单。

3 个答案:

答案 0 :(得分:0)

仅供参考,您最好从库项目添加支持包v4,而不是将其复制到本地库。请记住将库添加到滑动菜单应用程序中。

答案 1 :(得分:0)

最后我明白了......你只需要右键点击你的项目&gt; Android工具&gt;添加支持库,因此prblem是缺少的支持包v4 ..

答案 2 :(得分:0)

我遇到了同样的问题,最后我解决了打开gradle.properties并添加了以下内容: android.enableAapt2=false