首页 / 浏览问题 / 移动GIS / 问题详情
示例安卓APP(二维地图显示)闪退
16EXP 2022年08月23日

使用产品:supermap imobile 10i(2021) for android

操作系统:win10 x64;(手机操作系统:android 11)

问题详细描述:

  1. 部分运行日志(看起来是文件路径的问题?我确实不太懂如何放置许可文件和地图数据):

  (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();调用上述方法。

1个回答

您好,请问您那边工程的gradle版本是多少,建议您的gradle版本使用不要太高,要是您不确定建议您把最外层的gradle内容修改为如下:

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            allowInsecureProtocol = true
            url "https://developer.huawei.com/repo/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'

    }
}
allprojects {
    repositories {

    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

如果还是不可以,这边私信您,看看具体情况呢

3,745EXP 2022年08月23日
我完全按照iMobile 10i 的入门文档做的,请你按照文档复现一下,看看会不会出错。

入门文档我分享到百度网盘请您查看!

链接:https://pan.baidu.com/s/13z13KHMBT7V69I6WQNVToQ?pwd=1111
提取码:1111
后来确认是设备与gradle版本问题,第一次运行设备最好下载itablet测试一下,gradle中的版本推荐使用28
...