从Eclipse迁移到Android Studio导致问题,应用程序无法启动

时间:2015-06-25 06:11:30

标签: android eclipse android-studio handler

我将我的应用程序从eclipse转移到了android工作室,但该应用程序发出的错误是"找不到类"。我已经包含了所有必需的库,罐子等。与S.O上的其他问题不同,我的错误与我自己的类有关,而与其他库的类无关。它主要是在班上的Handler上崩溃。 这是日志猫:

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)

这是第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();
            }
        }
    }
};

代码在eclipse上运行正常,没有任何问题。 任何帮助,将不胜感激。感谢

1 个答案:

答案 0 :(得分:2)

我通过addinf MultiDex支持我的应用程序解决了这个问题。 我没有完全实现MultiDex支持,所以我的一些类不在正确的dex文件中。要修复它,您必须做的不仅仅是在defaultConfig块中设置multiDexEnabled = true。你还必须:

  1. 在您的依赖项中包含编译'com.android.support:multidex:1.0.0'
  2. 让您的Application类扩展MultiDexApplication而不仅仅是Application。或者,您可以在应用程序的attachBaseContext()中调用MultiDex.install()。
  3. 有关详细信息,请参阅https://developer.android.com/tools/building/multidex.html

    最初提到 this question from stack overflow