Reputation: 585
I am not an Android developer, but I am trying to upgrade the Facebook SDK for an app I have on Android Studio. The previous SDK was 3.5 and I am trying to add 4.4.1
I have written the login class by following the getting started guide but now when I try to launch the app on a device, although it compiles just fine, it crashes on startup.
I get the following error:
08-05 21:05:25.128 25207-25207/? E/dalvikvm﹕ Could not find class 'com.history.HistoryOrder', referenced from method com.service.Global. 08-05 21:05:25.138 25207-25207/? E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.ExceptionInInitializerError at com.imperautus.testProject.ActivitySplash.onCreate(ActivitySplash.java:61) at android.app.Activity.performCreate(Activity.java:5326) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309) at android.app.ActivityThread.access$700(ActivityThread.java:157) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5317) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: com.history.HistoryOrder at com.service.Global.(Global.java:113) at com.imperautus.testProject.ActivitySplash.onCreate(ActivitySplash.java:61) at android.app.Activity.performCreate(Activity.java:5326) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309) at android.app.ActivityThread.access$700(ActivityThread.java:157) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5317) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method)
What I see is that it complaints that it cannot find the class com.history.HistoryOrder but this class is in this exact place and it worked before the transition to the new Facebook SDK (I haven't touched the class' code).
The Global.java:113 says:
public static ArrayList<HistoryOrder> historyOrderList = new ArrayList<HistoryOrder>();
public static HistoryOrder historyOrderItem = new HistoryOrder();
I also changed all references in my code from app.Fragment to the support.v4.app.Fragment version because I thought that this caused the problem.
Any clues?
Upvotes: 2
Views: 3163
Reputation: 6492
java.lang.NoClassDefFoundError is propably thrown because you have reached the 65k limit http://developer.android.com/tools/building/multidex.html#about
If you need to go beyond 65k limit you must include multidex support
gradle:
defaultConfig {
...
multiDexEnabled true
}
...
dependencies {
compile 'com.android.support:multidex:1.0.1'
...
}
Manifest:
<application
...
android:name="android.support.multidex.MultiDexApplication">
If you have a Custom Application class:
extend MultiDexApplication
or add MultiDex.install(getBaseContext());
to your CustomApplication onCreate()
Note that on some low-end devices adding
MultiDex.install(getBaseContext());
to your CustomApplicationonCreate()
can still throwjava.lang.NoClassDefFoundError
:
If so try adding MultiDex.install
to attachBaseContext(Context base)
instead
public class CustomApplication extends Application {
...
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
...
Upvotes: 7
Reputation: 585
ok, it seems that the error was due to a very different reason:
The app was updated to use Google Services 7.5 which made the methods go to more than 65k which made me to add the mutiDexEnabled to true.
I don't know if the code needs to be changed to support that, but it seems that after making this change, the app was crashing at random points (when I remarked the history call, the reachability class was crashing, when removed the reachability another, etc.
of course all classes were at the right place when the compiler complained about not finding them This made me wonder if the multidex caused that so I removed some of the libraries like going from 7.5 verson of google play to 6.5
The app compiles and runs just fine now, allowing me to add the FB sdk 4+
I post this here, so it may help other people having problems without being able to understand where they come from.
Upvotes: 3
Reputation: 1973
I think you set the wrong class path
so 1st check your class path
It will solve your problem
Upvotes: 0