I have a (possibly overly) ambitious goal of writing an N64 emulator to sell on the Android market. I have a great deal of current experience programming in Java, and past experience in C++ (I'm a bit rusty, but its like riding a bike ... I hope ). I have a little bit of experience writing for the Android with the Android SDK and ADT plug-in for Eclipse ... I've written 3 simple starter apps, my most recent being an animated-texture cube app.
Anyway, my next step is to learn how to compile native C++ code, access it in the Java portion, debug it, etc. I've installed and set up the NDK and Sequoyah in Eclipse, and I'm trying to write a basic "Hello World" app that generates a string in native code and displays it in a basic TextView. The project seems to be set up correctly, it has generated the jni folder with a .cpp and a .mk file inside. I edited the HelloAndroid.cpp File as follows:
Then I edited the HelloAndroid.java File as follows:
The project compiles fine, but it fails to run in the AVD, generating the message "Sorry! The application Hello, Android (process paulscode.android.helloandroid) has stopped unexpectedly. Please try again."
Is there anything obviously wrong with my code, or are there some Eclipse or AVD settings that I need to check? Let me know if you require any further information about this Hello Android project to help me solve the problem.
Anyway, my next step is to learn how to compile native C++ code, access it in the Java portion, debug it, etc. I've installed and set up the NDK and Sequoyah in Eclipse, and I'm trying to write a basic "Hello World" app that generates a string in native code and displays it in a basic TextView. The project seems to be set up correctly, it has generated the jni folder with a .cpp and a .mk file inside. I edited the HelloAndroid.cpp File as follows:
Code:
#include <string.h>
#include <jni.h>
extern "C"
{
jstring Java_paulscode_android_helloandroid_HelloAndroid_sayHi( JNIEnv* env, jobject obj )
{
return env->NewStringUTF( "Howdy, this is JNI!" );
}
}
Code:
package paulscode.android.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity
{
@Override
public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
TextView tv = new TextView( this );
tv.setText( sayHi() );
setContentView( tv );
}
public native String sayHi();
}
Is there anything obviously wrong with my code, or are there some Eclipse or AVD settings that I need to check? Let me know if you require any further information about this Hello Android project to help me solve the problem.