DroidPluginTeam / DroidPlugin

A plugin framework on android,Run any third-party apk without installation, modification or repackage
http://droidpluginteam.github.io/DroidPlugin/
GNU Lesser General Public License v3.0
6.9k stars 2.53k forks source link

Why is my plugin not loading? #376

Closed kkworden closed 7 years ago

kkworden commented 7 years ago

Hello.

I am trying to load my plugin using this code in my host activity:

PluginManager.getInstance().installPackage(
       apkFile.getAbsolutePath(),
       PackageManagerCompat.INSTALL_REPLACE_EXISTING);
PackageInfo packageInfo = PluginManager.getInstance().getInstalledPackages(0).get(0);
PackageManager pm = this.getPackageManager();
Intent intent = pm.getLaunchIntentForPackage(packageInfo.packageName);
// packageInfo.packageName == "com.gdms.plugin"
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

However, I get the following error:

07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err: java.lang.NullPointerException
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at com.gdms.host.MainActivity.onActivityResult(MainActivity.java:57)
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at android.app.Activity.dispatchActivityResult(Activity.java:5488)
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at android.app.ActivityThread.deliverResults(ActivityThread.java:3515)
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3562)
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at android.app.ActivityThread.access$1300(ActivityThread.java:155)
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1291)
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at android.os.Looper.loop(Looper.java:136)
07-29 02:18:34.805 29450-29450/com.gdms.host W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5426)
07-29 02:18:34.815 29450-29450/com.gdms.host W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
07-29 02:18:34.815 29450-29450/com.gdms.host W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
07-29 02:18:34.815 29450-29450/com.gdms.host W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
07-29 02:18:34.815 29450-29450/com.gdms.host W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
07-29 02:18:34.815 29450-29450/com.gdms.host W/System.err:     at dalvik.system.NativeStart.main(Native Method)

It says that this line is the problem:

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Do you know why this is happening? Thank you.

kkworden commented 7 years ago

Nevermind, I had accidentally installed a different plugin and I forgot to delete it. Sorry.