ERROR : java.lang.NoClassDefFoundError: android.su

2019-01-24 02:17发布

问题:

This question already has an answer here:

  • Android app crashes after SDK-tools update version (NoClassDefFound, tool version 22) 9 answers

I have gone through all the related threads about his error but i was not successful .

App was working fine and i found some updates on SDKs yesterday .

I Updated by Android SDK Tools to 22(Rev.) and updated other updates also to latest .

And when i run my app , it crashed with the Logs

05-17 05:27:37.039: E/AndroidRuntime(1406): FATAL EXCEPTION: main
05-17 05:27:37.039: E/AndroidRuntime(1406): java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
05-17 05:27:37.039: E/AndroidRuntime(1406):     at com.facebook.internal.SessionTracker.<init>(SessionTracker.java:76)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at com.facebook.widget.LoginButton.finishInit(LoginButton.java:475)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at com.facebook.widget.LoginButton.onFinishInflate(LoginButton.java:468)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:631)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.app.Activity.setContentView(Activity.java:1657)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at com.myproject.tabs.Tab_More.onCreate(Tab_More.java:92)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1491)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:676)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.widget.TabHost.setCurrentTab(TabHost.java:348)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:141)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:456)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.View.performClick(View.java:2485)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.view.View$PerformClick.run(View.java:9080)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.os.Handler.handleCallback(Handler.java:587)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.os.Looper.loop(Looper.java:130)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at android.app.ActivityThread.main(ActivityThread.java:3687)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at java.lang.reflect.Method.invokeNative(Native Method)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at java.lang.reflect.Method.invoke(Method.java:507)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
05-17 05:27:37.039: E/AndroidRuntime(1406):     at dalvik.system.NativeStart.main(Native Method)

And i have placed all my .Jar files in libs folder

i removed jars in the Project > Properties > Java Build Path .

But still i get this crash . Also i am getting crash in setContentView in onCreate method . Why do i get this crash in one particular activity , while other activities are running . Moreover i have blocked all my codes in that activity ( code is as below )

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myactivity);
}

Any related answers are welcomed and thanks in Advance .

回答1:

Did you mark the checkboxes for required libraries in order and export tab

look at this Post



回答2:

With SDK update to v22, the android dependencies and the android private libraries (v4, v7) are seperated into two different paths.

Make sure that all the libraries(of the main project) and the main project has "Android Private Libraries"(android cores) and the "Android Dependencies"(other libraries that particular project is dependent upon) is checked.

To do that, right click on the project, goto properties, select "Java Build Path" from the left panel, and in "Order and Export" tab, select the two.

thank you