java.lang.NoClassDefFoundError: how do I fix this error? - java

I am developing an Android application which makes use of the Osmdroid maps api. I have added the library as an external jar in my build path and I do not get any errors during compile time. However, upon device deployment I get the following error:
03-27 16:18:50.986: E/AndroidRuntime(3306): java.lang.NoClassDefFoundError: org.osmdroid.util.GeoPoint
I have done some googgling and it is still a mystery to me.
Here is my IDE configuration.
Eclipse: Indigo Release version 2
Java SDK: 1.6.0_31
Android SDK: 17

You need to go into Build Path/Order and Export, and check the libs as of SDK 17. Then clean your project.

I doubt about you and your project. From my viewpoint, I see you have a good design. But why are you working with Build Path / Order and Export? Honestly I've never gone to that tab from the first day I worked with Eclipse.
To import jar files as libraries, use tab Libraries -> add external Jars.
And I'm sorry I don't know about game programming, this is just a suggestion: make sure your engine fits what Android supports. For example Android doesn't support javax.imageio. If not, the app can be compiled with external jars, but can be crashed in runtime.

Related

Using Eclipse instead of Android Studio [duplicate]

I prefer eclipse over android studio, my question is if I can still use it to build projects for future development - for example the recycleview library. It is supported in eclipse too, but will future google libraries continue to support it?
My second question is, if I'm using eclipse to make an app, will it be run on new devices too, as the project structure is different in eclipse and android studio.
My final question is how can I use libraries from android arsenal if I don't use android studio (all the libraries there are for maven and gradle)?
I prefer eclipse over android studio, my question is if I can still use it to build projects for future development - for example the recycleview library. It is supported in eclipse too, but will future google libraries continue to support it?
In the end, it is all just Java, XML, and other such resources. The RecyclerView library is no exception- it is just a library that can be used in any IDE.
The IDE you use for development is just a tool to view and edit these project files. Separately, you use a build system to build the application. Your IDE, the build system, and the project files are completely separate and one doesn't depend on the other to create a functioning application. In fact, you can build an Android application without an IDE at all.
The biggest issue you might run into here is the format of libraries such as RecyclerView. In the Eclipse days (note that Eclipse Android projects typically use Ant for building), most libraries came as either JAR files or Android libraries (of source code). With the release of Android Studio and the Android Gradle plugin, everything is shifting towards Gradle dependencies.
Also be aware that Google is not going to continue supporting Eclipse development. The tools for building Android application in Eclipse will not continue to receive updates, so bugs may pop up in the future that prevent you from continuing to use it effectively.
My second question is, if I'm using eclipse to make an app, will it be run on new devices too, as the project structure is different in eclipse and android studio.
The output of building an Android application is the same regardless of how or where you build it - you get an APK with the same file structure. The structure of the built APK is independent of the structure of the source code.
My final question is how can I use libraries from android arsenal if I don't use android studio (all the libraries there are for maven and gradle)?
Eclipse can use both Gradle and Maven for building. If you want to use libraries as Gradle or Maven dependencies, you will need to set up your project to use either Maven or Gradle to build instead of Ant. Otherwise you can still find JARs for most projects that don't rely on the Android framework, or you will need to get the source code for the library and set it up as a project dependency yourself.

Errors while setting up LibGDX on Eclipse

I have been trying to setup LibGDX on Eclipse (4.3). I followed the instructions here: https://github.com/libgdx/libgdx/wiki/Prerequisites and installed both ADT plugin for Eclipse and the Google Web toolkit successfully. Then I used the libgdx-ui.exe to create the libGDX project and on creating it, I see errors in Eclipse.
I am pretty sure I have installed the plugins properly and I have JDK 7 as well.
Any help would be greatly appreciated.
Thanks :)
It seems I have not installed the GWT plugins properly. But on trying to install it from the link, the option to install the SDK does not appear in the list.(Please check the image in the last comment I posted).
1) Android requires (before kitkat) jdk 6. It won't work with jdk 7.
2) After installing ADT plugin, you also have to open android sdk manager and download required api files.
These two should fix your android and java.lang.Object issues. It's better to test an android app on this setup (without libgdx) first.
3) Right click on all warnings regarding classpath entries, eclipse will provide you automatic quick fixes.
If the issue stays after this, the problem is with gwt sdk installation. Now you can follow The project XXX does not have any GWT SDKs on its build path. It should work smoothly as other problems won't interfere with it now.
Hope this helps.

Can we use Android studio for AOSP development?

Can we use Android studio for AOSP(Android Open Source Project) development, is there a way to do it. I didnt find one. anybody got any idea on this please ?
You can use Android Studio as a IDE for AOSP, since it's just a modified version of InteliJ's IDE.
from AOSP root:
make idegen && development/tools/idegen/idegen.sh
Then just "Open Project" in Android Studio and select the android.ipr it generated.
To import AOSP source in Android Studio or Eclipse, follow the full instructions here :
https://android.googlesource.com/platform/development/+/master/tools/idegen/README
What Pedlar suggested above is one way of doing it. I ran into lot of Jar dependency issues when I tried it with IDEA community edition (Android Studio is a fork of IDEA IDE). The IDE keeps prompting you about duplicate jars etc. The generated project includes framework Java sources as well as App sources. I tried to build an App project which resulted in broken AOSP build. IMHO, IDEA is a great IDE for Java development. But didn't work well with AOSP.
What worked for me is using eclipse to browse/edit/debug framework sources, but build the code from a terminal window. To avoid AOSP build breaks, please create a shadow dir of AOSP (i.e. lndir of AOSP) and use shadow dir for eclipse project.
This is explained at Using eclipse to browse/edit AOSP link in step by step.
If you are working on AOSP, you might want to check Debugging Android framework services.

Android Project with ActionBarSherlock doesn't get built

I implemented the current version of ActionBarSherlock to my Android Project.
Everything works fine and I don't get any errors.
But when I try to debug or export my project I don't get an .apk-file out of my project. Just a .jar-file with the name of my project.
I've read about some problems the SDK had with building projects that contain external libraries but this was at SDK version 14 and so I hope, this bug is fixed...
So there might be another cause for this problem.
Does anybody know a possible solution?
You cannot get *.jar file as the result of building Android project. This seems very strange to me. There must be something wrong with your project settings (if you changed them), or the project you build is of the wrong type (i.e. it is Java Application instead of Android Application).
You didn't mention which IDE do you use, but I assume you use Eclipse.
Make sure you have installed Android SDK and Eclipse ADT correctly (just in case).
Next thing to try is to create a new Android Application project from existing sources (there should be such option during the process of creation).

Error when building apk - "Multiple dex files define Lcom/google/ads/Ad"

I've been tearing my hair out over this one, for the past 3 hours I've been trying to fix it but have been unable to. I've created an android app and I'm ready to put it on the android market but I get this error when trying to export to an apk.
Unable to execute dex: Multiple dex files define Lcom/google/ads/Ad;
I've read a bunch on the problem and tried quite a few solutions but nothing has seemed to help. I've cleaned and rebuilt, I've delete the bin folder, I've made sure that the bin folder is excluded build path. Nothing's worked. If anyone could help me I would really appreciate it.
Untick the admob jar file in the "order and export" part of the "configure build path".
On another post with a problem similar to yours the only thing mentioned that you have not already considered was updating Eclipse. I don't know how or what order that you have done these "fixes" but another poster mentioned that all at once he deleted the bin directory for his project, cleaned and rebuilt the project and restarted Eclipse. After that the error disappeared.
Good Luck- Lijap
For me the error was due to 2 different versions of AdMob SDK being included accidentally.
Removing one of them fixed it.
As other have noted, this problem should be due to multiple versions of Goodle's ad SDK classes being included in the app build. What I haven't seen yet is a note that the most recent Google Play Service lib includes classes that (at least) share the same names as some in the admob sdk-- for example, I came upon this error because I was trying to build with both admob sdk v.4.0.4 and the google-play-services_lib project as a referenced project; the latter contains google-play-services.jar which contains the package com.google.ads and many of the same classes as the admob sdk. Thus it appears that the google play services lib and the admob sdk cannot both be used in a given app. My solution was to remove the admob sdk entirely from the build.
I had the same or a similar problem. My problem was that my application imported a library which used a different version of AdMob SDK.
Details of my problem:
Library used AdMob SDK 6.3.0
Application used AdMob SDK 6.1.0
Fixed it by including the same version.
For me, I just have to take out the libs folder which contains android-support-v4.jar from build path and it worked.

Categories

Resources