Migrating from Eclipse to Android Studio causing problems, app not starting

90 Views Asked by At

I shifted my app from eclipse to android studio but the app is giving errors of "could not find class". I have included all required libraries, jars,etc. And unlike other questions on S.O , my errors are related to my own classes, not classes from other libraries. And its mainly crashing on Handler in the class. Here is the log cat:

06-25 10:44:09.112    4006-4006/? E/dalvikvm﹕ Could not find class'com.Mylocation.MyLocation1$MyLocationListener', referenced from method com.Mylocation.MyLocation1.startGPS
06-25 10:44:09.114    4006-4006/? E/dalvikvm﹕ Could not find class 'com.GetDetailBean.OrderDetailsBean', referenced from method com.taxi_customer_sharedpreference.Sharedpreferences.getOrderDetails
06-25 10:44:09.123    4006-4024/? E/dalvikvm﹕ Could not find class 'com.server_connection.AppClient$JSONEntity', referenced from method com.server_connection.AppClient.execute
06-25 10:44:09.763    4006-4012/? E/jdwp﹕ Failed sending reply to debugger: Success
06-25 10:44:10.417    4006-4024/? E/dalvikvm﹕ Could not find class 'com.asiApp.NewOtherDriver', referenced from method com.parsing.ParsingClass.getDriversList
06-25 10:44:10.418    4006-4024/? E/dalvikvm﹕ Could not find class 'com.asiApp.NewOtherDriver', referenced from method com.parsing.ParsingClass.getDriversList
06-25 10:44:10.423    4006-4024/? E/dalvikvm﹕ Could not find class 'com.GetDetailBean.HistoryDetailBean', referenced from method com.parsing.ParsingClass.getHistoryDetail
06-25 10:44:10.535    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$3', referenced from method com.asiApp.MyMap.<init>
06-25 10:44:10.538    4006-4006/? E/dalvikvm﹕ Could not find class 'com.taxiConstant.Rotate3dAnimation', referenced from method com.asiApp.MyMap.applyRotation    
06-25 10:44:10.547    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$GetAddressAsync', referenced from method com.asiApp.MyMap.moveTocurrent
06-25 10:44:10.548    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$11', referenced from method com.asiApp.MyMap.updateDriversList
06-25 10:44:10.548    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$12', referenced from method com.asiApp.MyMap.LogoutOtherDevice
06-25 10:44:10.551    4006-4006/? E/dalvikvm﹕ Could not find class 'com.map.Overlay.MyItemizedOverlay', referenced from method com.asiApp.MyMap.drawPoints
06-25 10:44:10.553    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$1', referenced from method com.asiApp.MyMap.onActivityCreated
06-25 10:44:10.554    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$GetAddressAsync2', referenced from method com.asiApp.MyMap.onActivityResult
06-25 10:44:10.555    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$2', referenced from method com.asiApp.MyMap.onActivityResult
06-25 10:44:10.559    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$GetAddressAsync2', referenced from method com.asiApp.MyMap.onCameraChange
06-25 10:44:10.561    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$7', referenced from method com.asiApp.MyMap.onCreateDialog
06-25 10:44:10.561    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$10', referenced from method com.asiApp.MyMap.onCreateDialog
06-25 10:44:10.564    4006-4006/? E/dalvikvm﹕ Could not find class 'com.asiApp.MyMap$14', referenced from method com.asiApp.MyMap.payOptions
06-25 10:44:10.576    4006-4006/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.asiApp.MyMap$3
        at com.asiApp.MyMap.<init>(MyMap.java:886)
        at com.asiApp.SlidingMain.displayView(SlidingMain.java:229)
        at com.asiApp.SlidingMain.onCreate(SlidingMain.java:161)
        at android.app.Activity.performCreate(Activity.java:5125)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2289)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2377)
        at android.app.ActivityThread.access$600(ActivityThread.java:167)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:153)
        at android.app.ActivityThread.main(ActivityThread.java:5341)
        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:929)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
        at dalvik.system.NativeStart.main(Native Method)

And this is code on line 886:

private Handler changeaddtHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        chageAddresstoGeoThread.interrupt();
        if (msg.obj.toString().equalsIgnoreCase("change_success")) {
            if (changeGeopoint != null) {
                CameraPosition cameraPosition = new CameraPosition.Builder()
                        .target(changeGeopoint).zoom(16).build();
                mMap.animateCamera(CameraUpdateFactory
                        .newCameraPosition(cameraPosition));
            } else {
                Toast.makeText(context, "Sorry did't find your location.",
                        Toast.LENGTH_SHORT).show();
            }
        }
    }
};

And the code was working fine on eclipse without any issues. Any help would be appreciated. Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

I solved the problem by addinf MultiDex support to my application. I was incompletely implementing MultiDex support, so some of my classes weren't in the proper dex file. To fix it, you have to do more than just set multiDexEnabled = true in your defaultConfig block. You also have to:

  1. Include compile 'com.android.support:multidex:1.0.0' in your dependencies
  2. Have your Application class extend MultiDexApplication instead of just Application. Alternatively, you can call MultiDex.install() in attachBaseContext() of your application.

See https://developer.android.com/tools/building/multidex.html for more details.

Originally referred from this question from stack overflow