cordova, where is build.gradle file - android

Changing the build.gradle
and then I run cordova build android the build.gradle file is updated.
How can I change the dependencies of cordova / plugins? Or force to a particular version?
Having issues with : google-gcm services
I am having conflicting dependencies of plugin causing the services to fail to build.

Something like this might help you :
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}

Related

Nativescript gradle project-level

I want to use Segment (with Firebase) into my NativeScript app. So I must follow this instructions : https://segment.com/docs/destinations/firebase but I must modify two files : the Module-level build.gradle :
buildscript {
dependencies {
// Add these lines
compile 'com.segment.analytics.android:analytics:4.+'
compile 'com.segment.analytics.android.integrations:firebase:+'
}
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
and the Project-level build.gradle :
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
// Add this line
maven { url 'https://maven.google.com' }
}
}
But with NativeScript I have only one build.gradle. So, how can I implement this lines in gradle ?
Thanks !
I know this question is old but they may help someone in the future. Nativescript Docs aren't the best and this worked for me so it MAY not work for you.
This applies for Plugins and Regular Apps.
Buildscript Gradle.
App_Resources/Android/buildscript.gradle
PLUGINS buildscript.gradle
repositories {
// Add this line
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
}
App Grade
PLUGINS include.gradle
App_Resources/Android/app.gradle
dependencies {
compile 'com.segment.analytics.android:analytics:4.+'
compile 'com.segment.analytics.android.integrations:firebase:+'
}
apply plugin: 'com.google.gms.google-services'
HOWEVER
The compile configuration still exists but should not be used as it will not offer the guarantees that the api and implementation configurations provide.https://docs.gradle.org/current/userguide/java_library_plugin.html
You can also write this as
App Grade
PLUGINS include.gradle
App_Resources/Android/app.gradle
dependencies {
implementation 'com.segment.analytics.android:analytics:4.+'
implementation 'com.segment.analytics.android.integrations:firebase:+'
}

Firebase Cloud Messaging FCM build error Cannot add task ':processDebugGoogleServices' as a task with that name already exists

I'm trying to use Push Notifications with Firebase Cloud Messaging and Cordova FCM. My google-services.json located in root folder with config.xml and same file in platforms/android/ folder. With ionic cordova build I got error:
A problem occurred configuring root project 'android'.
Cannot add task ':processDebugGoogleServices' as a task with that name already exists.
I've installs:
cordova plugin add cordova-support-google-services --save
ionic cordova plugin add cordova-plugin-fcm
npm install --save #ionic-native/fcm
and previously by another reason:
cordova plugin add cordova-plugin-googleplus ...
Now what I got:
platforms/android/cordova-plugin-fcm/myapp-FCMPlugin.gradle:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// 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
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
platforms/android/cordova-support-google-services/myapp-build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.2.0'
}
}
// 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
}
platforms/android/project.properties:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-auth:11.0.1
cordova.system.library.2=com.google.android.gms:play-services-identity:11.0.1
cordova.system.library.3=com.facebook.android:facebook-android-sdk:4.14.+
cordova.system.library.4=com.google.firebase:firebase-core:+
cordova.system.library.5=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.1=cordova-plugin-fcm/myapp-FCMPlugin.gradle
cordova.gradle.include.2=cordova-support-google-services/myapp-build.gradle
which is edited from:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-auth:+
cordova.system.library.2=com.google.android.gms:play-services-identity:+
cordova.system.library.3=com.facebook.android:facebook-android-sdk:4.14.+
cordova.system.library.4=com.google.firebase:firebase-core:+
cordova.system.library.5=com.google.firebase:firebase-messaging:+
cordova.gradle.include.1=cordova-plugin-fcm/myapp-FCMPlugin.gradle
platforms/android/build.gradle which is also edited as project.properties:
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.android.gms:play-services-auth:11.0.1"
compile "com.google.android.gms:play-services-identity:11.0.1"
compile "com.facebook.android:facebook-android-sdk:4.14.+"
compile "com.google.firebase:firebase-core:+"
compile "com.google.firebase:firebase-messaging:11.0.1"
// SUB-PROJECT DEPENDENCIES END
}
plugins/cordova-plugin-fcm/scr/android/FCMPlugin.gradle:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// 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
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
plugins/cordova-support-google-services/build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.2.0'
}
}
// 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
}
Not sure what is wrong, advice would be helpful
The problem is you have conflicting versions of the GoogleServices plugin specified in your Gradle config:
/plugins/cordova-plugin-fcm/scr/android/FCMPlugin.gradle
com.google.gms:google-services:3.0.0
plugins/cordova-support-google-services/build.gradle
com.google.gms:google-services:3.2.0
You need to resolve this so the versions match.

android studio plugin with id: 'kotlin-android-extensions'

I am using gradle and I am trying to add kotlin to my project. But when I am trying to add 'kotlin-android-extensions' plugin for gradle it fails to find it.
To use the plugin, you have to add it in your root level file:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
ext.kotlin_version = '1.1.2-4'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Try to add the following to your gradle.build file
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
after that you have to make some changes in your dependencies classpath like this.
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and in dependencies compile make sure to add jre7 such that.
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
After doing all that rebuild the gradle and you are all done. This worked for me because i was facing the same problem you are now, and after this it's all done. Hope it works for you tooo....
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:+"
try this

“Plugin with id 'com.android.application' not found”

I am getting “Plugin with id 'com.android.application' not found”. I have updated the gradle distribution version in gradle wrapper properties but to no avail. Do I need to write the build gradle dependencies somewhere?
You have to add in your top level file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}

Error showing while gradle building

I am getting following error while building the gradle:
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.0.1.
Update your buildScript's dependency in your root build.gradle file like this
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
Apply plugin in app module's build.gradle file
apply plugin: 'com.google.gms.google-services'
Add the following line in the dependency of the project-level build.gradle:
classpath 'com.google.gms:google-services:3.0.0'
Use these dependencies for the project build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
}
and put this at the end of the app-level build.gradle file (after the dependencies).
apply plugin: 'com.google.gms.google-services'

Categories

Resources