ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚑️
https://capacitorjs.com
MIT License
12.08k stars 1k forks source link

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

Open bazuka5801 opened 4 years ago

bazuka5801 commented 4 years ago

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

ArturoBurela commented 4 years ago

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

bazuka5801 commented 4 years ago

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

ArturoBurela commented 4 years ago

@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.

peterlai107 commented 4 years ago

same problem too

alyleite commented 4 years ago

same problem

caseyrodgers commented 4 years ago

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

felipecaparelli commented 4 years ago

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.

masterbd commented 4 years ago

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.

marangonijunior commented 4 years ago

Same problem here.

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

joecodino commented 4 years ago

same issue, just following this: https://ionicframework.com/docs/native/firebase-crash

kharrak commented 4 years ago

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.
jorisbertomeu commented 4 years ago

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
robertnaquila commented 4 years ago

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?

wnabil commented 4 years ago

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

robertnaquila commented 4 years ago

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`

bazuka5801 commented 4 years ago

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

sandeepsingh-web commented 3 years ago

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...

bazuka5801 commented 3 years ago

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

tomavic commented 3 years ago

@sandeepsingh-web I can't afford this solution as playing in node_modules doesn't really help !!!

tomavic commented 3 years ago

Same problem here.

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

Yes I do have the same issue and I initially ran out from cordova because of errors like thay, and I found capacitor has problems with Firebase too.

Why is there isn't staright forward official plugin for firebase that works well without any issues!

bazuka5801 commented 3 years ago

@tomavic I want to write plugin for firebase, but I'am looking helpers to improve and test plugin

tomavic commented 3 years ago

@bazuka5801 I created cordova apple wallet plugin and I do care for break changes and keeping a stable version to run for all, because I am from the people who suffer from the major conflicts.

But since I started using cordova 5 years ago, I am always suffering from firebase plugin. And when firebasex plugin came out i thought that conflicts will end. But i was wrong. πŸ₯Ί

bazuka5801 commented 3 years ago

I want to rewrite plugin on Swift, Kotlin, to support firebase

tomavic commented 3 years ago

@bazuka5801 I am in. Contact me to arrange it.

imhoffd commented 3 years ago

@bazuka5801 @tomavic There are a variety of Firebase plugins available in the Capacitor Community that you could try: https://github.com/capacitor-community/?q=firebase&type=&language=

If you find issues, I'm sure the authors would be happy to look at PRs. Good luck 😁

tomavic commented 3 years ago

@dwieeb hi Dan

That's not the problem. The problem is that I have to dig into The plugin code to comment out some lines and play with some native code as well, just to disable a feature that I don't even use it!!

Gor how long should I keep do this stuff to keep my build successful for both platforms!

fsmalaquias commented 3 years ago

I've faced the same problem. I'm migrating an app from Ionic 3 to Ionic 5. So I did the following

cordova plugin remove cordova-plugin-firebasex npx cap sync

In Android Studio:

  1. Menu: Build -> Clean Project

In this step Gradle synced and I had no errors.

So I did:

cordova plugin add cordova-plugin-firebasex npx cap sync

So i had:

`Executing tasks: [clean] in project /Users/fsmalaquias/projects/capacitor/vistorias-saphyr/android

AGPBI: {"kind":"warning","text":"Using flatDirs should be avoided because it doesn't support any meta-data formats.\nCurrently detected usages:\n- repository flatDir used in: project ':app', project ':capacitor-cordova-android-plugins'","sources":[{}]} AGPBI: {"kind":"warning","text":"Please remove usages of jcenter() Maven repository from your build scripts and migrate your build to other Maven repositories.\nThis repository is deprecated and it will be shut down in the future.\nSee http://developer.android.com/r/tools/jcenter-end-of-service for more information.\nCurrently detected usages in: root project 'android', project ':app', project ':capacitor-android', ...","sources":[{}]}

Task :clean UP-TO-DATE Task :app:clean UP-TO-DATE Task :capacitor-android:clean UP-TO-DATE Task :capacitor-cordova-android-plugins:clean UP-TO-DATE

BUILD SUCCESSFUL in 252ms 4 actionable tasks: 4 up-to-date

Build Analyzer results available`

With some warnings but it 's ok

fsmalaquias commented 3 years ago

I've faced the same problem. I'm migrating an app from Ionic 3 to Ionic 5. So I did the following

cordova plugin remove cordova-plugin-firebasex npx cap sync

In Android Studio:

  1. Menu: Build -> Clean Project

In this step Gradle synced and I had no errors.

So I did:

cordova plugin add cordova-plugin-firebasex npx cap sync

So i had:

`Executing tasks: [clean] in project /Users/fsmalaquias/projects/capacitor/vistorias-saphyr/android

AGPBI: {"kind":"warning","text":"Using flatDirs should be avoided because it doesn't support any meta-data formats.\nCurrently detected usages:\n- repository flatDir used in: project ':app', project ':capacitor-cordova-android-plugins'","sources":[{}]} AGPBI: {"kind":"warning","text":"Please remove usages of jcenter() Maven repository from your build scripts and migrate your build to other Maven repositories.\nThis repository is deprecated and it will be shut down in the future.\nSee http://developer.android.com/r/tools/jcenter-end-of-service for more information.\nCurrently detected usages in: root project 'android', project ':app', project ':capacitor-android', ...","sources":[{}]}

Task :clean UP-TO-DATE Task :app:clean UP-TO-DATE Task :capacitor-android:clean UP-TO-DATE Task :capacitor-cordova-android-plugins:clean UP-TO-DATE

BUILD SUCCESSFUL in 252ms 4 actionable tasks: 4 up-to-date

Build Analyzer results available`

With some warnings but it 's ok

wajeshubham commented 3 years ago

I've faced the same problem. I'm migrating an app from Ionic 3 to Ionic 5. So I did the following cordova plugin remove cordova-plugin-firebasex npx cap sync In Android Studio:

  1. Menu: Build -> Clean Project

In this step Gradle synced and I had no errors. So I did: cordova plugin add cordova-plugin-firebasex npx cap sync So i had: Executing tasks: [clean] in project /Users/fsmalaquias/projects/capacitor/vistorias-saphyr/android AGPBI: {"kind":"warning","text":"Using flatDirs should be avoided because it doesn't support any meta-data formats.\nCurrently detected usages:\n- repository flatDir used in: project ':app', project ':capacitor-cordova-android-plugins'","sources":[{}]} AGPBI: {"kind":"warning","text":"Please remove usages ofjcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.\nThis repository is deprecated and it will be shut down in the future.\nSee http://developer.android.com/r/tools/jcenter-end-of-service for more information.\nCurrently detected usages in: root project 'android', project ':app', project ':capacitor-android', ...","sources":[{}]}

Task :clean UP-TO-DATE Task :app:clean UP-TO-DATE Task :capacitor-android:clean UP-TO-DATE Task :capacitor-cordova-android-plugins:clean UP-TO-DATE

BUILD SUCCESSFUL in 252ms 4 actionable tasks: 4 up-to-date Build Analyzer results available` With some warnings but it 's ok

Same problem after integrating FB login

bartuff commented 3 years ago

Another one that points to this problem, performing an installation with the latest versions and following the documentation step by step. Without adding any additional code, just adding FirebaseX (Capacitor) or Firebase or Firebase-authentication, this error appears.

eliasws commented 3 years ago

Any updates on this?

iKrishnaSahu commented 3 years ago

Any updates on this?

tomavic commented 3 years ago

That's the bad of taking a serious decision like that and depend on such a thing that is supposed to has a community!!

I don't know for how long people will suffer from such plugins and breaking changes!

Unlucky those who have a broken app right now. I don't know what to say!

eeschiavo commented 2 years ago

Any updates on this?

babarshamsi commented 2 years ago

i have not downgraded the gradle version 6.1.1 But what i did is that:

I removed these lines from build.gradle file apply plugin: 'com.novoda.bintray-release' & classpath 'com.novoda:bintray-release:0.9.1'

The Issue just gone like Boom !!

I think this Bintray Dependencies just conflicting behind the scene.

IgorSavchenko90 commented 2 years ago

Any updates on this?

diegopavani1 commented 2 years ago

Fork with fix: https://www.npmjs.com/package/cordova-plugin-firebasex-fix

npm i cordova-plugin-firebasex-fix