出現這個現象以後會致使 BundleActivator.start()
方法不會被調用java
6.0 方法簽名android
public static PackageInfo generatePackageInfo(PackageParser.Package p, int gids[], int flags, long firstInstallTime, long lastUpdateTime, Set<String> grantedPermissions, PackageUserState state, int userId) {
日誌中出現異常的調用是git
10-25 15:31:35.579 4046-4046/com.wlqq W/System.err: java.lang.NoSuchMethodException: generatePackageInfo [class android.content.pm.PackageParser$Package, class [I, int, long, long, class android.util.ArraySet, class android.content.pm.PackageUserState, int]
6.0.1 的 PackageParser http://androidxref.com/6.0.1_r10/xref/frameworks/base/core/java/android/content/pm/PackageParser.java
5.1.1 的 PackageParser http://androidxref.com/5.1.1_r6/xref/frameworks/base/core/java/android/content/pm/PackageParser.javagithub
Apkplug v3.9 完整日誌api
10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: java.lang.NoSuchMethodException: generatePackageInfo [class android.content.pm.PackageParser$Package, class [I, int, long, long, class android.util.ArraySet, class android.content.pm.PackageUserState, int] 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at java.lang.Class.getMethod(Class.java:624) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at java.lang.Class.getDeclaredMethod(Class.java:586) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.Z.b(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.eg.s(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.eg.t(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.bs.aO(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.bs.ba(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.bs.aK(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.bD.getBaseContext(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.bD.<init>(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.bs.aY(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.bq.getAndroidContext(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at org.tengxin.cl.run(Unknown Source) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at android.os.Handler.handleCallback(Handler.java:739) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at android.os.Looper.loop(Looper.java:148) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5466) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at java.lang.reflect.Method.invoke(Native Method) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 10-27 20:28:11.259 24724-24724/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 10-27 20:28:11.259 24724-24724/com.wlqq E/PackageInfo: ApplicationInfo is null 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: Unable to read ApplicationInfo 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: java.lang.NullPointerException: Attempt to read from field 'android.content.pm.ApplicationInfo android.content.pm.PackageInfo.applicationInfo' on a null object reference 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.eg.t(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.bs.aO(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.bs.ba(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.bs.aK(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.bD.getBaseContext(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.bD.<init>(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.bs.aY(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.bq.getAndroidContext(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at org.tengxin.cl.run(Unknown Source) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at android.os.Handler.handleCallback(Handler.java:739) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at android.os.Looper.loop(Looper.java:148) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5466) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at java.lang.reflect.Method.invoke(Native Method) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 10-27 20:28:11.260 24724-24724/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Apkplug v3.2 完整日誌微信
10-25 15:31:35.579 4046-4046/com.wlqq W/System.err: java.lang.NoSuchMethodException: generatePackageInfo [class android.content.pm.PackageParser$Package, class [I, int, long, long, class android.util.ArraySet, class android.content.pm.PackageUserState, int] 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at java.lang.Class.getMethod(Class.java:624) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at java.lang.Class.getDeclaredMethod(Class.java:586) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at org.tengxin.ag.b(Unknown Source) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at org.tengxin.dx.t(Unknown Source) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at org.tengxin.dx.u(Unknown Source) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at org.tengxin.bf.aQ(Unknown Source) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at org.tengxin.bf.aR(Unknown Source) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at org.tengxin.c.a(Unknown Source) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at org.tengxin.e.execStartActivity(Unknown Source) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3930) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3890) 10-25 15:31:35.587 4046-4046/com.wlqq W/System.err: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:820) 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at com.wlqq.plugin.wallet.sdk.WalletHelper$1$3.run(WalletHelper.java:255) 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at android.os.Handler.handleCallback(Handler.java:739) 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at android.os.Looper.loop(Looper.java:148) 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5466) 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at java.lang.reflect.Method.invoke(Native Method) 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 10-25 15:31:35.588 4046-4046/com.wlqq E/PackageInfo: ApplicationInfo is null 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: Unable to read ApplicationInfo 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: java.lang.NullPointerException: Attempt to read from field 'android.content.pm.ApplicationInfo android.content.pm.PackageInfo.applicationInfo' on a null object reference 10-25 15:31:35.588 4046-4046/com.wlqq W/System.err: at org.tengxin.dx.u(Unknown Source) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at org.tengxin.bf.aQ(Unknown Source) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at org.tengxin.bf.aR(Unknown Source) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at org.tengxin.c.a(Unknown Source) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at org.tengxin.e.execStartActivity(Unknown Source) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3930) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3890) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:820) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at com.wlqq.plugin.wallet.sdk.WalletHelper$1$3.run(WalletHelper.java:255) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.os.Handler.handleCallback(Handler.java:739) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.os.Looper.loop(Looper.java:148) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5466) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at java.lang.reflect.Method.invoke(Native Method) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.pm.ApplicationInfo.className' on a null object reference 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at org.tengxin.bf.aR(Unknown Source) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at org.tengxin.c.a(Unknown Source) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at org.tengxin.e.execStartActivity(Unknown Source) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3930) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3890) 10-25 15:31:35.589 4046-4046/com.wlqq W/System.err: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:820) 10-25 15:31:35.590 4046-4046/com.wlqq W/System.err: at com.wlqq.plugin.wallet.sdk.WalletHelper$1$3.run(WalletHelper.java:255) 10-25 15:31:35.590 4046-4046/com.wlqq W/System.err: at android.os.Handler.handleCallback(Handler.java:739) 10-25 15:31:35.590 4046-4046/com.wlqq W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) 10-25 15:31:35.590 4046-4046/com.wlqq W/System.err: at android.os.Looper.loop(Looper.java:148) 10-25 15:31:35.590 4046-4046/com.wlqq W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5466) 10-25 15:31:35.590 4046-4046/com.wlqq W/System.err: at java.lang.reflect.Method.invoke(Native Method) 10-25 15:31:35.590 4046-4046/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 10-25 15:31:35.590 4046-4046/com.wlqq W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 10-25 15:31:35.590 4046-4046/com.wlqq D/Tracker: track event wallet_launch-error_activity with values {Exception=java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.pm.ApplicationInfo.className' on a null object reference} 10-25 15:31:35.590 4046-4094/com.wlqq I/TDLog: onEvent being called! eventId: wallet_launch, eventLabel: error_activity, eventMap: mapSize: 1
關於在插件中使用以下方法app
int getIdentifier (String name, String defType, String defPackage)
defPackage
不管傳什麼包名,都只會在插件中尋找資源ide
defPackage
只有傳插件包名或宿主包名,纔會在插件中尋找資源oop
v3.9 降級到 v3.2 ,啓動會 crash微信支付
1 java.lang.RuntimeException:Unable to create application com.wuliuqq.client.app.AdminClientApplication: com.tencent.tinker.loader.TinkerRuntimeException: Tinker Exception:onCreate method not found 2 android.app.ActivityThread.handleBindApplication(ActivityThread.java:4480) 3 ...... 4 Caused by: 5 java.lang.NoClassDefFoundError:org.tengxin.dI 6 org.tengxin.bQ.a(Unknown Source) 7 org.tengxin.bQ.<init>(Unknown Source) 8 org.tengxin.bQ.<init>(Unknown Source) 9 org.tengxin.bu.start(Unknown Source) 10 org.apkplug.app.FrameworkFactory.start(Unknown Source) 11 org.apkplug.app.FrameworkFactory.start(Unknown Source) 12 org.apkplug.app.FrameworkFactory.start(Unknown Source) 13 com.wlqq.plugin.sdk.PluginManager.init(PluginManager.java:125) 14 com.wuliuqq.client.plugins.PluginManagerInitService.initPluginManagerSync(PluginManagerInitService.java:82) 15 com.wuliuqq.client.app.DiesApplication.initApkPlug(DiesApplication.java:266) 16 com.wuliuqq.client.app.DiesApplication.onCreateMain(DiesApplication.java:249) 17 com.wuliuqq.client.app.DiesApplicationLike.onCreate(DiesApplicationLike.java:78) 18 com.wuliuqq.client.app.DiesApplication.onCreate(DiesApplication.java:190) 19 com.wuliuqq.client.app.DiesApplicationLike.onCreate(DiesApplicationLike.java:73) 20 java.lang.reflect.Method.invokeNative(Native Method) 21 java.lang.reflect.Method.invoke(Method.java:525) 22 com.tencent.tinker.loader.app.TinkerApplication.delegateMethod(TinkerApplication.java:181) 23 com.tencent.tinker.loader.app.TinkerApplication.onCreate(TinkerApplication.java:192) 24 android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007) 25 android.app.ActivityThread.handleBindApplication(ActivityThread.java:4477) 26 android.app.ActivityThread.access$1300(ActivityThread.java:144) 27 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319) 28 android.os.Handler.dispatchMessage(Handler.java:99) 29 android.os.Looper.loop(Looper.java:137) 30 android.app.ActivityThread.main(ActivityThread.java:5136) 31 java.lang.reflect.Method.invokeNative(Native Method) 32 java.lang.reflect.Method.invoke(Method.java:525) 33 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 34 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 35 dalvik.system.NativeStart.main(Native Method)
插件中 bind 插件中的 Service
,在代理模式下,不能使用 Context#getApplication()
獲取的 Context
,而須要使用 Activity
之類的 Context
線上統計數據大概 20% 存在這種狀況,所以建議不要把重要的初始化邏輯放在裏面
06-13 11:28:13.676 5460-5863/com.wlqq W/System.err: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at android.os.Handler.<init>(Handler.java:121) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at android.app.Application.<init>(Application.java:81) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at java.lang.Class.newInstanceImpl(Native Method) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at java.lang.Class.newInstance(Class.java:1319) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at android.app.Instrumentation.newApplication(Instrumentation.java:982) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at android.app.Instrumentation.newApplication(Instrumentation.java:967) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at org.tengxin.bf.aR(Unknown Source) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at org.tengxin.bp.getApplicationContext(Unknown Source) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at com.nostra13.universalimageloader.core.ImageLoaderConfiguration$Builder.<init>(ImageLoaderConfiguration.java:191) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at com.wlqq.plugin.wallet.PluginActivator.initImageLoader(PluginActivator.java:60) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at com.wlqq.plugin.wallet.PluginActivator.init(PluginActivator.java:55) 06-13 11:28:13.686 5460-5863/com.wlqq W/System.err: at com.wlqq.plugin.wallet.PluginActivator.start(PluginActivator.java:31)
不能夠。調用 intent.getParcelableExtra
獲取 ResultReceiver
會出現如下異常
06-01 10:17:15.270 19102-19102/com.hcb.driver W/TDLog: UncaughtException in Thread main java.lang.RuntimeException: Error receiving broadcast Intent { act=install_plugin flg=0x10 pkg=com.hcb.driver (has extras) } in com.wlqq.plugin.sdk.PluginManager$InstallerService@448a9a9 at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:893) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5432) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: plugin.store.WalletServiceManager$1 at android.os.Parcel.readParcelableCreator(Parcel.java:2432) at android.os.Parcel.readParcelable(Parcel.java:2358) at android.os.Parcel.readValue(Parcel.java:2264) at android.os.Parcel.readArrayMapInternal(Parcel.java:2614) at android.os.BaseBundle.unparcel(BaseBundle.java:221) at android.os.Bundle.getParcelable(Bundle.java:786) at android.content.Intent.getParcelableExtra(Intent.java:5381) at com.wlqq.plugin.sdk.PluginManager$InstallerService.onReceive(PluginManager.java:1204)
不能夠。但能夠使用普通的 Broadcast
不能使用, 使用該方法可能會致使 Activity 界面卡死
宿主
-dontwarn org.apkplug.app.** -dontwarn org.apkplug.Bundle.** -dontwarn org.osgi.framework.** -dontwarn org.osgi.service.** -keep class org.apkplug.app.** { *; } -keep class org.apkplug.Bundle.** { *; } -keep class org.osgi.framework.** { *; } -keep class org.osgi.service.** { *; } -keep class org.tengxin** -keep class org.apkplug.mxdstream** { <fields>; <methods>; } -keepclassmembers class * extends android.content.ContentResolver { <methods>; } -keepclassmembers class * extends android.app.INotificationManager { <fields>; <methods>; } -keep class android.app.ITransientNotification { <fields>; <methods>; } -keep class android.service.notification** { <fields>; <methods>; } -keep class android.app.INotificationManager { <fields>; <methods>; } -keep class android.content.pm** -keep class android.os** -keepclassmembers class * extends android.content.pm.PackageManager { <methods>; } -keep class android.content.res.MiuiResources -keep class android.app.ApplicationPackageManager -keepclassmembers class * extends android.app.ApplicationPackageManager { <methods>; } -dontwarn org.tengxin.sv.** -dontwarn com.msg.** -dontwarn com.apkplug.CloudService.** -dontwarn com.apkplug.base.** -dontwarn com.apkplug.Ads** -dontwarn com.apkplug.AdsPlug** -dontwarn com.apkplug.Analytics** -dontwarn com.apkplug.Feedback** -dontwarn com.apkplug.Analytics.Bean** -dontwarn org.openudid** -keep class org.tengxin.sv** { *; } -keep class org.osgi** { *; } -keep class com.msg**{ *; } -keep class com.apkplug.CloudService**{ *; } -keep class com.apkplug.base** { *; } -keep class com.apkplug.Ads** { *; } -keep class com.apkplug.AdsPlug** { *; } -keep class com.apkplug.Analytics** { *; } -keep class com.apkplug.Feedback** { *; } -keep class com.apkplug.Analytics.Bean** { *; } -keep class org.openudid** { *; }
插件
-libraryjars android-support-v4.jar -libraryjars osgi.jar -keep class * implements org.osgi.** { *; } -keep class * implements org.apkplug.Bundle.** { *; } -keep class org.apkplug.mxdstream** { <fields>; <methods>; }
調用 startActivityForResult
方法,不要使用 Intent.FLAG_ACTIVITY_NEW_TASK
宿主
AndroidManifest.xml
中聲明 ${宿主應用的包名}.wxapi.WXPayEntryActivity
,設置 android:exported="true"
插件
${宿主應用的包名}.wxapi.WXPayEntryActivity
,在裏面處理微信支付回調plugin.xml
中配置導出該 Activity
參考