Ionic Build throws the following error: “could not find any matches for com.android.tools.build:gradle:+”

北城以北 提交于 2019-12-04 16:59:07
cordova plugin remove cordova-plugin-fcm
cordova plugin add cordova-plugin-fcm

In platforms> android> cordova-plugin-fcm> xxxxx-FCMPlugin.gradle

dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.2.0'
}

In plugins> cordova-plugin-fcm> plugin.xml

 <framework src="com.google.firebase:firebase-core:+" />
 <framework src="com.google.firebase:firebase-messaging:+" />

In platforms> android> project.properties

com.google.android.gms:play-services-location:11.4.2
com.google.firebase:firebase-core:11.4.2
com.google.firebase:firebase-messaging:11.4.2

finally, build ionic cordova build android

source here enter link description here

Comment out these lines in the FCMPlugin.gradle file (inside /plugins/cordova-plugin-fcm/src/android).

// classpath 'com.google.gms:google-services:3.0.0'
// apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Then change the plugin.xml of the FCM plugin to use a different version, in my situation 11.8.0. (inside /plugins/cordova-plugin-fcm/)

<framework src="com.google.firebase:firebase-core:11.8.0" />
<framework src="com.google.firebase:firebase-messaging:11.8.0" />

Now, remove en add the android platform again, so the changes will have affect. The next step is to just do ionic cordova run android

Based on @Adexe Rivera answer, I tried uninstalling and reinstalling the push notification plugin. Since the last version of the plugin requires the cordova-android package version to be >=7.0.0 I first uninstalled the android platform:

ionic cordova platform rm android

and installed it again but specifying that I wanted the latest cordova-android version available:

ionic cordova platform add android@latest.

After that, I added the push plugin again, specifying the SENDER_ID variable:

ionic cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXXXXX" and tried to build again.

This raised another error related to conflicting minSdkVersions. Doing some research it seems like another plugin, browsertab, specifies the minSdkVersion and it overrides the settings on the config.xml file at root folder. I changed that on the file created on root/platforms/android/cordova-plugin-browsertab so it matched the minSdkVersion I wanted (21) and finally it worked.

Hope this helps somebody.

Based on the answer of @Kevin Dias, I searched among my plugins the string 'com.android.tools.build:gradle:+', which in my case was in the plugin phonegap-plugin-push so what I did was:

ionic cordova platform remove android
ionic cordova platform add android
ionic cordova plugin remove phonegap-plugin-push
ionic cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXXXX" --variable FCM_VERSION="11.X.X"
ionic cordova build android

and the problems disappeared, so I can say that what we have to do is find out which plugin is given the error and try to update it.

Edit 11/12/2018

Finally, for me, this is not the main problem, I'm still looking for a solution, but maybe some of them will be solved. But it seems that something has happened with the maven repositories, like this:

When it resolves, I will comment again on the solution.

Edit 13/12/2018

Finally it was a problem related to the disappearance of several plugins from jcenter libraries, according to the following link, https://issuetracker.google.com/issues/120759347#comment24

It seems that they have already solved it, and at least it worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!