Open wdarking opened 6 years ago
Same problem here, all of a sudden. Have already tried cordova clean, manually cleaning gradle cache, removing and re-adding platform, starting project from scratch...
Commenting out app-FCMPlugin.gradle' line: 20 will have the app build, but then the plugin doesn't work well -- couldn't use FCMPlugin.getToken() for instance.
I can confirm I am having the same issue. Did the same thing... wiped out the line 20 then plugin stops working => I debugged the code where the token is retrieved and an exception occurs.
But I seriously don't understand any of this gradle stuff. If some genius could come a long and fix it, that would be awesome.
Here's a dirty hack to get it working. I have no idea about the long term fix however:
go to platforms/android/cordova-plugin-fcm and open up the gradle file inside. Make it look like this:
go to platforms/android/build.gradle Find the lines of code which have
And add the following lines around them (above and below)
Have your project open in android studio and go Tools > Android > SYnc Project with Gradle Files.
Build and it should work
Basically I came across this solution by going back to basics according to the documentation.
https://developers.google.com/android/guides/google-services-plugin
Same issue here. It was working the last time I build but now it give me an error
FAILURE: Build failed with an exception.
Where: Script '/cordova-plugin-fcm/customer-FCMPlugin.gradle' line: 20
What went wrong: A problem occurred evaluating root project 'www_android'.
com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: com/android/build/gradle/AppPlugin$AppModelBuilder
same issue here... any stable fix?
Chris Workaround does work.
I copy and paste the text to help others avoiding typos:
go to platforms/android/cordova-plugin-fcm and open up the gradle file inside.
Change the file from:
android {
defaultConfig {
multiDexEnabled true
}
}
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.1.1'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}
To:
android {
defaultConfig {
multiDexEnabled true
}
}
//buildscript {
// repositories {
// jcenter()
// maven { url 'https://maven.google.com' }
// }
// dependencies {
// classpath 'com.android.tools.build:gradle:+'
// classpath 'com.google.gms:google-services:3.1.1'
// }
//}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
//ext.postBuildExtras = {
// apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
//}
edit file platforms/android/build.gradle
change this:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.google.firebase:firebase-core:11.4.2"
compile "com.google.firebase:firebase-messaging:11.4.2"
compile "com.android.support:support-v4:24.1.1+"
// SUB-PROJECT DEPENDENCIES END
}
to this:
buildscript {
dependencies {
classpath 'com.google.gms:google-services:3.1.1'
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.google.firebase:firebase-core:11.4.2"
compile "com.google.firebase:firebase-messaging:11.4.2"
compile "com.android.support:support-v4:24.1.1+"
// SUB-PROJECT DEPENDENCIES END
}
apply plugin: 'com.google.gms.google-services'
Any idea on how to convert this into a patch? Afaik it's not possible to modify build.gradle directly from a plugin, so is it possible to still only use the plugins gradle-file?
no clue sorry :-(
This issue may be related to Google's update on support package:
Google released the new version 28.0.0-alpha1 of com.android.support:support-v4 which is adding 2 new attributes(android:fontVariationSettings and android:ttcIndex). Some of the plugins are using the latest android-support libraries which results in unwanted incompatibilities.
source: https://stackoverflow.com/a/49200782/4687714
I've managed to solve my build problems using this workaround:
cordova platform rm android
cordova platform add android
Option 2: Add next code snippet in build.gradle under platforms/android
configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:27.1.0'
}
Isn't a stable fix though
@wdarking Cool, I've done a similar thing but still had some issues with multidex not being applied properly. Maybe I need to take a better look at that.
I guess that all plugins probably should do something like what they've done in cordova-plugin-googlemaps in order to properly support the correct android-support version. (Same with play services as well)
Cordova: 8.0.0 Ionic: 3.19.1 Node: 8.9.4
cordova build android
output:config.xml
referenced
app-FCMPlugin.gradle
file:It was working ok a few days ago, but recently the build started to fail. Anyone is having the same problem? What could it be?