首页 / 浏览问题 / 移动GIS / 问题详情
安卓加载 本地工作空间闪退报错 在线场景无反应
145EXP 2022年07月07日
public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    //获取运行环境的绝对路径
    private static String sdcard = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();

    private Button btn_open, btn_open1;
    private Workspace workSpace;
    private SceneControl sceneControl;
    private Boolean bool;

    private static String url = "http://localhost:  8090/iserver/services/3D-World/rest/realspace";

    private String name = "World";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestPermissions();

        //设置许可文件路径
        Environment.setLicensePath(sdcard + "/SuperMap/license/");

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

        //开启全屏
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //强制横屏
//        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        setContentView(R.layout.activity_main);

        initView();

        workSpace = new Workspace();
        WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
        info.setServer(sdcard + "/SampleData/test/World.smwu");
        info.setType(WorkspaceType.SMWU);
        bool = workSpace.open(info);
    }

    /**
     * 初始化
     */
    private void initView() {
        //绑定控件,需要全局声明,这里省去声明
        sceneControl = findViewById(R.id.SceneControl);
        btn_open = findViewById(R.id.btn_open);
        //注册打开场景按钮点击事件
        btn_open.setOnClickListener(this);

        btn_open1 = findViewById(R.id.btn_open1);
        btn_open1.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //打开本地场景
            case R.id.btn_open:
                if (bool) {
                    Scene scene = sceneControl.getScene();
                    scene.setWorkspace(workSpace);
                    String sceneName = workSpace.getScenes().get(0);
                    scene.open(sceneName);
                    scene.refresh();
                }
                break;
            //打开在线场景
            case R.id.btn_open1:
                Scene scene = sceneControl.getScene();
                scene.setWorkspace(workSpace);
                scene.open(url, name);
                scene.refresh();
                break;
        }
    }

    /**
     * 申请动态权限
     * Android6.0以上设备设置动态权限
     */
    private void requestPermissions() {
        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;
                }
            }
        }
    }

}

资源文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <com.supermap.realspace.SceneControl
        android:id="@+id/SceneControl"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <Button
        android:id="@+id/btn_open"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="28dp"
        android:layout_marginBottom="22dp"
        android:text="本地数据" />

    <Button
        android:id="@+id/btn_open1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="22dp"
        android:text="在线数据" />

</RelativeLayout>

点击在线场景报错是:

D/libc-netbsd: [getaddrinfo]: hostname=localhost; servname=8090; cache_mode=(null), netid=0; mark=0
D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=0; ai_family=0
D/libc-netbsd: getaddrinfo: localhost get result from proxy >>
I/Choreographer: Skipped 31 frames!  The application may be doing too much work on its main thread.

点击本地场景报错是:

E/art: No implementation found for long com.supermap.realspace.Layer3DVectorNative.jni_GetFieldInfos(long) (tried Java_com_supermap_realspace_Layer3DVectorNative_jni_1GetFieldInfos and Java_com_supermap_realspace_Layer3DVectorNative_jni_1GetFieldInfos__J)
E/AndroidRuntime: FATAL EXCEPTION: Thread-2299
    Process: com.example.maptest, PID: 30073
    java.lang.UnsatisfiedLinkError: No implementation found for long com.supermap.realspace.Layer3DVectorNative.jni_GetFieldInfos(long) (tried Java_com_supermap_realspace_Layer3DVectorNative_jni_1GetFieldInfos and Java_com_supermap_realspace_Layer3DVectorNative_jni_1GetFieldInfos__J)
        at com.supermap.realspace.Layer3DVectorNative.jni_GetFieldInfos(Native Method)
        at com.supermap.realspace.Layer3D.<init>(Layer3D.java:45)
        at com.supermap.realspace.Layer3DOSGBFile.<init>(Layer3DOSGBFile.java:41)
        at com.supermap.realspace.Layer3D.createInstance(Layer3D.java:377)
        at com.supermap.realspace.Layer3Ds.resetLayer3DsArr(Layer3Ds.java:59)
        at com.supermap.realspace.Layer3Ds.<init>(Layer3Ds.java:43)
        at com.supermap.realspace.Layer3Ds.createInstance(Layer3Ds.java:134)
        at com.supermap.realspace.Scene.getLayers(Scene.java:281)
        at com.supermap.realspace.Scene.fromXML(Scene.java:458)
        at com.supermap.realspace.Scene$1.run(Scene.java:507)
        at android.os.Handler.handleCallback(Handler.java:815)
        at android.os.Handler.dispatchMessage(Handler.java:104)
        at android.os.Looper.loop(Looper.java:194)
        at com.supermap.realspace.SceneControl$RenderThread.run(SceneControl.java:731)
I/Process: Sending signal. PID: 30073 SIG: 9

请问这是 什么 原因

1个回答

您好,您那边看下工程中引用的so文件是否包含了libAutoCAD.so,如果使用三维相关功能需要将该库删掉。
3,685EXP 2022年07月07日
...