I am trying to setup a new Android project with Mapsforge. I know that people have been getting this issue because the library requires Java 7 to build. However, I am using Build-Tools verson 20, which uses Java 7. I also have the latest updated version of the Eclipse tools. In fact, I am on a clean install of the Android Developer Kit.
So far, I have imported mapsforge-core, mapsforge-map, mapsforge-map-android, mapsforge-map-awt, and mapsforge-map-reader.
I then tried to initialize a MapView using the following code:
AndroidGraphicFactory.createInstance(thisApp);
This results in the following error.
java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory
I looked in the referenced libraries, and the AndroidGraphicFactory class is defined within org.mapsforge.map.android.graphics and shows up. When looking at the jar file within /bin/dexedLibs\, the classes.dex file exists, but there is next to nothing else.
I followed the steps suggested by this answer, but the error persists.
Any ideas as to why this might be?
You need put the jar file into the libs/ folder insted of add reference on java build path.
Related
I've been having some struggles with building my app after Reinstalling Android Studio. The cues I've gotten have been related to either Java location or installation. With the jre already installed it seems more likely not to be an issue with JAVA.
I've tried importing my project, copy and pasting from .txt files, reinstalling java, redefining java PATH, changing build dependencies, downloading command line sdk manager to build outside of the ide, erasing build caches, and I also let Android Studio rewrite properties.profile when importing Android Studio Project.
Another strange thing, when I create a directory in the project structure it shows up when the ide is initiating before gradle builds. After gradle builds the folder is no longer visible.
EDIT
error: package R does not exist
error: cannot find symbol class appcompat
UPDATE
This seems like a common problem. I've tried to follow most of the current questions on java incompatiblity but still haven't come up with a work around. I downloaded oracle's jdk (unnecessarily) and pointed the studio project at it. Created a shortcut using the jdk java.exe and placed it in Studio core, added java to the PATH which allowed gradlew build in the terminal to initiate but not complete. What are the next steps?
UPDATE
Just in case somebody else stumbles onto this. This post and also this one got me there.
The fix ended up being an import of the .R file. com.example.android.recyclerview.R Hope it can help
I'm getting the following error when I try to run my App on my SmartPhone:
Didn't find class "munyul.game.android02.android.AndroidLauncher" on path: DexPathList
Due to HD issues, I was forced into rebuilding my machine and setting up my developed environment again. After a lot of messing around, I have the following installed and working:
Java 1.8
Eclipse Neon
libGDX
Android SDK Manager
The Android App in question was almost finished, but now that goal seems like a long way off :(
I used libGDX to create a new project, and then I copied the old code into the new project - this is where things got messy.
I had to fix several errors caused by changes in libGDX, which was easy. I then also had to fix several errors caused by changes to Google Services, this was not easy! I eventually read about the new m2repository folder, then I searched for and found the class files needed (play-services-ads, -base, -basement, -games and -plus, inside .aar files), placed all the classes.jar files into their own directory within the android/libs project folder, finally adding references to them from within Eclipse - now everything compiles and looks good (should these .jar files be checked for export? - see edit)
Finally, I had to make one more change; the old project/code was created with a package: munyul.game.android02.android, but the new only had munyul.game.android02, I added the missing package to the new and also updated the AndroidManifest.xml file (maybe this is what went wrong!?).
I've checked the code and manifest and everything looks correct, but when I run the App it instantly crashes with the above mentioned error.
Also, I've checked the Order and Exports for the android project, the boxes that should be checked are.
Anyone know what else I could try?
EDIT:
As a test, I checked the Google Services JAR's for Export, and now I'm getting a different error:
Could not find class 'android.support.v4.util.ArrayMap', referenced from method
com.google.android.gms.common.api.GoogleApiClient$Builder.<init>
I'm starting to think that my error lies with how I resolved my Google Services issues - is there a better way of linking the missing classes? Somehow adding them via Gradle?
EDIT #2:
I migrated the entire project to Android Studio - now the APK installs and runs correctly on all my devices.
Honestly, I would have prefered to stick with Eclipse, but it seems like that is no longer an option - HTH
Check your AndroidManifest.xml for the correct application class (or none if you are not overriding.) The AndroidLauncher is part of the "instant run" feature available in Android Studio and is automatically injected by gradle into the manifest file.
Eclipse is no longer a supported development toolchain - you'll want to do your migration to Android Studio (or IntelliJ) sooner rather than later.
Brand new install of the Android SDK, and Android Studio. Brand new project, literally no changes to any file in the project. Working AVD, running 4.4.3 (or something similar). I get the following error:
Gradle 'Gigviz' project refresh failed.
Error:Could not find meta-data resource 'META-INF/services/javax.xml.datatype.DatatypeFactory' for service 'javax.xml.datatype.DatatypeFactory'.
The best reason I can think of for this error is that I'm missing some component of the javax.xml.datatype.DatatypeFactory dependency. Has anyone encountered this error before?
I'm on OS X Yosemite, latest version of Android Studio.
Download this : http://www.java2s.com/Code/Jar/j/Downloadjavaxxml134jar.htm
Put it inside your JDK folder, in your program files. Something like this :
C:\Program Files\Java\jdk1.8.0_31\lib\missioncontrol\plugins
And see what happens.
Found this on Gradle's forums, same error cause by a duplicate set of jars, inside the JDK's lib/endorsed folder. Usually when I get any build errors with META-INF in them, it is because a duplicate files somewhere. Also make sure you are using Java 1.7 or lower.
First of all, I realise that similar questions have been posted a lot here. But I've been through all of the answers I can find to similar problems, and nothing has worked yet, so was wondering if someone could help me.
I'm trying to develop a simple chat app with an Android client and a server app sitting running on my laptop. This includes a regular Java "common" project that holds the class that is used to pass messages via the socket.
First I tried to reference the "common" project in the Android project, but after a bit of reading abandoned that idea.
Now I have exported the jar file for the common project, and imported it into my Android project by copying it into the "libs" folder, and then selecting Build Path > Add To Build Path. I have also gone to Properties > Java Build Path > Order and Export and checked the library and moved it to the top of the order.
I have also moved the "gen" project above the "src" one in that build order.
Android Private Libraries is also checked. Everything is checked.
When I debug as an Android Application to my Samsung S3, I see a "Could not find class error" in logcat when advancing to the Activity that contains a reference to a class in the "common" project. Stepping through to the point where a class in the "common" project is referenced then causes a ClassNotFoundException to be thrown.
If I try to put the name of the library in the Android Manifest, like:
<uses-library android:name="com.johndarv.chatproj.common" />
I get:
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Please check logcat output for more details.
Launch canceled!
Upon trying to install.
I have the following versions:
Eclipse Standard SDK 2.0.0
Android SDK 22.3
Android project is compiled with Android 4.2.2.
Any help would be much appreciated! If I can give any more info that would be useful, please ask!
The uses-library tag means that your app expects the library to be available on the system. This is to prevent installation on devices which do not have some expected third-party software installed. Consider phone manufacturer who ships his devices with some specific api.
So this is not your case. Forget about this tag this time.
And as to your problem. The jar is not exported into the apk.
Ensure in Project Settings > Java Build Path > Order and Export that the library jar is checked to be exported.
If you put a jar into /libs dir of android project it is automatically added to the build path. You do not need to do this manually (as you did). Then you can see it (this jar) under Android Libraries entry in under Project Settings > Java Build Path > Libraries. This entry is also checked as exported (by default in android project) in Order and Export tab.
Maybe your problm occurs due to the fact that the jar is actually exported twice (once manually and once as private library). Just remove manually added entry from build path. You will have it added once - but to be honest I do not expect this caused the problem. But for sure the problem is in your project settings. Maybe paste a screenshot with Java Build Path > Order and Export and Java Build Path > Libraries.
I managed to solve this by deleting the common project and then creating a new Java project with "Use execution environment" set to Java SE 1.6. And rewriting (copy-pasting) the old classes.
There must have been something wrong with my previous project, and looks like it was the Java version used to compile. I had tried to set the compliance version to 1.6 on the old project. In any case, creating a whole new 1.6 project, pasting the classes in, re-exporting, and copying into my Android project did the trick.
Thanks to everyone who tried to answer this for your help. Hope someone finds the above useful one day!
New to android dev world and am just getting started here, well trying to anyway. I've downloaded Cordova (2.8, might need to upgrade this), Java JDK (1.7), and the new Android Studio, the Andriod SDK, installed all the 4.x packages with that, and installed ant (1.9.2).
Everything seems to be working as far as that goes. Problem is when I can create a Cordova project, from the command line, load it up in Studio using the import feature, not tweaking anything, just accepting (as I read to do so on some blog out there) and everything seems to load ok and the project is there in Studio, until I try to make it. At this point, I get and error "java: package org.apache.cordova does not exist" This is followed by several other errors, which I feel may be related. I'm not nor am I trying to do anything fancy here, just get the stock up and running.
Anybody know what I'm missing? Do I need to copy a file somewhere or compile something extra? Or am I using the wrong version of something?
Thanks!
I found after hours of searching and trial and error (although mostly errors) I came to find that it was all due to missing the cordova-*.jar file. which needed to be built using the ant jar in the framework folder of my android cordova directory. This step had been majorly left out of a ton of documentation. Once built, I simply copied this into the 'libs' folder of my project and everything loaded up and ran, although I did get a warning about depreciated project from the compiler, creating an ant build and selecting 'external compiler' fixed this warning.
Android Studio uses Gradle project layout. This means main java files should be in /src/main/java. If Cordova generates different structure (it looks like it is old Ant structure) you need to add its source folders to build.gradle
android {
...
sourceSets {
main {
java {
include 'some/wanted/package/**'
include 'another/wanted/package/**'
exclude 'some/unwanted/package/**'
}
}
}
}
Here is where the file sits: