Open vinjn opened 11 years ago
compile-instal.bat
call ndk-build
call ant debug
call adb install -r bin\NativeActivity-debug.apk
android-ndk-r7b\samples\native-activity-diy\jni\main.c patch
#if 0
context = eglCreateContext(display, config, NULL, NULL);
#else
EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribs);
#endif
The following steps take /ndk/samples/native-activity as the example
install adt
( android-dev-tool, which contains sdk && eclipse) important sdk tools:
install ndk
important ndk tools:
install jdk
set JAVA_HOME = c:\Program Files\Java\jdk1.7.0_25\
generate buid.xml
$ android update project -p "/project/full/path"
you can simply enter to the path of your project using cd then you use
$ android update project -p .
Sucess
Updated and renamed default.properties to project.properties Updated local.properties No project name specified, using Activity name 'NativeActivity'. If you wish to change it, edit the first line of build.xml. Added file
C:\android-ndk-r8e\samples\native-activity\build.xml
Added fileC:\android-ndk-r8e\samples\native-activity\proguard-project.txt
Error
Error: The project either has no target set or the target is invalid. Please provide a
-t
or--target
to theandroid.bat update
command.$ android list targets
to find supported targets$ android update project -p . -t android-10
to explicitly specify the target idA proper output would be:
We can change the content of
default.properties
file.build jni so
$ ndk-build
build apk
$ ant clean debug
# clean to make sure .so file is replaced$ adb install -r bin/NativeActivity-debug.apk
# -r means forcefully installrun apk from adb
adb shell commands is
am start -n your.package.name/your.activity.name
$ adb shell am start -n com.example.native_activity/android.app.NativeActivity
error
changed to
create an empty src/ folder and try
ant debug
again