Hrm... I've somehow messed the native activity build up for one of my projects.
Frustratingly I had it all working a few days ago, and now I've broken it somehow.
I've lifted the native activity config virtually exactly to try to debug this, but it's still not working.
Even if someone just has some advice on how to debug the problem I'd appreciate it.
This behavior is identical on the debugger and on a nexus s. :/
I/ActivityManager( 105): Start proc com.example.native_activity for activity com.example.native_activity/android.app.NativeActivity: pid=2112 uid=10099 gids={}
W/NativeActivity( 2112): ANativeActivity_onCreate not found
D/AndroidRuntime( 2112): Shutting down VM
W/dalvikvm( 2112): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime( 2112): FATAL EXCEPTION: main
E/AndroidRuntime( 2112): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.native_activity/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/data/com.example.native_activity/lib/libnative-activity.so
E/AndroidRuntime( 2112): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
E/AndroidRuntime( 2112): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 2112): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 2112): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 2112): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2112): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 2112): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 2112): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2112): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 2112): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 2112): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 2112): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2112): Caused by: java.lang.IllegalArgumentException: Unable to load native library: /data/data/com.example.native_activity/lib/libnative-activity.so
E/AndroidRuntime( 2112): at android.app.NativeActivity.onCreate(NativeActivity.java:199)
E/AndroidRuntime( 2112): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 2112): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
E/AndroidRuntime( 2112): ... 11 more
W/ActivityManager( 105): Force finishing activity com.example.native_activity/android.app.NativeActivity
V/RenderScript_jni( 187): surfaceDestroyed
W/ActivityManager( 105): Activity pause time
doug@Wulf:~/projects/Natives/libcommon-android/jni/tests/na/common$ cat AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
package="com.example.native_activity"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:label="@string/app_name" android:hasCode="false">
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.lib_name"
android:value="native-activity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
doug@Wulf:~/projects/Natives/libcommon-android/jni/tests/na/common$ cat default.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-7
doug@Wulf:~/projects/Natives/libcommon-android/jni/tests/na/common$ cat jni/Android.mk
# Root path for building.
ROOT_PATH := $(call my-dir)
# Externals
LOCAL_PATH := $(ROOT_PATH)
include $(call all-subdir-makefiles)
# Application
include $(CLEAR_VARS)
LOCAL_PATH := $(ROOT_PATH)
LOCAL_MODULE := native-activity
LOCAL_SRC_FILES := common.c android.c
LOCAL_CFLAGS := -std=c99
LOCAL_C_INCLUDES := \
$(NDK_MODULE_PATH)/libcommon-android/jni/include
LOCAL_LDLIBS := \
-llog \
-landroid \
-lEGL \
-lGLESv1_CM \
-lz
LOCAL_STATIC_LIBRARIES := android_native_app_glue na zip png
include $(BUILD_SHARED_LIBRARY)
$(call import-module,libcommon-android/jni)
$(call import-module,android/native_app_glue)
doug@Wulf:~/projects/Natives/libcommon-android/jni/tests/na/common$ cat jni/Application.mk
APP_PLATFORM := android-9
doug@Wulf:~/projects/Natives/libcommon-android/jni/tests/na/common$ ~/projects/android-ndk/ndk-build NDK_LOG=1 NDK_DEBUG=1
Android NDK: NDK installation path auto-detected: '/home/doug/projects/android-ndk'
Android NDK: GNU Make version 3.81 detected
Android NDK: Host OS was auto-detected: linux
Android NDK: Host CPU was auto-detected: x86
Android NDK: HOST_TAG set to linux-x86
Android NDK: Host awk tool was auto-detected: awk
Android NDK: Host awk test returned: Pass
Android NDK: This NDK supports the following toolchains and target ABIs:
Android NDK: arm-eabi-4.4.0: armeabi armeabi-v7a
Android NDK: arm-linux-androideabi-4.4.3: armeabi armeabi-v7a
Android NDK: x86-4.4.3: x86
Android NDK: Found platform root directory: /home/doug/projects/android-ndk/platforms
Android NDK: Found supported platforms: android-3 android-4 android-5 android-8 android-9
Android NDK: PLATFORM android-3 supports: arm
Android NDK: ABI arm sysroot is: /home/doug/projects/android-ndk/platforms/android-3/arch-arm
Android NDK: PLATFORM android-4 supports: arm
Android NDK: ABI arm sysroot is: /home/doug/projects/android-ndk/platforms/android-4/arch-arm
Android NDK: PLATFORM android-5 supports: arm
Android NDK: ABI arm sysroot is: /home/doug/projects/android-ndk/platforms/android-5/arch-arm
Android NDK: PLATFORM android-8 supports: arm
Android NDK: ABI arm sysroot is: /home/doug/projects/android-ndk/platforms/android-8/arch-arm
Android NDK: PLATFORM android-9 supports: arm
Android NDK: ABI arm sysroot is: /home/doug/projects/android-ndk/platforms/android-9/arch-arm
Android NDK: Found stable platform levels: 3 4 5 8 9
Android NDK: Found max platform level: 9
Android NDK: Looking for AndroidManifest.xml in /home/doug/projects/Natives/libcommon-android/jni/tests/na/common
Android NDK: Found it !
Android NDK: Found project path: /home/doug/projects/Natives/libcommon-android/jni/tests/na/common
Android NDK: Parsing /home/doug/projects/Natives/libcommon-android/jni/tests/na/common/jni/Application.mk
Android NDK: Defaulted to APP_BUILD_SCRIPT=/home/doug/projects/Natives/libcommon-android/jni/tests/na/common/jni/Android.mk
Android NDK: Application 'local' forced debuggable through NDK_DEBUG
Android NDK: Selecting debug optimization mode (app is debuggable)
Android NDK: Adding import directory: /home/doug/projects/Natives
Android NDK: Adding import directory: /home/doug/projects/android-ndk/sources
Android NDK: Building application 'local' for ABI 'armeabi'
Android NDK: Using target toolchain 'arm-linux-androideabi-4.4.3' for 'armeabi' ABI
Android NDK: Looking for imported module with tag 'cxx-stl/system'
Android NDK: Probing /home/doug/projects/Natives/cxx-stl/system/Android.mk
Android NDK: Probing /home/doug/projects/android-ndk/sources/cxx-stl/system/Android.mk
Android NDK: Found in /home/doug/projects/android-ndk/sources/cxx-stl/system
Android NDK: Looking for imported module with tag 'libcommon-android/jni'
Android NDK: Probing /home/doug/projects/Natives/libcommon-android/jni/Android.mk
Android NDK: Found in /home/doug/projects/Natives/libcommon-android/jni
Android NDK: Looking for imported module with tag 'android/native_app_glue'
Android NDK: Probing /home/doug/projects/Natives/android/native_app_glue/Android.mk
Android NDK: Probing /home/doug/projects/android-ndk/sources/android/native_app_glue/Android.mk
Android NDK: Found in /home/doug/projects/android-ndk/sources/android/native_app_glue
Android NDK: Looking for imported module with tag 'libzip-android/jni'
Android NDK: Probing /home/doug/projects/Natives/libzip-android/jni/Android.mk
Android NDK: Found in /home/doug/projects/Natives/libzip-android/jni
Android NDK: Looking for imported module with tag 'libpng-android/jni'
Android NDK: Probing /home/doug/projects/Natives/libpng-android/jni/Android.mk
Android NDK: Found in /home/doug/projects/Natives/libpng-android/jni
Android NDK: Skipping duplicate import for module with tag 'android/native_app_glue'
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile thumb : native-activity <= common.c
Compile thumb : native-activity <= android.c
Compile thumb : na <= common.c
Compile thumb : na <= profile.c
Compile thumb : na <= profile.c
Compile thumb : na <= mock.c
Compile thumb : na <= assets.c
Compile thumb : na <= assets.c
Compile thumb : na <= mock.c
Compile thumb : na <= state.c
Compile thumb : na <= state.c
Compile thumb : na <= mock.c
Compile thumb : na <= events.c
Compile thumb : na <= mock.c
Compile thumb : na <= events.c
Compile thumb : na <= gfx.c
Compile thumb : na <= mock.c
Compile thumb : na <= gfx.c
Compile thumb : na <= texture.c
Compile thumb : na <= texture.c
Compile thumb : na <= mock.c
Compile thumb : na <= api.c
Compile thumb : na <= api.c
Compile thumb : na <= android.c
Compile thumb : na <= state.c
Compile thumb : na <= android.c
Compile thumb : na <= android.c
Compile thumb : na <= gfx.c
Compile thumb : na <= android.c
In file included from /home/doug/projects/Natives/libcommon-android/jni/impl/na/events.android/android.h:21,
from /home/doug/projects/Natives/libcommon-android/jni/impl/na/events.android/android.c:17:
/home/doug/projects/android-ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h:98: warning: declaration does not declare anything
/home/doug/projects/android-ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h:103: warning: declaration does not declare anything
/home/doug/projects/android-ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h:104: warning: declaration does not declare anything
/home/doug/projects/android-ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h:125: warning: declaration does not declare anything
Compile thumb : na <= events.c
In file included from /home/doug/projects/Natives/libcommon-android/jni/impl/na/events.android/android.h:21,
from /home/doug/projects/Natives/libcommon-android/jni/impl/na/events.android/events.c:18:
/home/doug/projects/android-ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h:98: warning: declaration does not declare anything
/home/doug/projects/android-ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h:103: warning: declaration does not declare anything
/home/doug/projects/android-ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h:104: warning: declaration does not declare anything
/home/doug/projects/android-ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h:125: warning: declaration does not declare anything
Compile thumb : na <= profile.c
Compile thumb : na <= common.c
Compile thumb : na <= assets.c
Compile thumb : na <= common.c
Compile thumb : na <= assets.c
Compile thumb : na <= android.c
Compile thumb : na <= texture.c
Compile thumb : na <= common.c
Compile thumb : na <= json.c
Compile thumb : na <= json.c
Compile thumb : na <= mock.c
StaticLibrary : libna.a
SharedLibrary : libnative-activity.so
Install : libnative-activity.so => libs/armeabi/libnative-activity.so