Failed to apply plugin "com.google.gms.google-services" - java

Here is my project build.gradle:
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:3.1.0'
}
}
In one of the module's build.gradle I have this:
apply plugin: 'com.google.gms.google-services'
which results into the following error:
Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension.
Fun fact, if I set google-services version to 3.0.0, this specific error disappears, but Gradle asks me to downgrade versions of other google libraries, but I really do not want to do that.
How do I deal with these LibraryVariants?

You only set apply plugin: 'com.google.gms.google-services' in the app module, and in no other modules.

You must add one dependencies in your build.gradle(Project:project_name)
classpath 'com.google.gms:google-services:3.1.0'
And add in your build.gradle(build.gradle:Module app)
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
}
apply plugin: 'com.google.gms.google-services'

Related

Drools kie-maven-plugin error message using Gradle "plugin with id 'kie-maven-plugin' not found."

I've gotten the kie-maven-plugin to work with maven, but when using it with gradle I get the error plugin with id 'kie-maven-plugin' not found. I've added the kie-maven-plugin coordinates to both the plugin repository section as well as the project dependencies section with no luck (as well as either/or). Am I getting the apply plugin line right?
In buildscript -> repositories -> dependencies section:
classpath 'org.kie:kie-maven-plugin:7.35.0.Final'
In allprojects section:
apply plugin: 'kie-maven-plugin'
In allprojects -> dependencies section:
compile group: 'org.kie', name: 'kie-maven-plugin', version: "7.35.0.Final"
I've also tried the following to no avail:
apply plugin: 'org.kie.maven.plugin'
apply plugin: 'kie'
apply plugin: 'org.kie'
apply plugin: 'org.kie.kie'
apply plugin: 'org.kie.kie-maven-plugin'
apply plugin: 'org.kie:kie-maven-plugin'
apply plugin: 'org.kie.maven.plugin.ValidateDMNMojo'

android push notifications library with google cloud messaging

i am working on an android using GCM application and adding support libraries,i added the following to my gradle
i added a plugin
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
and dependencies: i added:
compile 'com.google.android.gms:play-services:8.3.0'
classpath 'com.google.gms:google-services:3.0.0'
but it brings an error
Error:(3, 0) Plugin with id 'com.google.gms.google-services' not found.
and yet i see the plugin added. how to i correct it thank you
In your project level build.gradle add like following:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
While your App level build.gradle should look like this:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.google.android.gms:play-services-gcm:8.3.0"
}
apply plugin: 'com.google.gms.google-services'
Make sure to add apply plugin: 'com.google.gms.google-services' as last line in your app level gradle file.
You should only apply the com.android.application plugin.
Applying the java plugin as well will result in a build error.
Reference : http://tools.android.com/tech-docs/new-build-system/user-guide
The dependencies you have added are fine. You can remove the "apply plugin: 'com.google.gms.google-services'" entry.

Apt for Java subproject

I am developing an Android project. I have a plain java subproject. I would like to activate the apt process for this java subproject. My gradle file:
project(':subproject') {
apply plugin: 'java'
apply plugin: 'android-apt'
dependencies {
compile files('../app/libs/sqliteannotations-api-0.1-SNAPSHOT.jar')
apt files('../app/libs_annotations/sqliteannotations-0.1-SNAPSHOT-jar-with-dependencies.jar')
}
}
but I get this error:
The android or android-library plugin must be applied to the project
Add apply plugin: 'com.android.application' if you are working on an app.
Add apply plugin: 'com.android.library' if you are working on a library.

How to use DexGuard in java project whith Gradle

I am trying to use DexGuard plugin in Java project whith Gradle. It is library project for android.
But i want to link DexGuard library whitout:
apply plugin: 'com.android.application'
Because I need to use:
apply plugin: 'java'
Is it possible to use DexGuard plugin such a way?
I need this way to use because i need to use an additional plugin:
apply plugin: 'com.github.johnrengelman.shadow'
And I have a problem to use this plugin in conjunction whith android plugin...
My gradle:
buildscript {
repositories {
jcenter()
flatDir dirs: 'DexGuard/lib'
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.2'
classpath ':dexguard'
}
}
apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '**/*.jar')
}
sourceSets {
main {
java.srcDirs = ['src']
}
}
shadowJar {
...
}
task sdkDexguard(type: com.saikoa.dexguard.gradle.DexGuardTask) {
configuration 'dexguard.txt'
injars 'build/classes'
injars 'libs'
outjars 'build/application.apk'
}
I can not to build tasklist. Error in line task sdkDexguard:
Could not find property 'com' on root project
UPD
Problem in the library DexGuard 6.1.11 for standalone usage. GuardSquare team will solve that soon.
Problem solved in version 7.0.31. Now possible to use this method for standalone usage.

plugin with id spring-boot not found in parent build.gradle

I have below project structure:
java/
build.gradle
settings.gradle
projectA/
build.gradle
projectB/
build.gradle
When I put below codes in, e.g. projectA's build.gradle,
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
...
everything works fine.
But if I put the above code in Java's build.gradle:
subprojects {
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
...
}
When running gradle clean build, it keeps reporting below error:
Plugin with id 'spring-boot' not found.
Anyone encountered this issue before? And why?
I figured out a solution but don't know why. Will spent some time reading the docs during the weekend...
Change multi-project build.gradle to below:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
...
}
i.e move buildscript out of subprojects
Try using fully qualified name as below:
plugins{
id 'org.springframework.boot' version '2.0.3.RELEASE'
id 'java'
}
You need to specify version of some plugins, you just have to. But gradle doesn't want multiple different versions, even though you type the same version in multiple files, if they include each other it won't work.
So to fix that you have to move common plugin to the root project, it doesn't matter if some projects don't use it, read further. Here is the trick part, you need to put apply false in the root project to the plugins. Thanks to that it won't be applied to the root and other projects but it will be applied to all of the projects you will add the plugin to.
So in root you would put:
plugins{
id 'org.springframework.boot' version '2.0.3.RELEASE' apply false
}
But in subproject you put it without the version
plugins {
id 'org.springframework.boot'
}
Also don't forget to put include statements in the root project, for all the folders that root needs to apply to.

Categories