NathanaelA / nativescript-permissions

Wraps up the entire Android 6 permissions system in a easy to use plugin.
MIT License
46 stars 22 forks source link

Fix global.android.support is not defined #41

Closed jeremypele closed 5 years ago

jeremypele commented 5 years ago

Guard clause

NathanaelA commented 5 years ago

Are you sure you needed global.android test ; global.android should exist on all Android platforms as the entire names space wasn't removed; only certain parts of the namespace were moved to androidx....

jeremypele commented 5 years ago

It crashes on bundling when this clause is not present. I'll ping the webpack team on their repo to cross the informations

NathanaelA commented 5 years ago

@jeremypele - That is really weird; when I tested it with the --env.snapshot --release it didn't need the extra check there. Can you tell me if you were using any other build flags? I was using TNS 6.02 and dev-webpack 1.01

I'm not opposed to the PR at all; just trying to understand the why? :grinning:

jeremypele commented 5 years ago

@NathanaelA You're right actually, it's bundles correctly with 'the fix" above but nativescript-geolocation is not working. Cause is cannot read property "app" of undefined, it points to your plugin but it's actually not at cause.. androidSupport is undefined then androidSupport.app is not reachable. My guess is that multiDexEnabled splits the plugins into chunks in a way that does not let access to android nor androidx. We can close that PR as the root of is issues lies somewhere else.

Thanks for your input 👍

jeremypele commented 5 years ago

To wrap up everything: finally found the source of the issue, your plugin was not at all at cause as predicted.

Issue was coming from the presence of

"android": {
        "v8Flags": "--expose_gc",
        "requireModules": ["nativescript-geolocation"]
    }

in src/package.json

The requireModules mess with the whole snapshot compilation. Thanks for the support, letting this note as a trace for anyone facing the same issue

https://github.com/NativeScript/nativescript-dev-webpack/issues/1018 https://github.com/NativeScript/nativescript-geolocation/issues/234