使用产品:imobile 10.2 操作系统:win10 x64 华为OS(相当于安卓10)
数据类型: 文件型
问题详细描述:跟着3、SuperMap iMobile for Android快速入门-Android教程-腾讯课堂 (qq.com)网页的教程做,遇到java.lang.NullPointerException错误。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//指定路径,新建文件夹
Environment.setLicensePath("/sdcard/SuperMap/License/");
Environment.setWebCacheDirectory("/sdcard/SuperMap/WebCache/");
Environment.setTemporaryPath("/sdcard/SuperMap/temp/");
// Environment.getLicenseStatus();
//初始化
Environment.initialization(this);
setContentView(R.layout.activity_main);
//打开工作空间
Workspace world = new Workspace();
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
info.setServer("/sdcard/SuperMap/GeometryInfo/World.smwu");
info.setType(WorkspaceType.SMWU);
world.open(info);
//关联地图显示控件和工作空间
MapControl mapControl = findViewById(R.id.mapControl);
mapControl.getMap().setWorkspace(world);
//打开第一幅地图
String mapName = world.getMaps().get(0);
mapControl.getMap().open(mapName);
mapControl.getMap().refresh();
}
问题重现步骤: 1.在onCreate函数里打断点,然后调试
2.Environment.initialization(this) 初始化报错
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.supermaptest, PID: 18099
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.supermaptest/com.example.supermaptest.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4060)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Caused by: java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.Arrays$ArrayList.<init>(Arrays.java:3738)
at java.util.Arrays.asList(Arrays.java:3725)
at com.supermap.data.Environment.checkAndLoadLibrary64(Environment.java:1760)
at com.supermap.data.Environment.initialization(Environment.java:587)
at com.example.supermaptest.MainActivity.onCreate(MainActivity.java:30)
at android.app.Activity.performCreate(Activity.java:8214)
at android.app.Activity.performCreate(Activity.java:8202)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4033)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)