首页 / 浏览问题 / 移动GIS / 问题详情
Navidemo的getDeviceId报错要怎么解决,有许可证书
14EXP 2021年04月16日

     有动态权限,target更改,ndk对的,gradle3.1.3,手机许可路径对的,

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.navide/com.example.navide.StartupActivity}: java.lang.SecurityException: getDeviceId
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6810)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

Caused by: java.lang.SecurityException: getDeviceId
        at android.os.Parcel.createException(Parcel.java:1953)
        at android.os.Parcel.readException(Parcel.java:1921)
        at android.os.Parcel.readException(Parcel.java:1871)
        at com.android.internal.telephony.ITelephony$Stub$Proxy.getDeviceId(ITelephony.java:5439)
        at android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:1224)
        at com.supermap.data.Environment.checkDevice_New(Environment.java:854)
        at com.supermap.data.Environment.initialization(Environment.java:623)
        at com.example.navide.StartupActivity.onCreate(StartupActivity.java:32)//erro

1个回答

您好,看报错就是安全的问题,在获取设备id之前确定已经开启了动态权限?您那边targetSDK是哪个版本
9,242EXP 2021年04月16日
修改了权限之后又有个问题,麻烦了谢谢

Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.navide.MyApplication

您好,这个报错网上有很多解决方案,您那边可以百度搜索一下:https://blog.csdn.net/xulianboblog/article/details/50997629

好的谢谢
...