Best way into OF + Android?

Hi all,

coming back to OF after some time away and looking forward to getting into Android dev for an upcoming gig. There seem to have been some changes recently so wondering what the best approach is:

  1. Downloading the latest release and setting up eclipse via website instructions.
  2. Downloading the latest release and setting up eclipse via github instructions.
  3. Cloning the master branch on git and setting up eclipse via github instructions.
  4. Cloning the master branch on git and setting up Android Studio via github instructions.

I have tried the last 2 approaches with little luck in the simulator so far. Android Studio seems to compile OF but the emptyExample then crashes in simulator. Then when trying to create new projects or run an example I get the error Plugin with id ‘com.android.application’ not found. No luck in eclipse yet bat am about to try a different version after realising the extra detail in the github instructions.

I will end up writing this app for iOS in xcode/AppCode and then porting. Will be a relatively simple app but will need camera, video through a shader and possibly accelerometer/GPS data. Would prefer to use Android Studio even though C++ support is still a ways off. Although Ideally would like to get both setups running.

Any advice hugely appreciated.
Cheers,
nay.

EDIT - I’m on OSX 10.10

With respect to Android Studio, is your local master up-to-date? For running the example, you are copying gradle.build from androidEmptyExample into another example & then updating gradle.settings?

I’ve just recently started diving into the android studio setup on windows, but I had to revert back to an older commit to get the examples running for me. I didn’t do an organized search to find the most recent commit that works, but I haphazardly checked out this one. I was able to get the examples running that I needed.

Thanks, can I ask what error you were getting before trying this? I just reset to that commit and reimported settings.gradle but no luck.

Eclipse has proven worse. Trying with the latest OF release and the recommended eclipse version on the github instructions it hangs when indexing. I have adjusted eclipse RAM and cache settings, which help but not enough. I am on a recent macbook pro retina so performance shouldn’t be an issue.

I am now in the process of deleting everything to try again from scratch!

Hmm, I haven’t gotten the com.android.application error before, but I helped someone on OSX who had it earlier today. Instead of opening up from libs/openFrameworksCompiled/project/android/, I think they tried to open up an example directly from the build.gradle file.

I feel like I’m swimming in errors. On the current version of master, ofVideoGrabber didn’t work (tested on multiple devices with various version of android). I can’t remember the specific error message. On some versions of master, I get stuck indefinitely compiling (usually on an openCV related class). Now I’m running into the issue that all of the examples work, but if I try to create my own app via copying the empty example, I hit a series of errors. E.g. if I try to re-create the sound player example, the app throws an error that it can’t find the sound file on the device.

Wish I could be more help but I’m in the same boat. Maybe I’ll trying going the scratch route too.

Thanks. Looking forward to Android Studio support but for this next project it looks like I might be better served sticking with eclipse. The only reference I can find to eclipse versions to use is for the old Juno/4.2 release, which I had no luck with. Might give the latest release a try.

Any luck with that? I tried switching to linux and following the eclipse installation instructions for the 0.8.4 release. I’m still stuck with examples that work but custom apps that crash.

Hey, you’re further than me. I had no luck with Eclipse 4.2/Juno on OSX 10.10 as the indexing didn’t work so installed 4.3/kepler. I would have tried a more recent version but that would have meant Java 1.7 where as the instructions refer to 1.6.

After adjusting eclipse’s RAM and cache settings this worked okay to import and index the project. Updating the required SDK for the imported projects as per instructions did not work. I had no luck editing the target variable as per the project.properties files so installed the older SDK. I am now able to compile examples although I have not set up a simulator to see anything yet! Will post back when I get further.

Nice, well that’s definitely progress.

I just managed to get a custom app up and running. I ended up using java 1.8.0_40 with eclipse 4.2 (32x). I installed the android API 19 to deal with the no valid target errors. I also had some errors about the NDK, so I had to set the location in eclipse preferences (despite the path being in paths.make). All of that involved liberal rebooting of eclipse which seemed to sometimes “fix” errors.

I did get a simulator up and have the emptyExample running but then after trying to compile another example I get nothing but INSTALL_FAILED_MEDIA_UNAVAILABLE errors.

hey sorry i need to update the guide, they deprecated ADT some months ago and it’s now a little outdated. Eclipse Luna, the latest one works the best from my experience. the indexer is kind of tricky to get right i’m trying to make a config that works but the easiest is to just disable it in window > preferences > c++

@nay the error you are getting might be releated to the simulator not having external storage. OF compresses all resources in a zip file to later uncompress them when the app is run the first time, this requires external storage (it’s called like that but in most devices is just some internal flash memory) i haven’t really tried to run apps in the simulator since it’s really slow so you’ll probably have more luck by using a real device

Thanks Arturo, I’ll give the latest eclipse a try hoping that the RAM and cache setting tweaks will be enough to hang onto indexing.

I actually don’t have an Android device yet but will give it a try when I do. However, would definitely be useful to have access to simulators even if slow when needing to test for device resolutions etc that you don’t have access to before a release.

Will Android Studio support be an official part of the 090 release? When is that release planned?

There is also this guide - I find that this set up is better in practice than others because a) compile time is reasonable b) code completion features work for c++ in the ide

I tried it and out worked out well. I used Eclipse Luna.

1 Like