使用产品:supermap imobile 10i(2021) for android
操作系统:win10 x64;(手机操作系统:android 11)
问题详细描述:
- 部分运行日志(看起来是文件路径的问题?我确实不太懂如何放置许可文件和地图数据):
(0)下面的MainActivity.java:53这一行就是初始化那一行:
com.supermap.data.Environment.initialization(this);
(1)
2022-08-23 12:02:38.093 764-764/com.example.maptest5 E/Perf: perftest packageName : com.example.maptest5 App is allowed to use Hide APIs
2022-08-23 12:02:38.171 764-867/com.example.maptest5 E/libEGL: Invalid file path for libcolorx-loader.so
2022-08-23 12:02:38.228 764-764/com.example.maptest5 E/Parcel: Reading a NULL string not supported here.
2022-08-23 12:02:38.533 764-764/com.example.maptest5 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.maptest5, PID: 764
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maptest5/com.example.maptest5.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
at...
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
at...
at com.example.maptest5.MainActivity.onCreate(MainActivity.java:53)
(2)
2022-08-23 12:02:43.129 1812-1812/? E/xample.maptest: Unknown bits set in runtime_flags: 0x40000000
2022-08-23 12:02:43.141 1812-1812/? E/RefClass: java.lang.reflect.InvocationTargetException
2022-08-23 12:02:43.327 1812-1812/com.example.maptest5 E/Perf: perftest packageName : com.example.maptest5 App is allowed to use Hide APIs
2022-08-23 12:02:43.349 1812-1896/com.example.maptest5 E/libEGL: Invalid file path for libcolorx-loader.so
2022-08-23 12:02:43.480 1812-1812/com.example.maptest5 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.maptest5, PID: 1812
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maptest5/com.example.maptest5.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
at...
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
at com.supermap.data.Environment.encryptionMac(Environment.java:2283)
at com.supermap.data.Environment.writeFile(Environment.java:2312)
at com.supermap.data.Environment.checkDevice_New(Environment.java:836)
at com.supermap.data.Environment.initialization(Environment.java:626)
at com.example.maptest5.MainActivity.onCreate(MainActivity.java:53)
1.按照产品入门文档在Android Studio编写了相应代码,确已正确设置了ndk { abiFilters 'armeabi-v7a' };
2.在MainActivity.java设置了申请了动态权限(Android 6.0以上版本需要这一步),效果是在首次运行是手机确实会提示该应用要申请的权限,但之后仍然直接闪退。具体设置方法如下,不知道有没有问题:
(1)public class MainActivity extends AppCompatActivity里添加了private void requestPermissions() { //Android6.0以上设备设置动态权限
if (Build.VERSION.SDK_INT >= 23) {
// 检查是否拥有权限
String[] permissions = {
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.ACCESS_WIFI_STATE,
Manifest.permission.ACCESS_NETWORK_STATE,
Manifest.permission.CHANGE_WIFI_STATE,
};
String permission = null;
int id = 0;
boolean isBreak = false;
int checkCallPhonePermission = 0;
for (int i = 0; i < permissions.length; i++) {
permission = permissions[i];
checkCallPhonePermission = checkSelfPermission(permission);
if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) {
requestPermissions(permissions, id);
isBreak = true;
break;
}
}
}
}
(2)在protected void onCreate(Bundle savedInstanceState)里添加requestPermissions();调用上述方法。