Capacitor: bug: gradle add dependency to some lib project instead of app

Created on 3 Aug 2020  ·  18Comments  ·  Source: ionic-team/capacitor

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 2.4.0
  @capacitor/core: 2.4.0
  @capacitor/android: 2.4.0
  @capacitor/electron: 2.4.0
  @capacitor/ios: 2.4.0

Installed Dependencies:

  @capacitor/ios not installed
  @capacitor/cli 2.4.0
  @capacitor/core 2.4.0
  @capacitor/android 2.4.0
  @capacitor/electron not installed

[success] Android looking great! 👌

Platform(s)


Android

Current Behavior


yarn add cordova-plugin-firebasex
npx cap sync android
npx cap open android -> return error

Applying the Firebase Crashlytics plugin to a library project is unsupported.
It should only be applied to the application module of your project to enable automatic upload of obfuscation mapping files for your application.

Expected Behavior


npm install cordova-plugin-firebasex
npx cap sync android
build app -> sucessful build

Code Reproduction


GitHub

Other Technical Details

npx cap open android output: error in android studio

Additional Context

android

Most helpful comment

Is there any way to just make my code compile? I need to complete the migration. If you can suggest just a workaround I'll be glad... at least for a while. I've migrated to the capacitor because the File API doesn't work as expected.

All 18 comments

I'm not sure if this is a capacitor or ionic-native problem, but this issue may be a duplicate of https://github.com/ionic-team/ionic-native/issues/3484

@ArturoBurela May be, but why capacitor add dependencies to some library project instead of application?

@ArturoBurela May be, but why capacitor add dependencies to some library project instead of application?

I have no idea, I faced the same issue last week and found these two issues on Github.

same problem too

same problem

Same issue for me trying move from Cordova to Capacitor. No problems in Cordova.

Is there any way to just make my code compile? I need to complete the migration. If you can suggest just a workaround I'll be glad... at least for a while. I've migrated to the capacitor because the File API doesn't work as expected.

Count me in for a solution to this. I love the firebaseX plugin, as I've worked with it on V3 apps, but on V5 with Capacitor is not working at all.

Same problem here.

Failed to apply plugin [class 'com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsPlugin']

same issue
Gradle 5.6.4
capacitor ^2.4.1
after ionic cap sync
capacitor.build.gradle

dependencies {
    ...
    implementation "com.google.firebase:firebase-crashalytics:17.5.+"
}
apply from '.../node_modules/cordova-plugin-firebase-crash/src/android/build.gradle'

during gradle bundleRelease
```
A problem occurred evaluating script.

Failed to apply plugin [class 'com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsPlugin']
Applying the Firebase Crashlytics plugin to a library project is unsupported. It should only be applied to the application module of your project to enable automatic upload of obfuscation mapping files for your application.

Same issue here too, starting from ionic blank app using Capacitor@latest and firebasex cordova plugin@latest+firebasex ionic native@latest ...

$> ionic info

Ionic:

   Ionic CLI                     : 6.11.8 (/Users/jorisbertomeu/.nvm/versions/node/v14.10.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.3.3
   @angular-devkit/build-angular : 0.1000.8
   @angular-devkit/schematics    : 10.0.8
   @angular/cli                  : 10.0.8
   @ionic/angular-toolkit        : 2.3.3

Capacitor:

   Capacitor CLI   : 2.4.1
   @capacitor/core : 2.4.1

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v14.10.0 (/Users/jorisbertomeu/.nvm/versions/node/v14.10.0/bin/node)
   npm    : 6.14.8
   OS     : macOS Big Sur

Same issue. Managed to build successfully in iOS but got this error in Android. Wondering if a possible workaround is to cut and paste all relevant dependencies into the app build.gradle instead of project library. I have not done so as I don't want to mess up the codes unnecessarily. Anyone has managed to find a solution or workaround?

I successfully managed to fix it doing the following

  1. go to file node_modules/cordova-plugin-firebasex/src/android/build.gradle and comment out line 10 and from line 20 to 36
    image

  2. go to android/build.gradle and add classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1' in the dependencies
    image

  3. go to android/app/capacitor.build.gradle and add the commented code from firebase plugin and change apply plugin to apply plugin: 'com.google.firebase.crashlytics'
    image

  4. copy google-services.json file to android/app
    image

  5. add accent color by creating color.xml file in android/app/main/res/values/
    image

  6. Build the project

Source: https://firebase.google.com/docs/crashlytics/get-started?platform=android

Project setup works but build failed

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':capacitor-cordova-android-plugins:processDebugGoogleServices'.

File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/nullnull/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/debug/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/nullnullDebug/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/nullnull/debug/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/debug/nullnull/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/google-services.json`

Project setup works but build failed

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':capacitor-cordova-android-plugins:processDebugGoogleServices'.

File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/nullnull/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/debug/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/nullnullDebug/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/nullnull/debug/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/src/debug/nullnull/google-services.json
/Users/robert.naquila/Codes/EngineersLogbook-BEv2/android/capacitor-cordova-android-plugins/google-services.json`

@robertnaquila
It's writing to you, what you forgot add google-services.json to project

I successfully managed to fix it doing the following

  1. go to file node_modules/cordova-plugin-firebasex/src/android/build.gradle and comment out line 10 and from line 20 to 36
    image
  2. go to android/build.gradle and add classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1' in the dependencies
    image
  3. go to android/app/capacitor.build.gradle and add the commented code from firebase plugin and change apply plugin to apply plugin: 'com.google.firebase.crashlytics'
    image
  4. copy google-services.json file to android/app
    image
  5. add accent color by creating color.xml file in android/app/main/res/values/
    image
  6. Build the project

Source: https://firebase.google.com/docs/crashlytics/get-started?platform=android
@wnabil it working for me. thank you so much bro...

@sandeepsingh-web Looking so good, can you make fork this repo with fix and publish package?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hansel03 picture Hansel03  ·  3Comments

MatanYadaev picture MatanYadaev  ·  3Comments

peterpeterparker picture peterpeterparker  ·  3Comments

Kepro picture Kepro  ·  3Comments

peterpeterparker picture peterpeterparker  ·  3Comments