在集成框架是一定记住添加相应的权限,官方文档没有提到这个。在demo 中需要以下几个权限
<!-- SDK Only (4Stats)。也是“常用的”几个权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
其中有意思的是,我工程里没有
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
这个权限也报错。报错还挺有意思,仅第一次启动插件的时候才报错,主程序崩溃,再次点击主程序再次启动插件程序居然不会报错了。查了查日志提示
问题:
11-19 14:03:47.183 30411-30411/com.xxxxx.xxxxxx E/CrashFile: 错误CrashTime=2018-11-19 14:03:47.172
BOARD=EVA-AL00
CPU_ABI2=armeabi
HOST=wuhjk0387cna
versionName=v2.2.1
IS_TREBLE_ENABLED=true
SUPPORTED_64_BIT_ABIS=[Ljava.lang.String;@8107aab
CPU_ABI=armeabi-v7a
PERMISSIONS_REVIEW_REQUIRED=false
IS_USERDEBUG=false
DISPLAY=EVA-AL00 8.0.0.535(C00)
SUPPORTED_ABIS=[Ljava.lang.String;@fa68508
FINGERPRINT=HUAWEI/EVA-AL00/HWEVA:8.0.0/HUAWEIEVA-AL00/535(C00):user/release-keys
PRODUCT=EVA-AL00
HIDE_PRODUCT_INFO=false
ID=HUAWEIEVA-AL00
replacements=[Ljava.lang.String;@a3f76c6
TYPE=user
SERIAL=PBV0216B01002150
NO_HOTA=false
IS_CONTAINER=false
IS_ENG=false
DEVICE=HWEVA
TIME=1537190797000
IS_USER=true
MODEL=EVA-AL00
MANUFACTURER=HUAWEI
USER=test
versionCode=25
BRAND=HUAWEI
SUPPORTED_32_BIT_ABIS=[Ljava.lang.String;@b2604fa
matchers=[Ljava.lang.String;@29f44a1
HARDWARE=hi3650
IS_DEBUGGABLE=false
BOOTLOADER=unknown
RADIO=unknown
TAG=Build
UNKNOWN=unknown
IS_EMULATOR=false
TAGS=release-keys
java.lang.SecurityException: no permission to read the sync settings: Neither user 10401 nor current process has android.permission.READ_SYNC_SETTINGS.
at android.os.Parcel.readException(Parcel.java:1946)
at android.os.Parcel.readException(Parcel.java:1892)
at android.content.IContentService$Stub$Proxy.getMasterSyncAutomatically(IContentService.java:1302)
at android.content.ContentResolver.getMasterSyncAutomatically(ContentResolver.java:2637)
at com.fsck.k9.service.MailService.startService(MailService.java:95)
at com.fsck.k9.service.CoreService.onStartCommand(CoreService.java:245)
at com.qihoo360.replugin.component.service.server.PluginServiceServer$1.handleMessage(PluginServiceServer.java:110)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
解决:
添加相应的权限
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
问题二:
Process: com.fsck.k9.debug, PID: 9686
java.lang.VerifyError: Verifier rejected class com.fsck.k9.activity.UpgradeDatabases: void com.fsck.k9.activity.UpgradeDatabases.setupBroadcastReceiver() failed to verify: void com.fsck.k9.activity.UpgradeDatabases.setupBroadcastReceiver(): [0x15] register v0 has type Reference: java.lang.Object but expected Precise Reference: android.support.v4.content.LocalBroadcastManager (declaration of 'com.fsck.k9.activity.UpgradeDatabases' appears in /data/app/com.fsck.k9.debug--_cnEqjNe-MACqRWEXiUUQ==/split_lib_directories_apk.apk)
at com.fsck.k9.activity.UpgradeDatabases.actionUpgradeDatabases(Unknown Source:0)
at com.fsck.k9.activity.Accounts.onCreate(Accounts.java:389)
at android.app.Activity.performCreate(Activity.java:7372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
11-21 10:14:53.684 31510-31510/com.fsck.k9.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.fsck.k9.debug, PID: 31510
java.lang.VerifyError: Verifier rejected class com.fsck.k9.fragment.MessageListFragment: void com.fsck.k9.fragment.MessageListFragment.createCacheBroadcastReceiver(android.content.Context) failed to verify: void com.fsck.k9.fragment.MessageListFragment.createCacheBroadcastReceiver(android.content.Context): [0x4] register v0 has type Reference: java.lang.Object but expected Precise Reference: android.support.v4.content.LocalBroadcastManager (declaration of 'com.fsck.k9.fragment.MessageListFragment' appears in /data/app/com.fsck.k9.debug-7fjWON_Due_Jsc8fHsR7nQ==/base.apk)
at com.fsck.k9.fragment.MessageListFragment.newInstance(MessageListFragment.java:116)
at com.fsck.k9.activity.MessageList.initializeFragments(MessageList.java:329)
at com.fsck.k9.activity.MessageList.onCreate(MessageList.java:263)
at android.app.Activity.performCreate(Activity.java:7372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
解决:
改为普通的广播
问题三:
11-21 11:48:20.445 7054-7054/com.xxxx.xxxxx E/ws001: l.p.a spp|aac: Component class com.fsck.k9.service.BootReceiver does not exist in com.bjytsw.zhengtong
java.lang.IllegalArgumentException: Component class com.fsck.k9.service.BootReceiver does not exist in com.xxxx.xxxx
at android.os.Parcel.readException(Parcel.java:1950)
at android.os.Parcel.readException(Parcel.java:1892)
at android.content.pm.IPackageManager$Stub$Proxy.setComponentEnabledSetting(IPackageManager.java:4708)
at android.app.ApplicationPackageManager.setComponentEnabledSetting(ApplicationPackageManager.java:2364)
at com.fsck.k9.Core.setServicesEnabled(Core.kt:116)
at com.fsck.k9.Core.setServicesEnabled(Core.kt:83)
at com.fsck.k9.Core.init(Core.kt:68)
at com.fsck.k9.App.onCreate(App.kt:22)
at com.qihoo360.replugin.component.app.PluginApplicationClient.callOnCreate(PluginApplicationClient.java:224)
at com.qihoo360.loader2.Plugin.callAppLocked(Plugin.java:925)
at com.qihoo360.loader2.Plugin.callApp(Plugin.java:898)
at com.qihoo360.loader2.Plugin.load(Plugin.java:438)
at com.qihoo360.loader2.PmBase.loadPlugin(PmBase.java:1093)
at com.qihoo360.loader2.PmBase.loadAppPlugin(PmBase.java:1078)
at com.qihoo360.loader2.PluginCommImpl.getActivityInfo(PluginCommImpl.java:561)
at com.qihoo360.loader2.PluginCommImpl.loadPluginActivity(PluginCommImpl.java:411)
at com.qihoo360.loader2.PluginLibraryInternalProxy.startActivity(PluginLibraryInternalProxy.java:268)
at com.qihoo360.loader2.PluginCommImpl.startActivity(PluginCommImpl.java:380)
at com.qihoo360.i.Factory.startActivityWithNoInjectCN(Factory.java:327)
at com.qihoo360.replugin.RePlugin.startActivity(RePlugin.java:247)
at com.bjytsw.zhengtong.fragment.MineFragment.onClick(MineFragment.java:187)
at android.view.View.performClick(View.java:6291)
at android.view.View$PerformClick.run(View.java:24931)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)