首页 / 浏览问题 / 移动GIS / 问题详情
移动端t-加载地图test出现的问题
12EXP 2020年04月28日

Caused by: java.lang.NullPointerException: Attempt to get length of null array
at com.supermap.data.Environment.checkAndLoadLibrary64(Environment.java:1694)
at com.supermap.data.Environment.initialization(Environment.java:582)
at com.example.a82629.test2.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:7783)
at android.app.Activity.performCreate(Activity.java:7772)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3235)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3396)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2009)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7319)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)

18  //初始化环境
19  com.supermap.data.Environment.setLicensePath("sdcard/SuperMap/License/");
20  com.supermap.data.Environment.setWebCacheDirectory("sdcard/SuperMap/WebCache");
21  com.supermap.data.Environment.setTemporaryPath("sdcard/SuperMap/temp/");
22  com.supermap.data.Environment.initialization(this);
23  setContentView(R.layout.activity_main);

这里说我出现空指针问题,这里怎么解决啊?

2 个回答

依然出现这样的问题
12EXP 2020年04月28日
还是报什么错误呢?设备的权限是否开启

Caused by: java.lang.NullPointerException: Attempt to get length of null array

依然是这句

//组件功能必须在Environment初始化之后才能调用
com.supermap.data.Environment.initialization(this);

我加了

defaultConfig {
    applicationId "com.example.a82629.test2"
    minSdkVersion 20
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner    "android.support.test.runner.AndroidJUnitRunner"
    ndk{
        abiFilters "armeabi-v7a"
    }	
}

权限

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
    tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEM"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

在Android6.0设备以上运行需要开启动态权限,可以在代码的onCreate后面加入以下代码;:

//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};
    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;
        }
    }
}

您好,看报错信息是因为去检查64位库导致崩溃的,由于我们的sdk中没有64位库,所以会崩溃。解决方案如下:设置ndk
在app的grandle文件的defaultConfig节点添加以下代码

ndk {
    abiFilters "armeabi-v7a"
}
9,197EXP 2020年04月28日
...