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.
Related
I will keep it simple. I am using both kotlin and java in my Android project. I can provide my gradle files if necessary.
I need the following java plugins in my project: id 'java-library'
id "org.web3j". They work on an older version of Android gradle ('com.android.tools.build:gradle:3.6.3' ; distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip) but not on the newest one ("com.android.tools.build:gradle:4.1.1" ; distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip) from which I need other functionality. When I try to add them I get the following error.
Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins
Old gradle version has plugins:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
New gradle version has plugins:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
// id "org.web3j" version "4.8.1"
// id 'java-library'
}
I found others with the same problem but with no real answer. One workaround I found here is to configure them for a subproject or something, but I don't really understand how. Can somebody help? Ideally tell me what and where to put it in which gradle file and how it works (from my understanding I have only 1 project not many in my Android app).
This is the code that I found:
configure(allprojects) {
println "applying java plugin to $project"
apply plugin: 'java-library'
//...
}
You cannot add org.web3j as a plugin because it contains 'java' plugins that are not compatible with 'java' plugins of android. So, you can either add 'com.android.application' plugin or 'org.web3j'. Add web3j as a dependency -
implementation ('org.web3j:core:4.8.7'). It will work fine.
Appcompat version used in app is v7, androidx is used for integration with gradle.properties for firebase connection
Please help
You are using the wrong build.gradle file
You have to move the implementation from the top-level file to the app/build.gradle file in the dependencies block (not the dependencies in the buildscript block)::
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
//...
}
dependencies {
//...
implementation 'androidx.xxxxx'
}
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'
I am working to migrate from Springboot 1.5 to 2.1. Our project has a main build.gradle file and then four subprojects (acceptance, application, shared, integration) with build.gradle it in. The problem is that the "shared" subproject is dependent on models from the "application" subproject and no longer seems to be able to pick them up. In IntelliJ I can tell it to import the models and it accepts that but when I do a "gradle clean build" it fails for the following:
C:\code\java\workspace\brokerage-customer\shared\src\test\java\com\##MASKED##\brokerage\customer\util\OrgTrustUtil.java:563: error: cannot find symbol
public static BrokerageCustomer generateExpectedBrokerageCustomer() {
^
symbol: class BrokerageCustomer
location: class OrgTrustUtil
I am new to using gradle (used maven in the past). The build.gradle file for shared is:
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
bootJar {
enabled = false
}
dependencies {
// testCompile project(':application').sourceSets.main.output
}
Note that I have commented out the testCompile line as it was fine in 1.5 but errors in 2.1.
I am kind of assuming the issue is with the testCompile having to be commented out but I have not found how to keep it since it errors when I try to build.
I found the issue was that I had not applied the dependency manager plugin. Adding this made it work:
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
enabled = false
}
dependencies {
testCompile project(':application').sourceSets.main.output
}
I found the issue was that I had not applied the dependency manager plugin. Adding this made it work:
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
enabled = false
}
dependencies {
testCompile project(':application').sourceSets.main.output
}
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'