0

I'm trying to switch from Eclipse to IntelliJ IDEA for Android developing.

Currently I have an Android application which depends on more than 10 libraries (including third libraries and jars).

First of all, when I tried to run the application, I got a Dalvik DEX error. I could solve that modifying the scope of the dependencies of my projects, not mine. After I did this, I got this other error, which I don't know how to solve it...

03-11 16:10:10.423: ERROR/AndroidRuntime(10258): FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.niula.loodic.android/com.niula.loodic.android.ui.HomeActivity}: java.lang.ClassNotFoundException: Didn't find class "com.niula.loodic.android.ui.HomeActivity" on path: /system/framework/com.google.android.maps.jar:/data/app/com.niula.loodic.android-1.apk
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    at android.app.ActivityThread.access$600(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5041)
    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:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.niula.loodic.android.ui.HomeActivity" on path: /system/framework/com.google.android.maps.jar:/data/app/com.niula.loodic.android-1.apk
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)

Why is happening this?

Didn't find class "com.niula.loodic.android.ui.HomeActivity" on path: /system/framework/com.google.android.maps.jar:/data/app/com.niula.loodic.android-1.apk

Any help is welcome, I cant attach some images because I don't know the origin of the problem. Actually I get some strange errors from editor because Google Maps V2.

enter image description here enter image description here enter image description here enter image description here

http://imageshack.us/f/199/captura1.png/ http://imageshack.us/f/708/captura2zt.png/ http://imageshack.us/f/571/captura3h.png/ http://imageshack.us/f/835/captura4qk.png/

Thanks in advance

EDIT: If I change all my module (libraries) dependencies "scope" to "compile", this is the error I get during DEX execution:

Android Dex: [loodic] java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;

enter image description here

cesards
  • 15,882
  • 11
  • 70
  • 65
  • What happens when you change the scope from Provided to Compile. From my experience, if you have any .jars or modules that a module depends on, it should be set to Compile. Also, if I am interpreting this correctly, Provided only provides dependencies during compilation, not run time (http://www.jetbrains.com/idea/webhelp/dependencies-tab.html) – Alex Fu Mar 11 '13 at 16:08
  • Take a look to my edited post. – cesards Mar 11 '13 at 16:17

1 Answers1

1

Ah, the UNEXPECTED TOP-LEVEL EXCEPTION error...

The Android Dex: [loodic] java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat; piece should give you an idea of what's going on.

Basically, if you are using the same android support library file for various modules, make sure they point to the SAME .jar file, and not copies of the same file. That should fix your Dex error.

Alex Fu
  • 5,509
  • 3
  • 31
  • 40
  • Yeah that was the point... Thanks so much!!! I thought that IntelliJ worked as Eclipse. What's the typical way to handle that? copying library.jar to your main module and make sure to use this jar pointing to all your module dependencies? – cesards Mar 11 '13 at 16:36