MapControl mapControl = null;
String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
//设置许可文件路径(默认路径“/SuperMap/license/”)
Environment.setLicensePath(rootPath + "/SuperMap/license/"); // 此路径我验证过没问题
//组件功能必须在Environment初始化之后才能调用
Environment.initialization(this);
setContentView(R.layout.activity_main);
//打开工作空间
Workspace m_workspace = new Workspace();
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
info.setServer(rootPath + "/SampleData/GeometryInfo/World.smwu");
info.setType(WorkspaceType.SMWU);
m_workspace.open(info); // 断点这这步的时候 报错
//将地图显示控件和工作空间关联
MapView m_mapView = findViewById(R.id.mapView);
mapControl = m_mapView.getMapControl();
mapControl.getMap().setWorkspace(m_workspace);
//打开工作空间中的第二幅地图
String mapName = m_workspace.getMaps().get(1);
mapControl.getMap().open(mapName);
mapControl.getMap().refresh();
错误信息如下:
Process: com.example.supermapdemo, PID: 25405
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.supermapdemo/com.example.supermapdemo.MainActivity}: java.lang.IllegalStateException: LicenseStatus[
Status = 无效许可
Type = 试用许可
Version = 1100
SartDate = 2022-06-01
ExpireDate = 2022-09-01
]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3049)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3127)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:192)
at android.app.ActivityThread.main(ActivityThread.java:6896)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:875)
Caused by: java.lang.IllegalStateException: LicenseStatus[
Status = 无效许可
Type = 试用许可
Version = 1100
SartDate = 2022-06-01
ExpireDate = 2022-09-01
]
这里能看到证书许可的时间都是在有效期内,按照文档和视频配置的方式