This is the full warning:
JNI WARNING: instance fieldID 0x571819bc not valid for class
Ljava/lang/Class; in
Lcom/brokenteapot/lwtemplate/JNI;.onCreate:(Landroid/content/res/AssetManager;)V
(GetIntField)
And the backtrace:
#00 pc 00045dd0 /system/lib/libdvm.so (dvmAbort+75)
#01 pc 00039819 /system/lib/libdvm.so
#02 pc 0003e96b /system/lib/libdvm.so
#03 pc 000089b9 /system/lib/libandroid.so (AAssetManager_fromJava+88)
#04 pc 00002f54 /data/data/com.brokenteapot.lwtemplate/lib/libLiveWallpaperTemplate.so (Java_com_brokenteapot_lwtemplate_JNI_onCreate+128)
Here is the code that’s causing it:
Java
public final class LiveWallpaperService extends WallpaperService
{
static AssetManager assetManager;
@Override
public void onCreate()
{
assetManager = getAssets();
JNI.onCreate(assetManager);
}
}
C++
void Java_com_brokenteapot_lwtemplate_JNI_onCreate(JNIEnv* env, jobject assetManager)
{
AAssetManager* pAssetManager = AAssetManager_fromJava(env, assetManager);
}
I really have no idea what that warnings means or why it’s crashing. I’m following the example from the NDK samples almost exactly. Is it because it’s a service that something is different?
Ugh, I figured it out, the method signature was wrong in the JNI function:
should have been
I don’t really understand why some JNI functions need the void* and some don’t…