问题描述
我是用预制纯二进制apk的方式打包目标apk进android系统rom,安装完rom,发现目标apk无法正常启动,就是一直在启动界面那里转圈。但是通过正常安装第三方apk的方式可以顺利运行。
复现步骤
1.启动android系统
2.点击目标app图标
预期结果
可以正常启动apk
实际结果
先贴和uniapp相关的logcat(通过adb logcat | grep io.dcloud.bddt得到的log):
06-26 21:53:46.991 1508 3461 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=io.dcloud.bddt/io.dcloud.PandoraEntryActivity bnds=[27,648][193,866] (has extras)} from uid 10105
06-26 21:53:47.087 1508 4816 W DevicePolicyManager: Package io.dcloud.bddt (uid=10105, pid=5536) cannot access Device IDs
06-26 21:53:47.088 3521 4104 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:io.dcloud.bddt:getIccSerialNumber:isPreinstalled=true:isPrivApp=true
06-26 21:53:47.098 1508 4816 W DevicePolicyManager: Package io.dcloud.bddt (uid=10105, pid=5536) cannot access Device IDs
06-26 21:53:47.098 3521 4104 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:io.dcloud.bddt:getSubscriberId:isPreinstalled=true:isPrivApp=true
06-26 21:53:47.198 1508 1543 I ActivityTaskManager: Displayed io.dcloud.bddt/io.dcloud.PandoraEntryActivity: +98ms
06-26 21:53:47.368 5536 5549 W io.dcloud.bddt: Reducing the number of considered missed Gc histogram windows from 455 to 100
06-26 21:53:47.409 1508 6469 W DevicePolicyManager: Package io.dcloud.bddt (uid=10105, pid=5536) cannot access Device IDs
06-26 21:53:47.410 3521 4104 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:io.dcloud.bddt:getImeiForSlot:isPreinstalled=true:isPrivApp=true
06-26 21:53:47.416 1508 3461 W DevicePolicyManager: Package io.dcloud.bddt (uid=10105, pid=5536) cannot access Device IDs
06-26 21:53:47.417 3521 4104 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:io.dcloud.bddt:getImeiForSlot:isPreinstalled=true:isPrivApp=true
06-26 21:53:47.420 1508 19970 W DevicePolicyManager: Package io.dcloud.bddt (uid=10105, pid=5536) cannot access Device IDs
06-26 21:53:47.420 3521 4104 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:io.dcloud.bddt:getImeiForSlot:isPreinstalled=true:isPrivApp=true
06-26 21:53:47.422 1508 19970 W DevicePolicyManager: Package io.dcloud.bddt (uid=10105, pid=5536) cannot access Device IDs
06-26 21:53:47.423 3521 4104 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:io.dcloud.bddt:getDeviceId:isPreinstalled=true:isPrivApp=true
06-26 21:53:47.472 1508 1545 I ActivityManager: Start proc 22882:com.google.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:2/u0i8 for {io.dcloud.bddt/org.chromium.content.app.SandboxedProcessService0:2}
再贴上一些异常log:
06-25 17:06:27.387 1508 1531 W DevicePolicyManager: Package io.dcloud.bddt (uid=10105, pid=5536) cannot access Device IDs
06-25 17:06:27.388 3521 4348 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:io.dcloud.bddt:getIccSerialNumber:isPreinstalled=true:isPrivApp=true
06-25 17:06:27.391 3521 4348 E DatabaseUtils: Writing exception to parcel
06-25 17:06:27.391 3521 4348 E DatabaseUtils: java.lang.SecurityException: No phone privilege permission
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at com.android.providers.telephony.TelephonyProvider.checkPhonePrivilegePermission(TelephonyProvider.java:3885)
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at com.android.providers.telephony.TelephonyProvider.checkQueryPermission(TelephonyProvider.java:3091)
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at com.android.providers.telephony.TelephonyProvider.query(TelephonyProvider.java:2839)
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at android.content.ContentProvider.query(ContentProvider.java:1214)
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at android.content.ContentProvider.query(ContentProvider.java:1307)
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at android.content.ContentProvider$Transport.query(ContentProvider.java:267)
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:104)
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at android.os.Binder.execTransactInternal(Binder.java:1021)
06-25 17:06:27.391 3521 4348 E DatabaseUtils: at android.os.Binder.execTransact(Binder.java:994)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: Writing exception to parcel
06-25 17:06:27.396 3521 4348 E DatabaseUtils: java.lang.SecurityException: No phone privilege permission
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at com.android.providers.telephony.TelephonyProvider.checkPhonePrivilegePermission(TelephonyProvider.java:3885)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at com.android.providers.telephony.TelephonyProvider.checkQueryPermission(TelephonyProvider.java:3091)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at com.android.providers.telephony.TelephonyProvider.query(TelephonyProvider.java:2839)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at android.content.ContentProvider.query(ContentProvider.java:1214)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at android.content.ContentProvider.query(ContentProvider.java:1307)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at android.content.ContentProvider$Transport.query(ContentProvider.java:267)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:104)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at android.os.Binder.execTransactInternal(Binder.java:1021)
06-25 17:06:27.396 3521 4348 E DatabaseUtils: at android.os.Binder.execTransact(Binder.java:994)
06-25 17:06:27.398 1508 11220 W DevicePolicyManager: Package io.dcloud.bddt (uid=10105, pid=5536) cannot access Device IDs
06-25 17:06:27.399 3521 4348 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:io.dcloud.bddt:getSubscriberId:isPreinstalled=true:isPrivApp=true
系统信息:
- 发行平台: android apk
- 操作系统 [Android 10.0]
- HBuilderX版本 [2.7.9]
- uni-app版本 [2.2.0]
- 设备信息 [红米7a]
补充信息
根据我的信息和分析,可能是需要在androidManifest.xml增加READ_PHONE_STATE权限或者READ_PRIVILEGED_PHONE_STATE 权限,但是apk的开发商可能不知道怎么去加这个权限。uniapp可能默认会调用TelephonyManager的下面这些接口
- getImei()
- getDeviceId()
- getMeid()
- getSimSerialNumber()
- getSubscriberId()
BTW:
我又查看了HB的android_base.apk的androidManifest.xml,发现里面的权限特别多。我已经测试了android_base.apk在内置模式下和adb install 的方式下,表现一致,都能运行到“HBuilderX真机运行”的界面。所以我怀疑目标apk可能少了一些权限。
请帮忙诊断!
参考资料
https://developer.android.com/about/versions/10/privacy/changes
https://github.com/dcloudio/uni-app/issues/1842