2

I am using ionic 4 and trying to run on an android device after adding FCM(https://beta.ionicframework.com/docs/native/fcm) to the app to support push notification. However, I am not able to get a successful build as soon as I added the FCM native plugin to the app. it gave me the following error.

Could not find com.android.tools:common:25.5.0-alpha-preview-02. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/common/25.5.0-alpha-preview-02/common-25.5.0-alpha-preview-02.pom https://jcenter.bintray.com/com/android/tools/common/25.5.0-alpha-preview-02/common-25.5.0-alpha-preview-02.jar https://repo.maven.apache.org/maven2/com/android/tools/common/25.5.0-alpha-preview-02/common-25.5.0-alpha-preview-02.pom https://repo.maven.apache.org/maven2/com/android/tools/common/25.5.0-alpha-preview-02/common-25.5.0-alpha-preview-02.jar Required by: unspecified:unspecified:unspecified > com.android.tools.build:gradle:2.5.0-alpha-preview-02 > com.android.tools.build:gradle-core:2.5.0-alpha-preview-02 > com.android.tools.build:builder:2.5.0-alpha-preview-02 unspecified:unspecified:unspecified > com.android.tools.build:gradle:2.5.0-alpha-preview-02 > com.android.tools.build:gradle-core:2.5.0-alpha-preview-02 > com.android.tools.build:builder:2.5.0-alpha-preview-02 > com.android.tools.build:manifest-merger:25.5.0-alpha-preview-02 unspecified:unspecified:unspecified > com.android.tools.build:gradle:2.5.0-alpha-preview-02 > com.android.tools.build:gradle-core:2.5.0-alpha-preview-02 > com.android.tools.build:builder:2.5.0-alpha-preview-02 > com.android.tools.ddms:ddmlib:25.5.0-alpha-preview-02 unspecified:unspecified:unspecified > com.android.tools.build:gradle:2.5.0-alpha-preview-02 > com.android.tools.build:gradle-core:2.5.0-alpha-preview-02 > com.android.tools.build:builder:2.5.0-alpha-preview-02 > com.android.tools.analytics-library:shared:25.5.0-alpha-preview-02 unspecified:unspecified:unspecified > com.android.tools.build:gradle:2.5.0-alpha-preview-02 > com.android.tools.build:gradle-core:2.5.0-alpha-preview-02 > com.android.tools.build:builder:2.5.0-alpha-preview-02 > com.android.tools.analytics-library:tracker:25.5.0-alpha-preview-02 unspecified:unspecified:unspecified > com.android.tools.build:gradle:2.5.0-alpha-preview-02 > com.android.tools.build:gradle-core:2.5.0-alpha-preview-02 > com.android.tools.build:builder:2.5.0-alpha-preview-02 > com.android.tools:sdklib:25.5.0-alpha-preview-02 > com.android.tools.layoutlib:layoutlib-api:25.5.0-alpha-preview-02 unspecified:unspecified:unspecified > com.android.tools.build:gradle:2.5.0-alpha-preview-02 > com.android.tools.build:gradle-core:2.5.0-alpha-preview-02 > com.android.tools.build:builder:2.5.0-alpha-preview-02 > com.android.tools:sdklib:25.5.0-alpha-preview-02 > com.android.tools:dvlib:25.5.0-alpha-preview-02 unspecified:unspecified:unspecified > com.android.tools.build:gradle:2.5.0-alpha-preview-02 > com.android.tools.build:gradle-core:2.5.0-alpha-preview-02 > com.android.tools.build:builder:2.5.0-alpha-preview-02 > com.android.tools:sdklib:25.5.0-alpha-preview-02 > com.android.tools:repository:25.5.0-alpha-preview-02

I have been searching for an answer for the past 2 days and have tried changing parameters in the build.gradle (Cannot run existing Android Project com.android.tools:common:25.3.3) but have no success. Please help if any one here have any idea how to resolve it. Thanks a lot.

Tobias Wilfert
  • 919
  • 3
  • 14
  • 26
Bochey1314
  • 61
  • 3

2 Answers2

4

Thank God, I found a solution, go to platforms/android/cordova-plugin-firebase/***.gradle... then change

this.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

to

buildscript {
    repositories {
        maven { url "https://maven.google.com" }
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:+'
    }
}

I hope that it helps you, tell me if it works.....

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • make, cordova clean and cordova prepare before cordova build android – Christian Rodriguez Dec 09 '18 at 02:16
  • Good for you. However, It didn't work for me. I am still getting the same error. This drives me crazy. Thank you again for your help. – Bochey1314 Dec 09 '18 at 03:01
  • Hi, this answer did fix it for me aswell. What you could maybe try still @Bochey1314 is to first do "ionic cordova platform remove android", then add it back with "ionic cordova platform add android", then make the edits suggested. Just to make sure there is nothing stale in the android build. – Juha Kervinen Dec 09 '18 at 04:20
  • I already did that last night. but still getting the same issue. Btw, what version is your cordova-android? I am using 7.1.4 now. I m not sure if that's the issue. let me try it with 7.1.0 . – Bochey1314 Dec 09 '18 at 14:44
  • @Bochey1314 how did it go with cordova-android 7.1.0? I'm having the same issue in 7.1.1 & 7.1.4 – Marc Borni Dec 09 '18 at 15:07
  • and I don't think this answer is a "real" answer since plugin providers probably need to update their plugins for the error to dissapear – Marc Borni Dec 09 '18 at 15:09
  • 1
    i am using cordova 8.. try to change your build:gradle version, go to android/build.gradle and change by classpath 'com.android.tools.build:gradle:3.2.1' – Christian Rodriguez Dec 09 '18 at 17:07
  • I tried that as well but didn't work. Something is acting up in my ionic4 copy. Don't really know what it was. I finally fixed it using your solution by using a complete new copy. Thanks for your help – Bochey1314 Dec 09 '18 at 21:28
  • 1
    @MarcBorni Nope. didn't work. I tried to downgraded to 7.1.0 but it was changed back to 7.1.4 as soon as I did a build again. – Bochey1314 Dec 10 '18 at 23:30
0

Finally, I was able to fix this issue with Christian rodrigue's solution using a fresh copy of the ionic4 template. It was a bit tedious and troublesome. But at least it is working now. So basically, I use ionic start to get a new copy of the template and then added this plugin right away to see if it works. After I confirm that it is working, I then moved all the business logic to the new copy. Something is acting up in my old copy. I don't know what the exact cause is. Hope this help if you got into a similar situation like mine.

One thing I noticed that this error comes back if I upgrade the gradle in Android studio. So avoid upgrading if it prompt for now.

Bochey1314
  • 61
  • 3