Getting started with android - Fatal Exception in GL thread

Howdy all,

Long time first time… o wait, thats only with radio huh.

Anyways I’ve been kinda banging my head against the wall the past couple of days trying to get oF setup with Android. I’ve done it before with relatively little trouble but this time has been a major pain in the ass!

It’s seriously been one thing after another. At first I couldn’t get it built, then realized I wasn’t using the right NDK version. Despite fixing that issue and being able to build apps, I couldn’t get anything to draw correctly. Simple ellipses were turning into parallelograms lol.

It’s been a tough couple of days but I think I’m close. Currently running develop branch of oF, everything builds correctly, theres just one last linking error I can’t quite figure out.

Logcat message

  
  
12-25 07:11:47.812: E/AndroidRuntime(2538): FATAL EXCEPTION: GLThread 180  
12-25 07:11:47.812: E/AndroidRuntime(2538): java.lang.UnsatisfiedLinkError: Native method not found: cc.openframeworks.OFAndroid.init:()V  
12-25 07:11:47.812: E/AndroidRuntime(2538): 	at cc.openframeworks.OFAndroid.init(Native Method)  
12-25 07:11:47.812: E/AndroidRuntime(2538): 	at cc.openframeworks.OFAndroidWindow.onSurfaceChanged(OFAndroid.java:1079)  
12-25 07:11:47.812: E/AndroidRuntime(2538): 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)  
12-25 07:11:47.812: E/AndroidRuntime(2538): 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)  
  
  

Best I can figure out is that somehow the main.cpp under the src folder of, in my case “androidEmptyExample” is being ignored for some reason.

Just for shits and giggles I’m gonna try “android project update” in a second, but I get the feeling that’s not gonna work.

On a possibly related note, I’ve noticed that the instructions for setting up a external run configuration seems to need updating? Everytime I try to run it using that configuration I get this in the console

  
grep: repetition-operator operand invalid  
find: illegal option -- m  
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]  
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]  
cd ../../../addons/ofxAndroid/ofAndroidLib; \  
	echo installing on darwin-x86; \  
	if [ "darwin-x86" = "windows" ]; then \  
	cmd //c /Users/kindofsleepy/android-sdk/tools/android.bat update project --target android-17 --path .; \  
	else \  
	/Users/kindofsleepy/android-sdk/tools/android update project --target android-17 --path .; \  
	fi   
installing on darwin-x86  
Updated project.properties  
Updated local.properties  
Updated file ./proguard-project.txt  
It seems that there are sub-projects. If you want to update them  
please use the --subprojects parameter.  
cd /Users/kindofsleepy/Documents/openFrameworks/apps/myapps/androidEmptyExample; \  
	if [ -d "bin/data" ]; then \  
		mkdir -p res/raw; \  
		rm res/raw/androidemptyexampleresources.zip; \  
		cd bin/data; \  
		zip -r ../../res/raw/androidemptyexampleresources.zip *; \  
		cd ../..; \  
	fi   
if [ -f obj/ ]; then rm obj/; fi  
#touch AndroidManifest.xml  
if [ "darwin-x86" = "windows" ]; then \  
	cmd //c /Users/kindofsleepy/android-sdk/tools/android.bat update project --target android-17 --path .; \  
	else \  
	/Users/kindofsleepy/android-sdk/tools/android update project --target android-17 --path .; \  
	fi  
Updated project.properties  
Updated local.properties  
Updated file ./proguard-project.txt  
It seems that there are sub-projects. If you want to update them  
please use the --subprojects parameter.  
#rm -r bin/AndroidManifest.xml bin/R.txt bin/androidEmptyExample.apk bin/classes bin/classes.dex bin/dexedLibs bin/jarlist.cache bin/res bin/resources.ap_  
if [ "darwin-x86" = "windows" ]; then \  
	#/usr/bin//ant clean; \  
	/usr/bin//ant debug install; \  
	else \  
	#ant clean; \  
	ant debug install; \  
	fi  
/bin/sh: -c: line 1: syntax error: unexpected end of file  
make: *** [AndroidInstall] Error 2  
  

Any help is appreciated. Thank you!

we are changing the build system for android so it’s more integrated with eclipse, if you are using develop there’s no need to use the install target anymore, just press the run (play) button in eclipse and it should install your application. the latest version also supports the latest ndk.

there’s a problem with projects with resources in the data folder where you have to press run twice. its due to a bug in the eclipse plugin for android and it’s already fixed in their latest release from some days ago so you would want to update the eclipse plugin, the sdk and then ndk to the latest release

Whoa. Thanks for the quick response Arturo! And Merry Christmas!

I have re-downloaded eclipse, latest ADT plugin for eclipse, latest android sdk and ndk r8d and gone through the same steps only to be met with the same “Native method not found” error :frowning:

Anything else I should try?

take a look at the main.cpp file i think the one you have is the desktop version not the android one which should have the init function called from java, check the empty example:

  
  
#include "ofMain.h"  
#include "testApp.h"  
#ifdef TARGET_ANDROID  
	#include "ofAppAndroidWindow.h"  
#else  
	#include "ofAppGlutWindow.h"  
#endif  
  
  
  
int main(){  
  
#ifdef TARGET_ANDROID  
	ofAppAndroidWindow *window = new ofAppAndroidWindow;  
#else  
	ofAppGlutWindow *window = new ofAppGlutWindow;  
#endif  
	ofSetupOpenGL(window, 1024,768, OF_WINDOW);			// <-------- setup the GL context  
  
	// this kicks off the running of my app  
	// can be OF_WINDOW or OF_FULLSCREEN  
	// pass in width and height too:  
	ofRunApp( new testApp() );  
	return 0;  
}  
  
  
#ifdef TARGET_ANDROID  
#include <jni.h>  
  
//========================================================================  
extern "C"{  
	void Java_cc_openframeworks_OFAndroid_init( JNIEnv*  env, jobject  thiz ){  
		main();  
	}  
}  
#endif  
  

Unfortunately I don’t think thats the reason. Trying to run “androidEmptyExample”, compared the main.cpp and it looks the same.

Hey Arturo.

My bash knowledge is admitingly not that great, but I’m not sure that the app’s src(with main.cpp,testApp.h,testApp.cpp) folder is being included when building. Just for the heck of it I deleted that entire folder and I’m still pulling up the same error

“Native method not found: cc.openframeworks.OFAndroid.init:()V”

Which makefile should I look into to see if thats the case?

don’t think it’s related to that, do the examples work?

Unfortunately not. Things build fine, but when the simulator and phone try to launch a example, I run into that error.