Hello,
I know that some other people here are developing Android JNI apps.
For me it has worked perfectly so far, but as we just got a Galaxy S4 in the office I thought of testing my app there and boom =( It crashes at the startup:
I/True Democracy( 8624): Trying to load libtruedemocracy.so D/dalvikvm( 8624): Trying to load lib
/data/app-lib/com.felipe.truedemocracy-1/libtruedemocracy.so 0x421fadc8
W/libc ( 8624): WARNING: generic atexit() called from legacy shared library D/dalvikvm( 8624): Added shared lib
/data/app-lib/com.felipe.truedemocracy-1/libtruedemocracy.so 0x421fadc8
I/truedemocracy( 8624): JNI_OnLoad called
I/truedemocracy( 8624): Reading our Activity Class E/dalvikvm( 8624): ERROR: couldn't find native method E/dalvikvm( 8624): Requested:
Lcom/felipe/truedemocracy/TrueDemocracy;.GetHistoricalInflationCount:()I F/truedemocracy( 8624): javaEnvRef^.RegisterNatives failed I/truedemocracy( 8624): JNI_OnLoad finished
D/qdmemalloc( 217): ion: unmap_buffer base:0x0 size:8355840 offset:0 fd:49 D/qdmemalloc( 217): ion: unmap_buffer base:0x0 size:4096 offset:0 fd:78 D/qdmemalloc( 217): ion: unmap_buffer base:0x0 size:8355840 offset:0 fd:66 D/qdmemalloc( 217): ion: unmap_buffer base:0x0 size:4096 offset:0 fd:67 W/dalvikvm( 8624): No implementation found for native Lcom/felipe/truedemocracy/TrueDemocracy;.Translations_TranslateToISO639_2_Code:(Ljava/lang/String;Ljava/lang/String;)V D/AndroidRuntime( 8624): Shutting down VM
W/dalvikvm( 8624): threadid=1: thread exiting with uncaught exception (group=0x410b8ac8)
D/Sensorhubs( 228): readContextData: 1, 1, 14, 1
D/SensorHubManager( 724): onGetSensorHubDataLocked: library = 1, 1, 14, 1 D/CAE ( 724): onGetSensorHubData(SensorHubParserProvider.java:66)
- onGetSensorHubData Event [event buffer len :4]
I/CAE ( 724): parse(SensorHubParserProvider.java:129) - buffer size = 4 I/CAE ( 724): parse(SensorHubParserProvider.java:140) - 1, 1, 14, 1, D/qdoverlay( 217): Unset pipe=VG0 dpy=0; Unset pipe=VG1 dpy=0; Unset pipe=RGB1 dpy=0;
D/CAE ( 724): display(ContextProvider.java:430) - ================= FLIP_COVER_ACTION ================= V/WindowManager( 724): Window{42b3a138 u0
Keyguard}mOrientationRequetedFromKeyguard=false
E/AndroidRuntime( 8624): FATAL EXCEPTION: main
E/AndroidRuntime( 8624): java.lang.UnsatisfiedLinkError: Native method not found: com.felipe.truedemocracy.TrueDemocracy.Translations_TranslateToISO639_2_Code:(Ljava/lang/String;Ljava/lang/String;)V E/AndroidRuntime( 8624): at
com.felipe.truedemocracy.TrueDemocracy.Translations_TranslateToISO639_2_Code(Native Method)
E/AndroidRuntime( 8624): at
com.felipe.truedemocracy.TrueDemocracy.onCreate(TrueDemocracy.java:632) E/AndroidRuntime( 8624): at
android.app.Activity.performCreate(Activity.java:5250) E/AndroidRuntime( 8624): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) E/AndroidRuntime( 8624): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210) E/AndroidRuntime( 8624): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296) E/AndroidRuntime( 8624): at
android.app.ActivityThread.access$700(ActivityThread.java:151) E/AndroidRuntime( 8624): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281) E/AndroidRuntime( 8624): at
android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 8624): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 8624): at
android.app.ActivityThread.main(ActivityThread.java:5293) E/AndroidRuntime( 8624): at
java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 8624): at
java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 8624): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) E/AndroidRuntime( 8624): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) E/AndroidRuntime( 8624): at dalvik.system.NativeStart.main(Native Method)
Any ideas?
I am not doing anything unusual, and exact same APK works fine in HTC Wildfire, Xperia Mini, Galaxy Nexus, etc, etc.
=(
it runs JNI_onCreate to the end, so at least code is being executed.
The routine that it complains about is declared correctly:
procedure Java_com_felipe_truedemocracy_TrueDemocracy_Translations_TranslateToISO639_2_Code(
env:PJNIEnv; this:jobject; AISOCode, ACountry: jstring); cdecl;And is correct in the structure:
(name:'Translations_TranslateToISO639_2_Code';
signature:'(Ljava/lang/String;Ljava/lang/String;)V';
;),And is correct in RegisterNative:
// Register Pascal exported calls
if javaEnvRef^^.RegisterNatives(javaEnvRef, javaActivityClass,
@NativeMethods[0],length(NativeMethods))<0 then
begin
__android_log_write(ANDROID_LOG_FATAL, 'truedemocracy',
'javaEnvRef^.RegisterNatives failed');
end;My only idea at the moment is to do the static export too... maybe that will work, lets see.
