2013-08-20 65 views
0

我有一個應用程序,其中有一個滑動菜單。我已經使用jfeinstein的庫實現了它。直到昨天它一直工作得很好,但現在已停止工作。我甚至沒有對代碼做任何修改。以下是錯誤報告:錯誤充氣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教程來設置滑動菜單。

+2

大概這是罪魁禍首。引起:java.lang.NoClassDefFoundError:android.support.v4.view.ViewConfigurationCompat 看看支持包v4是否已經添加到您的項目。如果沒有,將其添加到您的項目,它應該解決它。 –

+1

@AndroSelva嗨,老兄,你能不能給我你的照片,這樣我可以每天崇拜它,因爲剛剛爲我工作!這的確是缺少支持包V4 ..不知道它怎麼突然失蹤..非常感謝! – Anish

+0

不用擔心我的朋友。很高興它解決您的問題..順便說一句,你不必崇拜我。 :P –

回答

0

僅供參考,你最好從圖書館項目中添加支持包V4,而不是將其複製到本地庫。並記住將庫添加到滑動菜單應用程序。

0

最後我得到了它..你剛剛有右擊你的項目>的Android工具>添加支持庫,所以prblem是缺少支持包V4 ..

0

我已經得到了同樣的問題,我已經解決終於打開gradle.properties,並添加以下內容: android.enableAapt2=false