操作系统win10 x64 Android studio 11.0.11
sdk platform 30 revision1 gradle version 7.2 gradle plugin version 7.1.2 Android API30 Android11.0(R)
jdk 11
问题:运行代码为官网示例代码 mobile-gis,已更换工程许可,可以成功打包,但是闪退。现在有如下报错,是否与闪退有关,要怎么解决呢?
我用Android studio运行也会闪退,logcat的报错如下:
/? I/e.myapplicatio: Late-enabling -Xcheck:jni /? E/USNET: USNET: appName: com.supermap.imobile.myapplication /? D/ActivityThread: setConscryptValidator /? D/ActivityThread: setConscryptValidator - put /? D/ActivityThread: handleBindApplication()++ app=com.supermap.imobile.myapplication /? D/CompatibilityChangeReporter: Compat change id reported: 171979766; UID 11248; state: DISABLED /? V/GraphicsEnvironment: ANGLE Developer option for 'com.supermap.imobile.myapplication' set to: 'default' /? V/GraphicsEnvironment: App is not on the allowlist for updatable production driver. /? D/LoadedApk: LoadedApk::makeApplication() appContext.mOpPackageName=com.supermap.imobile.myapplication appContext.mBasePackageName=com.supermap.imobile.myapplication /? D/NetworkSecurityConfig: No Network Security Config specified, using platform default /? D/NetworkSecurityConfig: No Network Security Config specified, using platform default /? D/ActivityThread: handleBindApplication() -- /? W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Mobile GIS/Data/Changchun.bru: open failed: EPERM (Operation not permitted) /? W/System.err: at libcore.io.IoBridge.open(IoBridge.java:575) /? W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:236) /? W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:186) /? W/System.err: at com.supermap.imobile.myapplication.MyApplication.CopyFiles(MyApplication.java:54) /? W/System.err: at com.supermap.imobile.myapplication.MyApplication.CopyFiles(MyApplication.java:46) /? W/System.err: at com.supermap.imobile.myapplication.MyApplication.CopyFiles(MyApplication.java:46) /? W/System.err: at com.supermap.imobile.myapplication.MyApplication.initData(MyApplication.java:28) /? W/System.err: at com.supermap.imobile.myapplication.MyApplication.onCreate(MyApplication.java:17) /? W/System.err: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211) /? W/System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7588) /? W/System.err: at android.app.ActivityThread.access$1700(ActivityThread.java:315) /? W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2286) /? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106) /? W/System.err: at android.os.Looper.loopOnce(Looper.java:226) /? W/System.err: at android.os.Looper.loop(Looper.java:313) /? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8751) /? W/System.err: at java.lang.reflect.Method.invoke(Native Method) /? W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) /? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) /? W/System.err: Caused by: android.system.ErrnoException: open failed: EPERM (Operation not permitted) /? W/System.err: at libcore.io.Linux.open(Native Method) /? W/System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:567) /? W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:273) /? W/System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:567) /? W/System.err: at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8611) /? W/System.err: at libcore.io.IoBridge.open(IoBridge.java:561) /? W/System.err: ... 18 more /? D/OpenGLRenderer: RenderThread::requireGlContext() /? I/AdrenoGLES-0: QUALCOMM build : cac6e6f805, I5187d04b75 Build Date : 11/22/21 OpenGL ES Shader Compiler Version: EV031.35.01.10 Local Branch : Remote Branch : Remote Branch : Reconstruct Branch : /? I/AdrenoGLES-0: Build Config : S P 10.0.7 AArch64 /? I/AdrenoGLES-0: Driver Path : /vendor/lib64/egl/libGLESv2_adreno.so /? I/AdrenoGLES-0: PFP: 0x016dc094, ME: 0x00000000 /? D/OpenGLRenderer: RenderThread::setGrContext() /? D/AndroidRuntime: Shutting down VM /? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.supermap.imobile.myapplication, PID: 21556 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.supermap.imobile.myapplication/com.supermap.imobile.myapplication.MainActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4111) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4277) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 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:2443) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8751) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) Caused by: java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:220) 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.supermap.imobile.myapplication.MainActivity.onCreate(MainActivity.java:57) at android.app.Activity.performCreate(Activity.java:8290) at android.app.Activity.performCreate(Activity.java:8270) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4085) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4277) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 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:2443) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8751) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
另外,我打开了云盘的链接,并且成功打包,但打开app出现屏幕闪烁的情况,白色背景。这是logcat的报错内容:
/com.bestyou.myapplication V/studio.deploy: Startup agent attached to VM /com.bestyou.myapplication V/studio.deploy: No existing instrumentation found. Loading instrumentation from instruments-88564b4d.jar /com.bestyou.myapplication W/u.myapplicatio: DexFile /data/data/com.bestyou.myapplication/code_cache/.studio/instruments-88564b4d.jar is in boot class path but is not in a known location /com.bestyou.myapplication V/studio.deploy: Applying transforms with cached classes /com.bestyou.myapplication W/u.myapplicatio: Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled. /com.bestyou.myapplication W/u.myapplicatio: Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled. /com.bestyou.myapplication D/ActivityThread: handleBindApplication()++ app=com.bestyou.myapplication /com.bestyou.myapplication D/CompatibilityChangeReporter: Compat change id reported: 171979766; UID 11249; state: ENABLED /? I/u.myapplicatio: Late-enabling -Xcheck:jni /? E/USNET: USNET: appName: com.bestyou.myapplication /? D/ActivityThread: setConscryptValidator /? D/ActivityThread: setConscryptValidator - put /com.bestyou.myapplication V/GraphicsEnvironment: ANGLE Developer option for 'com.bestyou.myapplication' set to: 'default' /com.bestyou.myapplication V/GraphicsEnvironment: App is not on the allowlist for updatable production driver. /com.bestyou.myapplication D/LoadedApk: LoadedApk::makeApplication() appContext.mOpPackageName=com.bestyou.myapplication appContext.mBasePackageName=com.bestyou.myapplication /com.bestyou.myapplication D/NetworkSecurityConfig: No Network Security Config specified, using platform default /com.bestyou.myapplication D/NetworkSecurityConfig: No Network Security Config specified, using platform default /com.bestyou.myapplication D/ActivityThread: handleBindApplication() -- /com.bestyou.myapplication D/OpenGLRenderer: RenderThread::requireGlContext() /com.bestyou.myapplication I/AdrenoGLES-0: QUALCOMM build : cac6e6f805, I5187d04b75 Build Date : 11/22/21 OpenGL ES Shader Compiler Version: EV031.35.01.10 Local Branch : Remote Branch : Remote Branch : Reconstruct Branch : /com.bestyou.myapplication I/AdrenoGLES-0: Build Config : S P 10.0.7 AArch32 /com.bestyou.myapplication I/AdrenoGLES-0: Driver Path : /vendor/lib/egl/libGLESv2_adreno.so /com.bestyou.myapplication I/AdrenoGLES-0: PFP: 0x016dc094, ME: 0x00000000 /com.bestyou.myapplication D/OpenGLRenderer: RenderThread::setGrContext() /com.bestyou.myapplication W/System.err: java.io.IOException: No such file or directory /com.bestyou.myapplication W/System.err: at java.io.UnixFileSystem.createFileExclusively0(Native Method) /com.bestyou.myapplication W/System.err: at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:317) /com.bestyou.myapplication W/System.err: at java.io.File.createNewFile(File.java:1006) /com.bestyou.myapplication W/System.err: at com.supermap.data.Environment.checkDevice_New(Environment.java:832) /com.bestyou.myapplication W/System.err: at com.supermap.data.Environment.initialization(Environment.java:626) /com.bestyou.myapplication W/System.err: at com.bestyou.myapplication.MainActivity.onCreate(MainActivity.java:74) /com.bestyou.myapplication W/System.err: at android.app.Activity.performCreate(Activity.java:8290) /com.bestyou.myapplication W/System.err: at android.app.Activity.performCreate(Activity.java:8270) [...] /com.bestyou.myapplication W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106) /com.bestyou.myapplication W/System.err: at android.os.Looper.loopOnce(Looper.java:226) /com.bestyou.myapplication W/System.err: at android.os.Looper.loop(Looper.java:313) /com.bestyou.myapplication W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8751) /com.bestyou.myapplication W/System.err: at java.lang.reflect.Method.invoke(Native Method) /com.bestyou.myapplication W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) /com.bestyou.myapplication W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) /com.bestyou.myapplication D/AndroidRuntime: Shutting down VM /com.bestyou.myapplication E/AndroidRuntime: FATAL EXCEPTION: main Process: com.bestyou.myapplication, PID: 18040 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bestyou.myapplication/com.bestyou.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4111) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4277) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 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:2443) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8751) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference at com.supermap.data.Environment.encryptionMac(Environment.java:2283) [...] at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) /com.bestyou.myapplication I/Process: Sending signal. PID: 18040 SIG: 9
在打开的hellomap工程中,gradle版本5.6.4,gradle插件版本3.6.3,jdk8,sdk32。Android studio与系统版本同上。
首先
String RootPath = android.os.Environment.getExternalStorageDirectory().getAbsolutePath().toString(); Environment.setLicensePath(RootPath + "/Mobile GIS/License/");
然后我创建如下工作空间:我的手机>内部存储>Mobile GIS>License,里面放入我申请的许可“SuperMap iMobile Trial-20221024.slm”
在运行之后他已经在Mobile GIS这个文件夹下面产生了Data文件,虽然他是空的,这是不是代表路径没有问题呢?