capacitor: Ionic + Capacitor - Cordova Plugins exception
Description of the problem:
Affected platform
- [ x] Android
- iOS
- electron
- web
OS of the development machine
- [x ] Windows
- macOS
- linux
Other information:
Capacitor version: 1.0.0
node version: 10.15.3 npm version: 6.9.0
Steps to reproduce: When I run my app, I see the following exceptions (and the plugins don’t work: AdMobFree and InAppPurchase v1)
V/Capacitor/Plugin: To native (Cordova plugin): callbackId: InAppBillingV31732914844, service: InAppBillingV3, action: init, actionArgs: []
W/System.err: java.lang.ClassNotFoundException: com.alexdisler.inapppurchases.InAppBillingV3
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at org.apache.cordova.PluginManager.instantiatePlugin(PluginManager.java:489)
at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169)
at org.apache.cordova.PluginManager.exec(PluginManager.java:122)
at com.getcapacitor.MessageHandler.callCordovaPluginMethod(MessageHandler.java:73)
at com.getcapacitor.MessageHandler.postMessage(MessageHandler.java:46)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:160)
at android.os.HandlerThread.run(HandlerThread.java:65)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 12 more
Suppressed: java.io.IOException: No original dex files found for dex location
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5798)
at android.app.ActivityThread.access$1100(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/System.out: Error adding plugin com.alexdisler.inapppurchases.InAppBillingV3.
E/Capacitor: Post message error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171)
at org.apache.cordova.PluginManager.exec(PluginManager.java:122)
at com.getcapacitor.MessageHandler.callCordovaPluginMethod(MessageHandler.java:73)
at com.getcapacitor.MessageHandler.postMessage(MessageHandler.java:46)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:160)
at android.os.HandlerThread.run(HandlerThread.java:65)
V/Capacitor: callback: -1, pluginId: Console, methodName: log, methodData: {"level":"error","message":"ERROR {}"}
E/Capacitor/Plugin/Console: ERROR {}
E/Capacitor: Unable to inject Capacitor, Plugins won't work
Link to sample project:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (5 by maintainers)
@tgangso @orhan-swe did you guys find a way to add a billing key manually? I am struggling to find a solution myself
Variables and hooks don’t work on Capacitor, you have to check the plugin and see what they do with the variable/hook and do it yourself manually.
This is very, very sad.
BTW it is horrible to close an issue because you can’t test it. the issue exists and it should remain open otherwise proven it is not a real issue. There are exceptions when working with those plugins as you can see above.
Also curious how to add the billing key manually.
Hi @theunreal Did you find out how to add the variable BILLING_KEY manually when installing the plugin in capacitor project with only “npm install cc.fovea.cordova.purchase” ?