首页 / 浏览问题 / 移动GIS / 问题详情
app在手机上点开后闪退
4EXP 2022年10月11日
使用产品:iMobile 11i 操作系统:win10 x64
问题详细描述:按照开发文档的步骤完成了jdk、Android Studio环境配置和代码编写,构建没有报错,但是把app安装到真机之后(vivo x27),会直接闪退。未引入SuperMap时的HelloWorld的demo可以在手机上打开,想请问这个问题可以怎么解决。

2022-10-11 14:23:16.322 8100-8100/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.myapplication, PID: 8100
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.FileOutputStream.close()' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3680)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3835)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
        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:2291)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:230)
        at android.app.ActivityThread.main(ActivityThread.java:8024)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:526)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.FileOutputStream.close()' on a null object reference
        at com.supermap.data.Environment.writeFile(Environment.java:2320)
        at com.supermap.data.Environment.checkDevice_New(Environment.java:836)
        at com.supermap.data.Environment.initialization(Environment.java:626)
        at com.example.myapplication.MainActivity.onCreate(MainActivity.java:30)
        at android.app.Activity.performCreate(Activity.java:7894)
        at android.app.Activity.performCreate(Activity.java:7883)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1353)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3655)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3835)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
        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:2291)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:230)
        at android.app.ActivityThread.main(ActivityThread.java:8024)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:526)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)

1个回答

您好请您确认一下几点:

1.许可路径是否设置正确;

2.设备是否连接网络,时间是否正确;

3.应用是否有读取权限;

4.许可是否可用;

5..gradle版本不要太高,建议4-6之间;

6.build.gradle中compileSdk与targetSdk不要太高,建议使用28

7.build.gradle中是否有添加

ndk{
    abiFilters 'armeabi-v7a'
}

8.如果上述都确认了还是不行,使用debug模式启动,说明下报错信息呢

3,745EXP 2022年10月11日
您好,这个是logcat的报错信息

2022-10-11 14:23:16.322 8100-8100/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.myapplication, PID: 8100
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.FileOutputStream.close()' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3680)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3835)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
        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:2291)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:230)
        at android.app.ActivityThread.main(ActivityThread.java:8024)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:526)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.FileOutputStream.close()' on a null object reference
        at com.supermap.data.Environment.writeFile(Environment.java:2320)
        at com.supermap.data.Environment.checkDevice_New(Environment.java:836)
        at com.supermap.data.Environment.initialization(Environment.java:626)
        at com.example.myapplication.MainActivity.onCreate(MainActivity.java:30)
        at android.app.Activity.performCreate(Activity.java:7894)
        at android.app.Activity.performCreate(Activity.java:7883)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1353)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3655)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3835)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
        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:2291)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:230)
        at android.app.ActivityThread.main(ActivityThread.java:8024)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:526)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
更换build.gradle的compileSdk与targetSdk为28后解决
...