0

PS: Actually, this is working, I have another problem that I'll update this question soon.

I has the following native code:

JNIEXPORT void JNICALL Java_com_rmsdk_wrapper_RMServices_init(JNIEnv *env, jobject thiso,
        jstring prodName, jstring version) {

    jclass thisClass = env->GetObjectClass(thiso);

    __android_log_print(ANDROID_LOG_DEBUG, "APP", "[findMethodId]");        
    jmethodID getDeviceName = env->GetMethodID(thisClass, "getDeviceName", "()Ljava/lang/String;");

    __android_log_print(ANDROID_LOG_DEBUG, "APP", "[invoke]");      
    jstring dvcName = (jstring) env->CallObjectMethod(thiso, getDeviceName);

    __android_log_print(ANDROID_LOG_DEBUG, "APP", "[strings retrivied]");

And the respective method at a Java class

public String getDeviceName() {
    String deviceName = Build.MODEL;
    LogU.v("APPServices", "getDeviceName("+deviceName+")");
    return deviceName;
}

But when running the following happens:

D/RMSDK:DRM(3717): [findMethodId]
D/RMSDK:DRM(3717): [invoke]
I/DEBUG(27674): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG(27674): Build fingerprint: 'MOTO/PORTLA/wifi_hubble:3.2/H.6.6-27/1317781165:user/ota-rel-keys,release-keys'
I/DEBUG(27674): pid: 3717, tid: 3717  >>> br.com.abril.iba <<<
I/DEBUG(27674): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
I/DEBUG(27674):  r0 00000000  r1 40c33038  r2 5651b1ec  r3 be86444c
I/DEBUG(27674):  r4 0000008c  r5 8282a018  r6 82805e28  r7 826f0a68

The method are being found, but they crash when invoking it (any method does), how can I fix that? I'm not sure why it's not working.

PS: Same error happens with Android NDK5 & NDK7B

1
  • 1
    Are you sure thiso is not NULL? And thisClass is not NULL? And getDeviceName is not NULL? Feb 29, 2012 at 3:01

1 Answer 1

0

Your code runs fine on my HTC Desire Z, I compiled the native part using android-ndk-r7b. Are you sure you have method getDeviceName() in the same class where you execute init(String s1, String s2);? I used the following java code:

public class HelloJni extends Activity {

public native void init(String s1, String s2);



@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    init("","");
}

static {
    System.loadLibrary("hello-jni");
}

public String getDeviceName() {
    String deviceName = Build.MODEL;
    Log.v("APPServices", "getDeviceName("+deviceName+")");
    return deviceName;
}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.