Log in or register to post comments

Integrate Unity and Eclipse: Unable to execute dex

March 27, 2013 - 2:46am #1

Hi,

I have an Android project working in Unity. I built the apk and the app works fine. Now I want to integrate this part inside of my application in Eclipse. I followed these steps:

https://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse

I didn't reach the Code Changes part, I stopped at the step 15 of the Integration Steps, and there I get an error if I try to run the application. I tried it twice from scratch, so I don't think I missed any step.

I'm getting the following error:

[2013-03-27 10:23:40 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/qualcomm/QCARUnityPlayer/R$attr;

If I remove QCAR.jar and QCARUnityPlayer.jar from QCARJava /libs folder the error is gone, but then the application crashes because it can't find com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity.

I tried to clean both projects and to remove the QCARJava /bin folder but the problem is still there. This is my project explorer:

http://img109.imageshack.us/img109/2366/qcarfileexplorer.png

Anybody knows what might be causing this error and how can I fix it? Is it because there's a qcarunity.jar inside QCARUnity /bin?

Thanks!

Integrate Unity and Eclipse: Unable to execute dex

March 28, 2013 - 3:00am #9

Yes, I did it because I got the ClassDefNotFound error.

Integrate Unity and Eclipse: Unable to execute dex

March 28, 2013 - 2:56am #8

Ok, glad to see that the first problem is solved;

concerning the runtime crash, have you done this step too ?

 

Tip: if you get ClassDefNotFound (or similar) runtime errors, you might need to perform these extra steps:

  1. Go to the Project > Properties > Java Build Path Order and Export tab, and check (tick) theclasses.jarAndroid x.y and Android Dependencies items.
  2. Apply and rebuild the probject. 

Integrate Unity and Eclipse: Unable to execute dex

March 28, 2013 - 2:27am #7

Ok, with a different package name that error is gone. If someone else finds this error, you cannot use com.qualcomm.QCARUnityPlayer as your package name.

But now I found myself with another error when the app starts:

03-28 10:08:06.950: E/dalvikvm(10026): ERROR: couldn't find native method
03-28 10:08:06.950: E/dalvikvm(10026): Requested: Lcom/unity3d/player/UnityPlayer;.unityAndroidInit:(Ljava/lang/String;Ljava/lang/String;)V
03-28 10:08:06.950: E/dalvikvm(10026): Candidate: Lcom/unity3d/player/UnityPlayer;.unityAndroidInit:(Ljava/lang/String;Ljava/lang/String;)Z
03-28 10:08:06.950: E/dalvikvm(10026): JNI posting fatal error: com/unity3d/player/UnityPlayer
03-28 10:08:06.950: E/dalvikvm(10026): VM aborting
03-28 10:08:06.950: A/libc(10026): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

It seems it has something to do with the .so libraries. The app finds and loads the libraries:

Added shared lib /mnt/asec/com.dt.Track1-1/lib/libQCAR.so 0x41255968
Added shared lib /mnt/asec/com.dt.Track1-1/lib/libQCARWrapper.so 0x41255968
No JNI_OnLoad found in /mnt/asec/com.dt.Track1-1/lib/libQCARWrapper.so 0x41255968, skipping init
Added shared lib /mnt/asec/com.dt.Track1-1/lib/libQCARUnityPlayer.so 0x41255968
No JNI_OnLoad found in /mnt/asec/com.dt.Track1-1/lib/libQCARUnityPlayer.so 0x41255968, skipping init
Added shared lib /mnt/asec/com.dt.Track1-1/lib/libmono.so 0x41255968
No JNI_OnLoad found in /mnt/asec/com.dt.Track1-1/lib/libmono.so 0x41255968, skipping init
Added shared lib /mnt/asec/com.dt.Track1-1/lib/libunity.so 0x41255968

But it seems it's not calling the right method (the only difference between the requested method and the existing method is the last letter: V or Z. Do you have any idea what could this be?

Integrate Unity and Eclipse: Unable to execute dex

March 27, 2013 - 8:17am #6

Ok,

the fact that you change the android-target to 17 is certainly something that you should not do, unless you set the same target version in Unity as well (the two must be consistent, otherwise the whole integration will not work);

so, that's one possible reason of your error;

so, if you want to stick to Android 2.2 (level 8) both in Unity and Android, you can easily fix the android:configChanges just by removing the "screenSize" and "smallestScreenSize" from the list

Second:

the package name is also fundamental; if your package name in Android is different from the bundle identifier used in Unity, then the integration will also not work.

So, these are little details, but you must make sure that everything is exactly as described in the step-by-step guide.

 

Integrate Unity and Eclipse: Unable to execute dex

March 27, 2013 - 8:06am #5

I've done those steps and the error is still the same. 

When I import the QCARUnity in eclipse (step 6), I need to change project.properties to remove some errors. In project.properties android-target is set to 8, and I need it to be 17, otherwise the attributes:

android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"

give me an error. I'm not sure if that has something to do about it.

Also, the name of the package used in Unity is com.qualcomm.QCARUnityPlayer. I'm not responsible of the Unity part, so I asked the one in charge to change its package name to see if that has something to do about this error.

Integrate Unity and Eclipse: Unable to execute dex

March 27, 2013 - 6:03am #4

Hey, now reading again your original post; you say that you stopped at step 15;

actually, you also need to perform these extra part (which I copy-paste here):

 

Code changes

The following small code changes must be applied to the main activity class (e.g. "QCARJavaActivity") in your "QCARJava" project:

  1. Make your main activity class (e.g. "QCARJavaActivity") extend from QCARPlayerActivity (instead of extending from Activity).

  2. Press Ctrl+Shift+O to automatically adjust the imports.

  3. Remove the line "setContentView(R.layout.main)."

  4. Edit the AndroidManifest.xml of your QCARJava project; replace the name of the main activity, which is set to "com.qualcomm.QCARUnityPlayer.QCARPlayerProxyActivity" with the name of your actual main activity, e.g. "com.my.org.QCARJavaActivity."

You are now ready to build and launch your QCAR-based Unity Android project on your device from Eclipse.

 

In particular, the part where you adjust the AndroidManifest.xml is an essential part (because otherwise the androidmanifest is incorrect)

 

 

 

Integrate Unity and Eclipse: Unable to execute dex

March 27, 2013 - 5:10am #3

I did all the steps again and I found a mistake I made: if I move the entire /lib folder from QCARUnity to QCARJava the folders don't merge, actually it does nothing. Now I copied it manually and in QCARJava I have:

/libs/armeabi-v7a
/libs/android-support-v4.jar
/libs/QCAR.jar
/libs/QCARUnityPlayer.jar

The rest is exactly the same as the image I posted before, and the error is still there.

I have no /libs folder inside assets (neither in QCARJava, QCARUnity or the StaginArea folder). StagingArea folder only has assets/bin. Should it have assets/libs? Or I have to copy QCARUnity /libs inside QCARJava /assets instead of QCARJava /libs? I tried to copy it inside /assets but it doesn't fix it either.

 

Integrate Unity and Eclipse: Unable to execute dex

March 27, 2013 - 4:20am #2

Hi,

it looks like you miss these libraries in your QCARJava project structure:

under your "assets" directory, I don't see "/libs/armeabi-v7a" (under your "/assets/" folder I only see "bin" and "QCAR" sub-dirs)

I think you probably did not followed the steps exactly as they are descrobed in the tutorial; maybe double-check again.

 

Log in or register to post comments