sitefinitysteve / nativescript-google-analytics

Apache License 2.0
23 stars 14 forks source link

Failed to apply plugin [id 'com.google.gms.google-services'] when used together with nativescript-push-notifications #29

Closed ignaciolarranaga closed 7 years ago

ignaciolarranaga commented 7 years ago

Hi I noticed both plugins generate some conflict when used together, and not sure which one is the best to log the issue or the most appropriate to make and adjustment/suggestion ?

Sorry for the inconvenience if the problem is related to the push-notifications plugin.

The problem as the title says is the version of google-services. For reproduction:

tns create Sample --ng
cd Sample
tns plugin add nativescript-google-analytics
tns plugin add nativescript-push-notifications
cp ...../google-services.json app/App_Resources/Android/
tns run android

and you will get:

What went wrong:
A problem occurred evaluating root project 'Sample'.
> Failed to apply plugin [id 'com.google.gms.google-services']
   > For input string: "+"

Here is the complete trace:

MacBook-Pro-de-Ignacio:tmp ignacio$ tns create Sample --ng
Installing  tns-template-hello-world-ng
/private/tmp/Sample
└─┬ tns-template-hello-world-ng@2.5.0 
  ├── @angular/common@2.4.3 
  ├── @angular/compiler@2.4.3 
  ├── @angular/core@2.4.3 
  ├── @angular/forms@2.4.3 
  ├── @angular/http@2.4.3 
  ├── @angular/platform-browser@2.4.3 
  ├── @angular/platform-browser-dynamic@2.4.3 
  ├── @angular/router@3.4.3 
  ├─┬ nativescript-angular@1.4.0 
  │ ├── nativescript-intl@0.0.10 
  │ ├── parse5@1.3.2 
  │ ├── punycode@1.3.2 
  │ ├── querystring@0.2.0 
  │ ├── url@0.10.3 
  │ └── UNMET PEER DEPENDENCY zone.js@^0.7.2
  ├── nativescript-theme-core@1.0.2 
  ├── reflect-metadata@0.1.9 
  ├─┬ rxjs@5.0.3 
  │ └── symbol-observable@1.0.4 
  └── UNMET PEER DEPENDENCY zone.js@^0.7.2

/private/tmp/Sample
└─┬ tns-core-modules@2.5.0 
  └── tns-core-modules-widgets@2.5.0 

> nativescript-dev-android-snapshot@0.0.6 postinstall /private/tmp/Sample/node_modules/nativescript-dev-android-snapshot
> node postinstall.js

> nativescript-dev-typescript@0.3.7 postinstall /private/tmp/Sample/node_modules/nativescript-dev-typescript
> node postinstall.js

Project already targets TypeScript ~2.1.0
/private/tmp/Sample
├─┬ nativescript-dev-android-snapshot@0.0.6 
│ ├── adm-zip@0.4.7 
│ ├─┬ nativescript-hook@0.2.1 
│ │ ├─┬ glob@6.0.4 
│ │ │ ├─┬ inflight@1.0.6 
│ │ │ │ └── wrappy@1.0.2 
│ │ │ ├── inherits@2.0.3 
│ │ │ ├─┬ minimatch@3.0.3 
│ │ │ │ └─┬ brace-expansion@1.1.6 
│ │ │ │   ├── balanced-match@0.4.2 
│ │ │ │   └── concat-map@0.0.1 
│ │ │ ├── once@1.4.0 
│ │ │ └── path-is-absolute@1.0.1 
│ │ └─┬ mkdirp@0.5.1 
│ │   └── minimist@0.0.8 
│ ├── semver@5.3.0 
│ └── shelljs@0.6.1 
├── nativescript-dev-typescript@0.3.7 
├── typescript@2.1.6 
└── zone.js@0.7.7 

Project Sample was successfully created.

MacBook-Pro-de-Ignacio:tmp ignacio$ cd Sample/
MacBook-Pro-de-Ignacio:Sample ignacio$ tns plugin add nativescript-google-analytics
/private/tmp/Sample
└── nativescript-google-analytics@0.3.5 

Successfully installed plugin nativescript-google-analytics.
MacBook-Pro-de-Ignacio:Sample ignacio$ tns plugin add nativescript-push-notifications

> nativescript-push-notifications@0.1.2 postinstall /private/tmp/Sample/node_modules/nativescript-push-notifications
> node postinstall.js

/private/tmp/Sample
└── nativescript-push-notifications@0.1.2 

Successfully installed plugin nativescript-push-notifications.
MacBook-Pro-de-Ignacio:Sample ignacio$ cp /Users/ignacio/Workspaces/DuenoVende/hezea-app/app/App_Resources/Android/google-services.json app/App_Resources/Android/
MacBook-Pro-de-Ignacio:Sample ignacio$ tns run android
Copying template files...
  ◞ Installing tns-androidInstalling  tns-android
  ◝ Installing tns-android/private/tmp/Sample
└── tns-android@2.5.0 

  ◠ Installing tns-android/private/tmp/Sample
└─┬ babel-traverse@6.23.1 
  ├─┬ babel-code-frame@6.22.0 
  │ ├─┬ chalk@1.1.3 
  │ │ ├── ansi-styles@2.2.1 
  │ │ ├── escape-string-regexp@1.0.5 
  │ │ ├─┬ has-ansi@2.0.0 
  │ │ │ └── ansi-regex@2.1.1 
  │ │ ├── strip-ansi@3.0.1 
  │ │ └── supports-color@2.0.0 
  │ ├── esutils@2.0.2 
  │ └── js-tokens@3.0.1 
  ├── babel-messages@6.23.0 
  ├─┬ babel-runtime@6.23.0 
  │ ├── core-js@2.4.1 
  │ └── regenerator-runtime@0.10.1 
  ├─┬ babel-types@6.23.0 
  │ └── to-fast-properties@1.0.2 
  ├── babylon@6.15.0 
  ├─┬ debug@2.6.1 
  │ └── ms@0.7.2 
  ├── globals@9.15.0 
  ├─┬ invariant@2.2.2 
  │ └── loose-envify@1.3.1 
  └── lodash@4.17.4 

  ◜ Installing tns-android/private/tmp/Sample
└── babel-types@6.23.0 

  ◜ Installing tns-android/private/tmp/Sample
└── babylon@6.15.0 

  ◜ Installing tns-android/private/tmp/Sample
└── lazy@1.0.11 

Project successfully created.
Executing before-prepare hook from /private/tmp/Sample/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /private/tmp/Sample/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.1.6
Executing before-prepare hook from /private/tmp/Sample/hooks/before-prepare/nativescript-push-notifications.js
Preparing project...

:config phase:  createDefaultIncludeFiles

:config phase:  copyAarDependencies

:config phase:  addAarDependencies
    +adding dependency: /private/tmp/Sample/platforms/android/libs/aar/pushplugin.aar
    +adding dependency: /private/tmp/Sample/platforms/android/libs/aar/widgets-release.aar
google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.
please apply google-services plugin at the bottom of the build file.
Incremental java compilation is an incubating feature.
:asbg:clean UP-TO-DATE
:deleteMetadata
:deleteFlavors
:deleteConfigurations UP-TO-DATE
:clean

BUILD SUCCESSFUL

Total time: 6.062 secs

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html
Successfully prepared plugin nativescript-angular for android.
Successfully prepared plugin nativescript-intl for android.
Successfully prepared plugin nativescript-google-analytics for android.
Successfully prepared plugin nativescript-push-notifications for android.
Successfully prepared plugin nativescript-theme-core for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Project successfully prepared (android)
Executing after-prepare hook from /private/tmp/Sample/hooks/after-prepare/nativescript-dev-android-snapshot.js
Searching for devices...
Building project...

:config phase:  createDefaultIncludeFiles
    +found plugins: nativescript-google-analytics
Renaming plugin directory to flavor name: /private/tmp/Sample/platforms/android/src/nativescript-google-analytics -> /private/tmp/Sample/platforms/android/src/F0
    +found plugins: nativescript-push-notifications
Renaming plugin directory to flavor name: /private/tmp/Sample/platforms/android/src/nativescript-push-notifications -> /private/tmp/Sample/platforms/android/src/F1
    +found plugins: tns-core-modules-widgets
     + creating include.gradle file for /private/tmp/Sample/platforms/android/configurations/tns-core-modules-widgets
Renaming plugin directory to flavor name: /private/tmp/Sample/platforms/android/src/tns-core-modules-widgets -> /private/tmp/Sample/platforms/android/src/F2

:config phase:  createPluginsConfigFile
     Creating product flavors include.gradle file in /private/tmp/Sample/platforms/android/configurations folder...

:config phase:  pluginExtend
    +applying configuration from: /private/tmp/Sample/platforms/android/configurations/include.gradle
    +applying configuration from: /private/tmp/Sample/platforms/android/configurations/nativescript-google-analytics/include.gradle
    +applying configuration from: /private/tmp/Sample/platforms/android/configurations/nativescript-push-notifications/include.gradle
    +applying configuration from: /private/tmp/Sample/platforms/android/configurations/tns-core-modules-widgets/include.gradle

:config phase:  copyAarDependencies

:config phase:  addAarDependencies
    +adding dependency: /private/tmp/Sample/platforms/android/libs/aar/pushplugin.aar
    +adding dependency: /private/tmp/Sample/platforms/android/libs/aar/widgets-release.aar

FAILURE: Build failed with an exception.

* Where:
Build file '/private/tmp/Sample/platforms/android/build.gradle' line: 802

* What went wrong:
A problem occurred evaluating root project 'Sample'.
> Failed to apply plugin [id 'com.google.gms.google-services']
   > For input string: "+"

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.916 secs
Command /private/tmp/Sample/platforms/android/gradlew failed with exit code 1
# run android

┌───────────────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Usage                         │ Synopsis                                                                                                           │
│ Run on all connected devices  │ $ tns run android [--key-store-path <File Path> --key-store-password <Password> --key-store-alias <Name> --key     │
│ and running emulators         │ -store-alias-password <Password>] [--release] [--justlaunch]                                                       │
│ Run on a selected connected   │ $ tns run android --device <Device ID> [--key-store-path <File Path> --key-store-password <Password> --key-store   │
│ device or running emulator    │ -alias <Name> --key-store-alias-password <Password>] [--release] [--justlaunch]                                    │
│ Start an emulator and run the │ $ tns run android --emulator [<Emulator Options>] [--key-store-path <File Path> --key-store-password <Password> -  │
│ app inside it                 │ -key-store-alias <Name> --key-store-alias-password <Password>] [--release] [--justlaunch]                          │
└───────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Runs your project on a connected Android device or in a native Android emulator, if configured. This is shorthand for prepare, build and deploy. While your app is running, prints the output from the application in the console and watches for changes in your code. Once a change is detected, it synchronizes the change with all selected devices and restarts/refreshes the application.

### Options

    * --no-watch - If set, changes in your code will not be reflected during the execution of this command.
    * --device - Specifies a connected device/emulator on which to run the app.
    * --emulator - If set, runs the app in a native emulator for the target platform, if configured. When set, you can also set any other valid combination of emulator options as listed by $ tns help emulate android.
    * --release - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the --key-store-* options.
    * --key-store-path - Specifies the file path to the keystore file (P12) which you want to use to code sign your APK. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-password - Provides the password for the keystore file specified with --key-store-path. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-alias - Provides the alias for the keystore file specified with --key-store-path. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --key-store-alias-password - Provides the password for the alias specified with --key-store-alias-password. You can use the --key-store-* options along with --release to produce a signed release build. You need to specify all --key-store-* options.
    * --justlaunch - If set, does not print the application output in the console.
    * --clean - If set, forces rebuilding the native application.

### Attributes

    * <Device ID> is the index or name of the target device as listed by $ tns device android
    * <Emulator Options> is any valid combination of options as listed by $ tns help emulate android

Sending exception report (press Ctrl+C to stop).....

I think the problem might be related to this, but just guessing:

:config phase:  addAarDependencies
    +adding dependency: /private/tmp/Sample/platforms/android/libs/aar/pushplugin.aar
    +adding dependency: /private/tmp/Sample/platforms/android/libs/aar/widgets-release.aar
google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.
please apply google-services plugin at the bottom of the build file.
ignaciolarranaga commented 7 years ago

Link to the push-plugin where I also reported the issue: https://github.com/NativeScript/push-plugin/issues/101

ignaciolarranaga commented 7 years ago

The problem seems to be related to this dependencies in the include.gradle:

dependencies {
    // [START gms_compile]
    def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '+'
    compile "com.google.android.gms:play-services-analytics:+"
    // [END gms_compile]
}

I noticed if + is replaced by a concrete version (i.e. 10.2.0) the problem does not happen. Is this an option ?

sitefinitysteve commented 7 years ago

Not really, we've had a bunch of PRs and issues specifically related to the gradle def to make it play nice with other plugins.

I would put this back on the push plugin or back to the NS Android runtime repo to globally come up with a solution to this.

On Feb 16, 2017 6:14 AM, "Ignacio Larrañaga" notifications@github.com wrote:

The problem seems to be related to this dependencies in the include.gradle:

dependencies { // [START gms_compile] def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '+' compile "com.google.android.gms:play-services-analytics:+" // [END gms_compile] }

I noticed if + is replaced by a concrete version (i.e. 10.2.0) the problem does not happen. Is this an option ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sitefinitysteve/nativescript-google-analytics/issues/29#issuecomment-280303403, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeI6AumltZpLZa06yIEyhiX_5bOQ_eGks5rdC-pgaJpZM4MC0zK .

ignaciolarranaga commented 7 years ago

Is possible to define googlePlayServicesVersion somewhere in the project to be replaced it here and workaround the problem ? (like in the package.json or something ?)

sitefinitysteve commented 7 years ago

Don't think so, would be a good workaround to suggest to turn though. That definition would override what's set in the plugins added.

But you'd have to go to the ns core team to request

On Feb 16, 2017 6:28 AM, "Ignacio Larrañaga" notifications@github.com wrote:

Is possible to define googlePlayServicesVersion somewhere in the project to be replaced it here and workaround the problem ? (like in the package.json or something ?)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sitefinitysteve/nativescript-google-analytics/issues/29#issuecomment-280306021, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeI6FVhsieK-qbKcQhvk1mE_rtkKb3cks5rdDLQgaJpZM4MC0zK .

ignaciolarranaga commented 7 years ago

Thanks, I created a temporary workaround in a fork while try some other alternatives. Please let me know if you have some update on your side.

https://github.com/ignaciolarranaga/nativescript-google-analytics/commit/b44a0d928bbab64e0db912ea99db7ca1e1dca3df

ignaciolarranaga commented 7 years ago

Don't you prefer to keep the issue open till we get some final solution ?, because indeed the usage of both plugins together will produce an error. We can adjust the title if preferred, something like: Compatibility problem between nativescript-google-analytics and nativescript-push-notifications.

sitefinitysteve commented 7 years ago

Well I mean... there's nothing that I can do to resolve it, I think the current state reflects compatibility between this plugin and firebase. The issue really lies with the notification plugin itself or the core to come up with some way to manage these shared dependancies.

I'm not by any means saying this is not an issue, but this is just the wrong repo for it, no?

ignaciolarranaga commented 7 years ago

Thanks, I reopen the issue on their repo, if you want to make a comment I think will be appreciated.