Multiple dex files + Unable to start activity ComponentInfo - java

After searching for similar questions/answers without success I'll try to explain my situation.
I've an Andorid game developed with LibGDX, which also uses the Google Play Games services.
My game is composed by several projects:
google-play-services_lib (lib project provided by Google, unmodified)
http://i.stack.imgur.com/1XnHn.png (libs)
http://i.stack.imgur.com/Gay5H.png (buildpath)
BaseGameUtils (lib project provided by Google, unmodified. depends on 1)
http://i.stack.imgur.com/3iJ0W.png (libs)
http://i.stack.imgur.com/noNDX.png (buildpath)
odd-blocks (the principal project of the game)
http://i.stack.imgur.com/atsKA.png (libs)
http://i.stack.imgur.com/5MDua.png (buildpath)
odd-blocks-android (basically the main activity class, depends on 1, 2, and 3)
http://i.stack.imgur.com/VUxJt.png (libs)
http://i.stack.imgur.com/yP6wv.png (buildpath)
odd-blocks-desktop (for testing the game on desktop mode, depends on 3)
http://i.stack.imgur.com/pKGUf.png (libs)
http://i.stack.imgur.com/9XzdM.png (buildpath)
My problem is that, with the configuration shown, when I try to execute the odd-blocks-android project I obtain the following error:
[2014-03-08 19:04:22 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
[2014-03-08 19:04:22 - odd-blocks-andorid] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Which is related to the "andorid-support-v4.jar", I'm sure to have only one version of this jar, as you can see in the images. There is a "solution" proposed in some questions to disable the private libraries in the build path configuration. In my case, if I do that, the game is executed but before starting there is a exception that says:
03-08 18:26:05.524: E/AndroidRuntime(15449): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.damsoft.oddblocks/com.damsoft.oddblocks.MainActivity}: java.lang.NullPointerException
There are also, some questions available about this second error message, that mentions that it is because the manifest is incorrect because does not have the activity registered. I'm sure that this is not my case, because I checked it, and also because my game worked before. In these questions they also mention that a way to resolve this error is to enable the "android private libraries" in the build path configuration screen, but then, I got the first error...
It is also important to mention that this error started to happen after the update to "Android SDK build-tools" v19 (currently 19.0.3).
I've been trying many things but nothing seems to solve the issue, maybe is something stupid... I don't know, but I'm out of ideas. I hope you can help :)

Finally I found the problem.
It was the "gdx-backend-android.jar", and some bad luck.
I installed a nightly build of LibGDX that for some reason included the classes of the android-support-v4.jar that caused the conflict of versions.
My solution was as simple as re-download libgdx.
But as a general remark, it is important to notice that this error message could mean that some other lib includes duplicated classes. Not necessarily with the same file name. The only way I found to check this was to rename the jar files to zip, and check for the duplicated class files.

Related

Android Studio Javadoc Generation error: cannot find symbol R

I am trying to generate javadocs for a larger android project - using android studios built-in "Tools > Generate JavaDoc". I have tried different scopes (my module, a custom scope containing only the java files I created, Project Files, ...) but everytime there is a class included which uses import com.my-app.R; or a generated class such as SomeFragmentBinding for ViewBinding, I get an
error: cannot find symbol from javadoc...
Apart from this problem the usual building and executing of the app is completely successful and works like a charm, although I get some some warnings regarding my database layout. Also I am using Hilt for Dependency Injection, but I don't really think that is related?
Now I am a complete noob using gradle and my attempts to configure the javadoc task myself have failed - and from what I have found online this should generally work out-of-the-box.

Android Studio: Getting JDocTest to work

Currently my team is working on some more complex code which our app will use and although we have UnitTests running we would really like to be able to use JDocTest so that we can create tests while we write some of our smaller methods.
I have successfully followed the instructions from JDocTest github read me and compiled it into my project. However I'm having trouble running the particular .java class files. I'm trying to be able to run MatrixCreator.
Here is what my directory looks like
Here is my attempt to set up MatrixCreator under application
I get the error
Error:Gradle: A problem occurred configuring root project 'AvocadoCoreProject'.
Could not resolve all files for configuration ':classpath'.
Could not find com.android.tools.build:gradle:3.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
Required by:
project :

Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions

My Project shows no errors. Though when I run the application it says please fix the error before running your application. When I looked at Console tab it says
[2015-07-10 19:50:26 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;
[2015-07-10 19:50:26 - NavigationDrawer] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;
I tried searching for the solution but haven't got any.
this is what I have for my support libraries.
Please Help. I got stuck here. Thank you in advance.
You have added several times this same library try to delete it to get only one (android-support-v7-appcompat.jar).
I propose to remove last (at bottom) and first (at top).
I do not know how you android program does, but from my experience these types of errors is the beginning of many erroes own eclipse. I recommend migrate their projects to AndroidStudio an excellent IDE that works without any kind of bugs.

ClassNotFoundException with static context class [duplicate]

I write a android app in Eclipse and use run command on my cellphone.
It's run success on my cellphone.
But I use [Android Tools -> Export Signed Application Package...] to export my app.
Then use [adb install] to install apk on my cellphone and run.
And I got the error message:
07-22 11:20:43.537: E/AndroidRuntime(20216): Caused by: java.lang.ClassNotFoundException: com.mytest.MyActivity in loader dalvik.system.PathClassLoader[/data/app/com.mytest-1.apk]
In [Java Build Path -> Order and Export], I have been selected all.
In AndroidManifest.xml, the application attribute doesn't have android:name.
I don't know how to solve this problem.
I'm success use Eclipse run on my cellphone, why run error when I export the app?
please help me, thanks!!
I had same issue, after 2 hours of research I managed to fix this problem by deleting "bin" and "gen" folders and rebuilding project.
There seems to multiple reasons for this happening from what I have researched. Do you have a lib folder? if so change it to "libs".
Do you have proguard enabled? If so that may cause the problem.
Also try unchecking the "Android #.#.#" and "Android Dependencies" in your Build Path, Order and Export.
Check out this thread which has a bunch of other possible solutions, a lot of them deal with setting the proper ActivityName in the manifest file.
java.lang.ClassNotFoundException on working app
If those solutions still don't solve the problem try these threads.
Android: Unable to instantiate activity / ClassNotFoundException
ClassNotFoundException Android
What I had to do is just re-do the building/exporting process with no modification to the code whatsoever. It worked for me, which I did was to export it two times.
On my first export, the build APK has lower file size and the second export (with no any modification to the code/configuration) produced a slightly larger file size (about 200KB diff).
This bug in building is really costly, kills you in front of your manager, and should be really fixed by Android/Eclipse team. Kind of sucks

exporting project with native libraries in eclipse

I have a project that uses leap motion sdk. I wrote this project in Eclipse. When I run my program I don't have any problem because I set my native libraries as it is suggested from configuration.
However, when I export my application I can not run my program because Eclipse does not include my native libraries and I am having this error.
Native code library failed to load.
java.lang.UnsatisfiedLinkError: no LeapJava in java.library.path
My purpose is create a .jar file which user can run with one click on Windows(just). I tried this methodologies as it is suggested in stackoverflow. However, I could not get this result.
1.) method with static{ System.load("write each .dll") }
This did not work becuse I am having a error when I try to load Leapd.dll.
2.) System.setProperty("java.library.path", "C:/Users/can/Desktop/Vinar_libraries/LeapSDK/lib/x64/" );
This one also did not work.
3.) Adding -Djava.library.path="\LeapSDK\lib\x64" parameter from running configurations on Eclipse.
I know this subject is mentioned many times in stackoverflow. However, proposed solutions did not work for Leap Motion sensor.

Categories