模拟器7.0中的应用程序崩溃:应用程序中的JNI DETECTED ERROR:GetStringUTFChars收到NULL jstring

时间:2016-10-05 10:38:13

标签: android android-ndk android-emulator java-native-interface

我在JniLibs代码上遇到了错误的android ndk。我收到了错误:

  

JNI在应用程序中检测到错误:GetStringUTFChars收到NULL jstring

以下是详细错误。我不能发布所有内容,因为它太长了。

10-05 17:12:01.100 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: GetStringUTFChars received NULL jstring
10-05 17:12:01.100 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470]     in call to GetStringUTFChars
10-05 17:12:01.101 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470]     from java.lang.String com.example.myapp.othercode.PassCodeUtil.genPassCode(android.content.Context)
10-05 17:12:01.101 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470] "main" prio=5 tid=1 Runnable
10-05 17:12:01.101 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470]   | group="main" sCount=0 dsCount=0 obj=0x75518a50 self=0x7ffef3695a00
10-05 17:12:01.101 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470]   | sysTid=3773 nice=0 cgrp=default sched=0/0 handle=0x7ffef7ff9b40
10-05 17:12:01.101 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470]   | state=R schedstat=( 0 0 0 ) utm=3 stm=2 core=0 HZ=100
10-05 17:12:01.101 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470]   | stack=0x7fffa7798000-0x7fffa779a000 stackSize=8MB
10-05 17:12:01.101 3773-3773/com.example.myapp A/art: art/runtime/java_vm_ext.cc:470]   | held mutexes= "mutator lock"(shared held)
.
.
.

JniLibs在此下面的模拟器中运行良好,并在模拟器7.0版中显示错误。从最近的应用程序中删除应用程序并再次打开应用程序时出现错误。是因为模拟器还是我做错了什么。我是android ndk的新手。

感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

最后,我知道问题的原因。我得到GetStringUTFChars参数的错误,我是null。此GetStringUTFChars的语法是:

if (mystring == NULL){ return NULL; } // function GetStringUTFChars

我在参数 string 上得到null,所以解决方法是在使用此函数之前检查null。例如:

    function writeDataToFirebase() {
     var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
      var data = sheet.getDataRange().getValues();
      var dataToImport = {};
      for(var i = 1; i < data.length; i++) {
        var Sr_No=data[i][0];;
        var Employee_Id=data[i][1];                                                     
        dataToImport[Sr_No + '-' + Employee_Id] = {
          NAME:data[i][3],
          DESIGNATION:data[i][4],
          BL_Start_Date:data[i][5],
          Start_Date_at_Company:data[i][6],
          End_DATE:data[i][7],
          Mobile:data[i][8],
          PAN_CARD_NO:data[i][9],
          Email_Address:data[i][10],
          DOB:data[i][11]   
        };
      }
    //  Logger.log(Firebase);
      var firebaseUrl = "https://fundoohr.firebaseio.com";
      var secret="tzRgYNHu26ZkeJLbP7n2DlVBuogeB9NgSrF9z7a2";
      var base = FirebaseApp.getDatabaseByUrl(firebaseUrl,secret);
      base.setData("", dataToImport);
    }

参考文献:https://stackoverflow.com/a/15268628/5241603