I have created the three projects as described in http://code.google.com/p/libgdx/wiki/ProjectSetup, and running the desktop version works, but I am getting the error below when I run the android version on the emulator. The main project is in the build path of the android project and eclipse builds everything with no errors. what am I missing?
10-31 07:06:47.023: E/dalvikvm(769): Could not find class 'com.mygame.MyGame',
referenced from method com.mygame.MyGameAndroid.onCreate
I have resolved this when I switched the Java compiler for the main project from JavaSE-1.7 to JavaSE-1.6. Do now know why this did not work with JavaSE-1.7. Would appreciate any comments on that.
EDIT: a related post: http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=2314
In my case, this happened because my core Game class derived from a framework Game class. The framework class wasn't properly included; since the subclass couldn't be found, Android reported that the main class couldn't be found (since it wasn't fully known).
To solve this, I correctly added my derived framework reference, and everything worked.
In had to check the radio button in the android project properties->Java Build Path-> Order and Export-> main game project. Hope it helps anyone else.
Related
When I cloned Android's default alarm in Anroid Open Source Project # https://android.googlesource.com/platform/packages/apps/DeskClock/ and tried to run it on Android Studio I got the following error:
package com.android.datetimepicker.time does not exist
cannot find symbol class TimePickerDialog
cannot find symbol class RadialPickerLayout <anonymous
com.android.deskclock.alarms.TimePickerCompat$TimerPickerPreL$1> is
not abstract and does not override abstract method
processTimeSet(int,int) in OnTimeSetListener
Please help in any way. Thank you.
After a week of frustration, I was able to clone the default alarm app and get rid of the above DateTimePicker errors mentioned above by injecting the dependency to the gradle by:
compile 'com.github.citux:datetimepicker:0.2.0'
Thanks to the good people out there (https://github.com/CiTuX/datetimepicker) who have cloned and distributed as a gradle dependency of the framework used in Android Open Source Project # https://android.googlesource.com/platform/frameworks/opt/datetimepicker
Hope this will help some who works on cloned Android Open Source Project.
Neither of those classes exist in the Android SDK. There is a
TimePickerDialog, as others have noted, in a different package.
There is a RadialPickerLayout in the Android source code, and you
are welcome to try to use it.
Really, you should be talking to whoever wrote this Android project
and asking them where they were planning on getting those classes
from.
Here is the main answer
When I run a Andriod test (junit) test in Android Studio I get the folowing errormessage.
Exception in thread “main” java.lang.NoClassDefFoundError: junit/textui/ResultPrinter.
I assume the error is because it cannot find the junit.jar file.
When I follow below junit setup it does not fix the error:
http://www.tutorialspoint.com/junit/junit_environment_setup.htm
I cannot get above setup working. It still cannot find the junit classes.
Any ideas how to fix the problem.
Did you put your test class in correct place in the folder structure, Martin?
Look at the table under "Flavors and build types support" on http://tools.android.com/tech-docs/unit-testing-support
It resolved the issue for me, but I had to move the test class (and create folders) manually - while Android Studio can generate the test suite automatically for you (Go to... Test, after right-clicking on the class header), it doesn't offer to put it in right location by default, so it can be confusing.
Also make sure to set Test Artifact to "Unit Tests" in Build Variants tab, but the official tutorial says that more explicitly so I assume that's not what you overlooked.
I understand your question was dated, but maybe someone stumbles upon it like I only just did struggling with this issue myself ;) And guys, remember - highest voted answers on StackOverflow that tell you to stick to Android tests and drop JUnit are obsolete now, Android Studio supports JUnit tests that run on your PC directly, as explained in the link I posted above. Of course they don't give you access to instrumentation - I use them to test my "pure" Java logic which is platform agnostic.
I know that there are some similar questions, but no solution helped me.
I am getting a java.lang.NoClassDefFoundError when I try to access an (existing) class
in a self-created .jar from my projectgroup.
This .jar works fine in an normal javaProject but doesn´t work with Android.
But an older version of this .jar worked fine with Android.
I am developing with Eclipse + Android Development Tool - Plugin (Version 21)
I have put the .jar in the Project_Home/libs folder.
There are no errors at compiletime.
Before the exception was thrown, there was some "dalvikvm - could not find class ... referenced from ..." errors.
I think, there could be a problem with the Java Version, because our projectgroup recently started to use Java 7, but I am not sure and have no idea how to fix it.
Thanks a lot for your help.
Rename your lib to libs and update the build path and then try again
I think if the project is compiling fine then we can rule out any error in copying or java buildpath. The only other time i get this error is when my import is wrong in the code. I would suggest you to re-check your import and recreate R.java file.
Make sure that your classes do not have same names as ones already present within Android. Upon building the package, due to "optimization" classes with same names are omitted.
Android libraries are mostly compiled against 1.5. Not all libraries are also present within Android. Your package may depend on some other library that is not present within the system.
Ordinarily I don't want to answer my own question but I hope it will help someone.
I didn't see an other warning (not in Logcat, it was in the console):
"Dx bad class file magic (cafebabe) or version (0033.0000)"
I had found this Warning in an other Stackoverflow question.
I had opened one of the class file from the not working .jar with an HexEditor
and changed the Major-Version-Byte to 0x32 and it worked.
I know this is not a solution, because there could be features from Java 7 in the class,
so the class file no longer work, but it proves that it was a problem with the Java version
Well, I wanted to create a Library project from my existing sources so that it would help me re-use code for the paid app that I have in mind. When I saw the developer guide on how this was to be done, I thought it was very simple.
Just mark the project as a Library project and it should be converted to one.
But when I tried referencing one of the base classes in an application, the app force closes with the following exceptions
02-04 21:50:06.765: E/AndroidRuntime(699): java.lang.NoClassDefFoundError: in.my.package.name.R$layout
Let me give you some more info. I have referenced the Library project in the application and have also included the manifest entries with fully qualified activity names. I have a BaseActivity which has all the menu and re-usable code bits. The point where the above exception occurs is where I am trying to reference the layout file in this BaseActivity inside the library project.
setContentView(R.layout.apphome);
What is it that I am missing or doing wrongly?
PS: I am just noticing that When I right click on my application and go to the android tab, there is a red cross instead of a green tick in the place where the library project is referenced. But there are no visible errors on the console or in the code of the project.
Seems its a known issue.
Issue link here
Hope Google guys resolve this problem in their next SDK release.
So to be clear, the problem was that my libraries had custom styling capabilities and that was the problem.
I was trying to do a simple app using the Google Tasks API. Something simple it's turning into a nightmare. Maybe it's something simple, probably it is, but I can't figure it out.
The problem: I was following the example of TasksSample.java from Google but I can't compile even after importing the libraries and dependencies required. I'm using Google API Java Client version 1.5.0.
The problem it's when I access the GoogleAccessProtectedResource class. The import is:
import com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessProtectedResource;
I always, and I mean always, no matter what code I have get the following error:
09-26 03:14:38.372: ERROR/dalvikvm(18731): Could not find class 'com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessProtectedResource', referenced from method com.greven.test.google.tasks.GoogleTasksTake100Activity.
09-26 03:14:38.402: ERROR/AndroidRuntime(18731): FATAL EXCEPTION: main
09-26 03:14:38.402: ERROR/AndroidRuntime(18731): java.lang.NoClassDefFoundError: com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessProtectedResource
I really can't see where the problem is. I imported all the needed .jars... I guess
As you can see in this picture the class is obviously imported:
So what other options do I have to fix this? Use Maven? I'm clueless now. I never thought I would have a problem like this. Oh I also tested on different computers, other Google java api client (version 1.4) and same thing happened. Thanks in advance.
It seems as per your screenshot that your imported jar is imported in Eclipse, however for your Android application to work you need these jars to be dropped into a specific folder so that it is added to your APK and so the emulator and the Android devices find it.
It seems you should drop these jars in a folder named /libs at the root of your project. See this SO question: How can I use external JARs in an Android project?
The Article you are referring too uses the /assets folder but this might have changed a few Android versions ago.