PeterStaev / nativescript-purchase

:moneybag: A NativeScript plugin for making in-app purchases!
Apache License 2.0
82 stars 28 forks source link

InAppBillingHelper is not a constructor #39

Closed dean-huczok closed 6 years ago

dean-huczok commented 6 years ago

Installed this plugin into a Nativescript Angular app, followed details on the in-depth tutorial but I keep getting the same error on init() and cannot go any further, no matter where in the app I place init() (whether in main.ts or inside a page's ngOnInit()).

JS: ERROR Error: Uncaught (in promise): TypeError: com.tangrainc.inappbilling.InAppBillingHelper is not a constructor JS: TypeError: com.tangrainc.inappbilling.InAppBillingHelper is not a constructor JS: at file:///data/data/myapp/files/app/tns_modules/nativescript-purchase/purchase.js:37:22

I've tried removing the plugin tns plugin remove nativescript-purchase and reinstalling it tns plugin add nativescript-purchase. Same error.

The plugin's .gradle file seems to compile when I run tns run android (also tried the --clean option but no dice), so I'm not sure why the JS compiler can't find the InAppBillingHelper class (also no errors or problems reported on VSCode).

Building project... Gradle build...

  • applying user-defined configuration from C:\path\to\myapp\app\App_Resources\Android\app.gradle
  • add include.gradle from C:\path\to\myapp\node_modules\nativescript-purchase\platforms\android\include.gradle

Can't find anyone with the same problem thru Google search, appreciate if anyone can shed some light on what is or could be happening here... thanks in advance :)

PeterStaev commented 6 years ago

Hey @dean-huczok , can you try to delete your node_modules and platforms folders and then running your app? Other than that I have no other ideas what might be causing this. Also what version of TNS are you using?

dean-huczok commented 6 years ago

Thanks @PeterStaev for the fast response!

I just deleted node_modules and platforms folders, then ran tns run android and the build halted at this error:

java.io.IOException: Cannot run program "C:\path-to-android-sdk\build-tools\27.0.1\aapt.exe": CreateProcess error=5, Access is denied

I get these permissions problems now and then on my Windows 10 machine, ughh, usually in %APPDATA% though...

Anyway I simply changed permissions for the Android SDK build-tools executable aapt.exe and now my app is compiling properly without the original InAppBillingHelper is not a constructor error.

Thanks heaps, looks like it's case closed! 👍