Examples with Camera not working on Android

I followed Android Studio set up guide on github for OSX 10.9.4 to download Android Studio 1.1.0 and the NDK. I imported the Android project from settings.gradle. I was able to successfully run the EmptyExample.I also successfully ran the TouchExample by copying the build.gradle from the EmptyExample into the TouchExample folder and I modified the include line in settings.gradle to be:include ‘examples:android:androidTouchExample’

I received error messages when trying the same process with ImageExample, OpenCVExample and CameraExample.

When running the ImageExample on my phone (Droid 2, running Android 2.3.4) I received this error message.

When running the OpenCVExample on a Galaxy S4 running Android 4.4.2 I received this error message.

When running the OpenCVExample on my phone (Droid 2, running Android 2.3.4) I received this error message.

It looks like there is related discussion in an issue on github, specifically about ofVideoGrabber failing in the current version of master in the repository.

I did a little follow up checking after we hit those errors. I tested out the S4 on my setup (PC, running off a version of the master branch updated circa early march), and I was able to get AndroidCameraExample working. When I updated my local master, the example broke. So I’d say that a good temporary fix would be to revert your local openFrameworks repository to an older version that works.

To do that: close android studio, open up your terminal, cd into your openFrameworks directory and type git checkout 0babb8697cfaa0d96726faed4d06a2ba7f88eaf5. After that, you can open up android studio, resync the gradle files and then build your example. This will allow you to temporarily jump back to an older version of master - one step behind the one that @halfdanj thinks is causing the error.

1 Like

@SDK - wait scratch that, do git checkout 2b202d56ecfb9923e2a81591dbb85351113676ed instead. I tried rolling back to a few different points in the history of the repository, and there were weird hangups with gradle building. It would get stuck while compiling things like ofMesh. This is the first one I tried that worked for me.

I got this response:
Administrators-MacBook-Pro:~/Desktop/openFrameworks] pieterdekoninck% git checkout 2b202d56ecfb9923e2a81591dbb85351113676ed
M libs/openFrameworksCompiled/project/android/build.gradle
M libs/openFrameworksCompiled/project/android/settings.gradle
Note: checking out ‘2b202d56ecfb9923e2a81591dbb85351113676ed’.

You are in ‘detached HEAD’ state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b new_branch_name

HEAD is now at 2b202d5… tess2 emscripten: remove extra library
[Administrators-MacBook-Pro:~/Desktop/openFrameworks] pieterdekoninck%

Is this good?

Yep, now try opening up android studio again and see if you can sync the gradle files and build one of the examples.

I am getting the same error messages for CameraExample, OpenCVExample and ImageExample.

I’m having issues with running any of the examples that use the camera as well. Not too sure if this is still an ongoing issue. I’ve got my set up with Android Studio. I get this error message when using the androidOpenCVFaceExample and similar ones with the other examples that use the camera.

Any suggestions?