使用产品:supermap-imobile-11.1.0-234-android-zip-chs package com.example.scenedemo; import androidx.appcompat.app.AppCompatActivity; import android.Manifest; import android.os.Build; import android.os.Bundle; import android.view.View; import android.widget.Button; import com.supermap.data.Environment; import com.supermap.realspace.Scene; import com.supermap.realspace.SceneControl; import java.io.File; import pub.devrel.easypermissions.EasyPermissions; public class MainActivity extends AppCompatActivity { private SceneControl m_sceneControl; private Button m_btnOpen; // 离线三维场景数据名称 String url = "192_168_1_111_8090_iserver_services_realspace-CBD"; // 三维场景名称 String sceneName = "CBD"; String rootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath().toString(); /** * 需要申请的权限数组 */ protected String[] needPermissions = { 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, }; /** * 初始化环境 */ private void initEnvironment() { //设置一些系统需要用到的路径 File file = new File(rootPath + "/SuperMap/license/","SuperMap iMobile Trial -20230626.slm"); boolean flag = file.exists(); Environment.setLicensePath(rootPath + "/SuperMap/license/"); // Environment.setTemporaryPath(rootPath + "/SuperMap/temp/"); // Environment.setWebCacheDirectory(rootPath + "/SuperMap/WebCatch"); //如果机器中默认不包括需要显示的字体,可以把相关字体文件放在参数所代表的路径中。 //组件功能必须在Environment初始化之后才能调用 Environment.initialization(MainActivity.this); } @Override protected void onCreate(Bundle savedInstanceState) { // 配置超图许可 super.onCreate(savedInstanceState); requestPermissions() ; initEnvironment(); setContentView(R.layout.activity_main); //获取场景控件 m_sceneControl = (SceneControl)findViewById(R.id.SceneControl); m_btnOpen = (Button)findViewById(R.id.btn_open); m_btnOpen.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 获取Scene Scene scene = m_sceneControl.getScene(); // 根据url,通过已知的场景名称打开场景, 密码默认是supermap scene.open(url, sceneName, "supermap"); } }); // //打开本地三维数据 // SceneControl m_sceneControl = findViewById(R.id.SceneControl); // // String wksPath = rootPath + "/SuperMap/SampleData/CBD/CBD 场景.sxwu"; // Workspace m_workspace = new Workspace(); // WorkspaceConnectionInfo info = new WorkspaceConnectionInfo(); // info.setServer(wksPath); // info.setType(WorkspaceType.SXWU); // if (m_workspace.open(info)) { m_sceneControl.getScene().setWorkspace(m_workspace); // } // String sceneName = m_workspace.getScenes().get(0); // Boolean bOpened = m_sceneControl.getScene().open(sceneName); } /** * 检测权限 * return true:已经获取权限 * return false: 未获取权限,主动请求权限 */ public boolean checkPermissions(String[] permissions) { return EasyPermissions.hasPermissions(this, permissions); } /** * 申请动态权限 */ private void requestPermissions() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return; } if (!checkPermissions(needPermissions)) { EasyPermissions.requestPermissions( this, "为了应用的正常使用,请允许以下权限。", 0, 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); //没有授权,编写申请权限代码 } else { //已经授权,执行操作代码 } } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); // Forward results to EasyPermissions EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this); } } 问题出现位置 Environment.initialization(MainActivity.this); 报错信息: