I'm trying to make a cross-platform project using C++ on Windows and the Android NDK. I've been trying to put it together in one project with multiple build configurations, but I'm running into a problem for the Android build.
My project directory structure is as follows:
PROJECT/
src <- This has the Android SDK files
jni <- This has the Android NDK files
src-mp <- Multiplatform C++ code
src-pc <- Windows-specific code
gen
res
...
When building for Android, the src-pc folder contains code that doesn't compile and generates errors (it's using GLFW and GLEW, which doesn't seem to be compatible with Android). I right-clicked on it and hit
"Resource Configurations -> Exclude from Build".
However, the errors in src-pc are still being reported and so Eclipse refuses to run the application. I know the application runs on Android without the src-pc folder.
I suspect it's something with the indexer, but I can't get it to ignore the files in the src-pc folder. I've considered setting up a separate dependent project for Windows, but I was hoping that there was a way to put it all in one project. I've looked at the resource filters functionality, but I don't see a way to set filters for specific build configurations, so that doesn't help.
I already found that it's possible to delete the problem reports in the Problems tab, but doing that every time I build is a nuisance and I was hoping for a better fix.
I'm using Android NDK R9D and the SDK tools for API level 19. I'm on Eclipse Kepler. The toolchain being used for C++ compilation is Cygwin GCC with the Android Builder.
Related
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.
I've created a simple library to get JSON responses and map it to Java Object.
I built a JAR using 'build with dependencies' in IntelliJ IDEA with JDK 1.8. However, this JAR works when used with other IntelliJ IDEA projects.
However when I add in Android Studio Project, I get this Error:com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
I found on Reddit that some user did the same (built JAR with IntelliJ Idea and Imported in Android Studio)
I think I am missing something or a way to create JAR file which is causing incompatibility to Android Studio. I'm pounding my head for hours with no luck.
For Android Studio, change File -> Project Structure -> SDK Location -> JDK Location to jdk1.7.x. For the command line, ensure java -version outputs java version "1.7.x".
Before Gradle was used with libgdx I could just open my Eclipse project in AIDE and everything worked fine. As of libgdx version 1.0 I now use Gradle in Eclipse but I don't know how to get this to work with AIDE.
It's not finding the jar libraries because I get compile errors about unknown libgdx classes.
Do I have to add a local Maven repository or is there another way?
Thanx!
I had similar issues, and what worked for me is I started a libgdx project within AIDE (yes it has that function), let it set itself up properly with all the libraries etc in the lib folder, then copied my code into the respective core, android etc folders as appropriate.
It's a bit fiddly, and I'm still not 100% there yet as I'm trying to work off two git branches, one for laptop (with gradle, your original project), and one for AIDE (with all the libraries already in it)
It should at least help you get your project working.
I'm little confused about project properties, Java Build Path, Order and Export when compiling an Android project.
Look at this:
Should I check Android 2.3.3, Android Dependencies and android.jar ?
when compiling my android project to be sure that everything will works fine on the destination device. My doubts arise because I get an error on some devices, please look at my previous question:
Exception java.lang.NoSuchMethodError on java.util.Deque.push
It's not related to your exporting. Your project references java.util.Deque which was only added in API level 9
(http://developer.android.com/reference/java/util/Deque.html)
Devices with API level < 9 will fail as they cannot call this Class/method as it doesn't exist on them.
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).