arnesson / cordova-plugin-firebase

Cordova plugin for Google Firebase
http://arnesson.github.io/cordova-plugin-firebase
MIT License
1.01k stars 1.56k forks source link

Android Build Error - Could not find com.android.tools:common:25.5.0-alpha-preview-02 #967

Open coyu1314 opened 5 years ago

coyu1314 commented 5 years ago

After adding this Firebase plugin to my ionic4(angular) app, I cannot get a successful android build with this ionic native plugin. My app built and ran fine without it. I am getting 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 answer for the past 2 days and have tried changing parameters in the build.gradle (https://stackoverflow.com/questions/53677823/cannot-run-existing-android-project-com-android-toolscommon25-3-3) but have no success. Please help if any one here how to resolve it. Thanks a lot.

jkervine commented 5 years ago

The answer by Christian Rodrigues in this stack overflow posting helped me to resolve the build error: https://stackoverflow.com/questions/53687611/android-fail-to-build-could-not-find-com-android-toolscommon25-5-0-alpha-pre

minion-kevin-pro commented 5 years ago

Is there any way to solve them? To automatically fix it?

BorntraegerMarc commented 5 years ago

since I get this error in my ionic pro automatic build I can't change that file. This plugin needs to resolve the issue so our automatic builds work again

coyu1314 commented 5 years ago

@jkervine I tried that already but didn't work for me. It drove me crazy now. Did you do anything in the outer build.grade(platform/android/build.gradle)?

coyu1314 commented 5 years ago

After trying again with the previous solution in stackoverflow, I didn't see the previous error when doing "ionic cordova run android --device" in the terminal(btw, I m still seeing the same error in Android studio when doing the File > Sync Project with Gradle File). However, it stop/terminate by itself when building half way without showing any error. As you can see below. Any clue?

cordova run android --device Android Studio project detected Preparing Firebase on Android ANDROID_HOME=/Users/symbp/Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home studio Subproject Path: CordovaLib Subproject Path: app spawn EACCES

oudj001 commented 5 years ago

Does someone already have a solution? Still having this error even with Christian Rodrigues' solution..

coyu1314 commented 5 years ago

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

jkervine commented 5 years ago

I would also suspect that it's a combination of plugin dependencies being missing with the current setup and then gradle caching the wrong state, event with the deps fixed. I've seen similar situation with native android projects where gradle just refuses to co-operate until everything is nuked from the orbit.

Borja4 commented 5 years ago

I had the same problem, to fix it, I had to install with the SDK manager the API level 25, update Google play services and Android SDK platform-tools besides the Android SDK Tools.

2018-12-10 a las 15 01 08

After doing that, I went to android-build.gradle in platforms/android/cordova-plugin-firebase folder and modify buildscript.repositories Object to add maven.url:

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