I am getting the following exception while running run-war on IntelliJ IDEA.
| Uglifying File 44 of 464 - application.
| Error Error executing script RunWar: com.google.common.collect.Maps.immutableEnumMap(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap; (NOTE: Stack trace has been filtered.
Use --verbose to see entire trace.)
java.lang.NoSuchMethodError: com.google.common.collect.Maps.immutableEnumMap(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;
at com.google.javascript.jscomp.parsing.parser.Keywords.<clinit>(Keywords.java:94)
at com.google.javascript.jscomp.parsing.parser.Scanner.scanIdentifierOrKeyword(Scanner.java:681)
at com.google.javascript.jscomp.parsing.parser.Scanner.scanToken(Scanner.java:569)
at com.google.javascript.jscomp.parsing.parser.Scanner.peekToken(Scanner.java:228)
at com.google.javascript.jscomp.parsing.parser.Parser.peekToken(Parser.java:2737)
at com.google.javascript.jscomp.parsing.parser.Parser.peekToken(Parser.java:2730)
at com.google.javascript.jscomp.parsing.parser.Parser.getTreeStartLocation(Parser.java:2649)
at com.google.javascript.jscomp.parsing.parser.Parser.parseProgram(Parser.java:147)
at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:102)
at com.google.javascript.jscomp.JsAst.parse(JsAst.java:84)
at com.google.javascript.jscomp.JsAst.getAstRoot(JsAst.java:50)
at com.google.javascript.jscomp.CompilerInput.getAstRoot(CompilerInput.java:118)
at com.google.javascript.jscomp.Compiler.hoistExterns(Compiler.java:1467)
at com.google.javascript.jscomp.Compiler.parseInputs(Compiler.java:1369)
at com.google.javascript.jscomp.Compiler.parse(Compiler.java:788)
at com.google.javascript.jscomp.Compiler.compileInternal(Compiler.java:743)
at com.google.javascript.jscomp.Compiler.access$000(Compiler.java:93)
at com.google.javascript.jscomp.Compiler$3.call(Compiler.java:655)
at com.google.javascript.jscomp.Compiler$3.call(Compiler.java:652)
at com.google.javascript.jscomp.Compiler$4.call(Compiler.java:699)
If I run the same app using run-app it works.
This is BuildConfig.groovy:
build ":tomcat:7.0.55"
compile ':cache:1.1.8'
compile ":asset-pipeline:2.1.1"
compile ":easygrid:1.6.9"
compile ":twitter-bootstrap:3.3.2.1"
compile ':spring-security-core:2.0-RC4'
compile ":jquery-validation-ui:1.4.9"
compile ":birt-report:4.3.0.3"
runtime ":hibernate:3.6.10.18"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
Any idea what it might be? or how to solve it?
Adding a build-scoped dependency on Guava fixed this issue for me in a Grails 2.5.2 app
dependencies {
// other dependencies go here
build 'com.google.guava:guava:18.0'
}
https://code.google.com/p/guava-libraries/wiki/UseGuavaInYourBuild
Make sure you have two things set in your BuildConfig:
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '12.0'
}
Just make sure you're using the correct version that you need. Then do a Grails Refresh Dependencies.
I had the same problem with Grails 2.5.0 and I fixed it by bumping the guava version to the latest available.
In my grails-app/conf/BuildConfig.groovy, I now have:
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '18.0'
}
And that resolved the issue.
I had the same error and fix it using the latest asset plugin:
(compile "org.grails.plugins:asset-pipeline:2.11.0")
Related
I upgraded my Java application from Spring 4 to Spring 5 and i am getting java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference error while running on tomcat server.
followed by java.lang.ClassNotFoundException: org.springframework.beans.factory.access.BeanFactoryReference
Please help me to fix this issue..
Below are dependencies in my build.gradle file
compile 'org.springframework:spring-context-support:5.2.11.RELEASE'
compile 'org.springframework:spring-webmvc:5.2.11.RELEASE'
compile 'org.springframework.security:spring-security-config:5.2.8.RELEASE'
compile 'org.springframework.security:spring-security-web:5.2.8.RELEASE'
compile 'org.springframework.security:spring-security-ldap:5.2.8.RELEASE'
compile 'org.springframework.integration:spring-integration-sftp:5.2.11.RELEASE'
compile 'org.springframework.ws:spring-ws-core:3.0.9.RELEASE'
compile 'com.thoughtworks.xstream:xstream:1.4.14'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.10'
compile 'wsdl4j:wsdl4j:1.6.3'
compile 'commons-discovery:commons-discovery:0.2'
compile 'javax.xml:jaxrpc-api:1.1'
compile 'com.google.guava:guava:24.1.1-android'
compile('org.apache.poi:poi-ooxml:4.1.2') {
exclude group: 'stax', module: 'stax-api'
}
compile 'javax.validation:validation-api:1.1.0.Final'
compile 'org.hibernate:hibernate-validator:5.1.3.Final'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'commons-fileupload:commons-fileupload:1.4'
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.13.3'
compile 'com.lmax:disruptor:3.3.4'
compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'
compile 'org.apache.commons:commons-csv:1.2'
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
providedCompile 'javax.servlet.jsp.jstl:jstl-api:1.2'
providedCompile 'javax.servlet:jstl:1.2'
providedCompile 'org.glassfish.web:jstl-impl:1.2'
providedCompile 'com.microsoft.sqlserver:sqljdbc4:2.0'
providedCompile 'javax.xml.bind:jaxb-api:2.2.12'
testCompile 'org.springframework:spring-test:5.2.11.RELEASE'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile 'foo-commonj:foo-commonj:1.1.0'
testCompile 'commonj-twm:commonj-twm:1.1.0'
integrationTestCompile sourceSets.main.output
integrationTestCompile configurations.testCompile
integrationTestCompile sourceSets.test.output
integrationTestRuntime configurations.testRuntime
Please let me know if more information required from my side.
There is nothing to fix, you must go through the process of upgrading/migrating from Spring 4.x to 5.x. That is a major upgrade so it is expected that classes would be removed.
As stated by core Spring developer here:
I'm afraid BeanFactoryReference and co are simply gone in 5.0. You need to clean up your dependencies so that they are all Spring Framework 5.0 compatible (...)
With that said, you will need to read over the upgrade guide for 5.0 here, then work you're way up all the way to 5.3
I resolved it by myself. I cleaned tomcat history by tomcat -> clean
I did gradle refresh, ran again on tomcat server and issue resolved.
Tomcat was taking application's old build. In previous build I had spring-ws-core:2.x.RELEASE which was bringing spring-beans.4.x.jar and it is incompatible with other spring 5 jars.
so root cause was incompatible jars and then tomcat cache build.
I am upgraded SpringBoot version 2.1.0 to 2.2.2.RELEASE
java : openjdk11
spring-boot: v2.2.0.RELEASE
springCloudVersion : Hoxton.RC1
Error :
APPLICATION FAILED TO START
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)
The following method did not exist:
org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang> /Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;
The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:
jar:file:/home/cuelogic.local/kanisha.modi/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.RELEASE/95fc8c13037630f4aba9c51141f535becec00fe6/spring-plugin-core-2.0.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class
It was loaded from the following location:
file:/home/cuelogic.local/kanisha.modi/.gradle/caches/modules-2/files-2.1/org.springframework.plugin/spring-plugin-core/2.0.0.RELEASE/95fc8c13037630f4aba9c51141f535becec00fe6/spring-plugin-core-2.0.0.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry
Error caused by
Caused by: java.lang.NoSuchMethodError:
org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;
at
springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)
at
springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.defaultContextBuilder(DocumentationPluginsBootstrapper.java:106)
at
springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.buildContext(DocumentationPluginsBootstrapper.java:91)
at
springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:154)
at
org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182)
... 101 common frames omitted
build.gradle
dependencies {
compile "org.springframework.cloud:spring-cloud-starter-netflix-eureka-client"
compile "io.opentracing.contrib:opentracing-spring-jaeger-cloud-starter:1.0.1"
compile "org.springframework.boot:spring-boot-starter"
compile "org.springframework.boot:spring-boot-starter-amqp"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.springframework.boot:spring-boot-starter-security"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-data-rest"
compile "org.springframework.boot:spring-boot-starter-data-mongodb"
compile "org.springframework.boot:spring-boot-starter-aop"
compile "org.springframework:springloaded:1.2.8.RELEASE"
compile "org.springframework.security:spring-security-web"
compile "org.springframework.security:spring-security-config"
compile "org.apache.commons:commons-collections4:4.1"
compile "com.fasterxml.jackson.core:jackson-databind:2.9.10"
compile "com.google.guava:guava:${guava_version}"
compile(group: 'io.springfox', name: 'springfox-swagger2', version: '2.7.0') {
exclude(module: 'guava')
}
compile "javax.cache:cache-api:1.1.0"
compile "org.springframework.boot:spring-boot-starter-websocket"
compile "org.springframework.boot:spring-boot-configuration-processor"
compile "org.springframework.boot:spring-boot-starter-cache"
compile "com.hazelcast:hazelcast-spring:3.12"
compile "com.hazelcast:hazelcast-eureka-one:1.0.2"
compile "org.reflections:reflections:0.9.11"
compile group: 'io.opentracing.contrib', name: 'opentracing-spring-cloud-mongo-starter', version: '0.3.12'
}
How to solve this issue? Please help me it would be grateful.
I want to upgrade my application to springboot v2.2.2 .So need a solution for this version.
Update your springfox-swagger version. I have springfox 2.9.2 running with boot 2.2.2
Edit 98.01.2020:
You somehow got spring-plugin-core-2.2.0.RELEASE in your classpath. SpringFox needs version 1.2.0, Spring Boot 2.2.2 itself does not pull this in. Can you run gradle dependencies --configuration runtimeClasspath and check which dependency pulls in this version?
I'm having an issue with setting up my build.gradle in a standalone java app - and a very similar configuration works in one of my other projects. What am I missing here? I think this has to be a simple fix, but it eludes me at the moment.
My simple build.gradle:
apply plugin: 'java'
sourceCompatibility = 1.9
targetCompatibility = 1.9
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/org.apache.poi/poi
compile group: 'org.apache.poi', name: 'poi', version: '4.1.0'
// https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.0'
}
The error message eclipse gives me (from the gradle process) when I refresh the gradle project:
CONFIGURE SUCCESSFUL in 0s
Could not resolve: org.apache.poi:poi:4.1.0
Could not resolve: org.apache.poi:poi-ooxml:4.1.0
How can I resolve this? I've read the gradle docs, and appeared to be following the process. Gradle documentation links showing my error are appreciated as well. Thank you.
To resolve the dependencies try running from the command line. From there you can work to solve the IDE issue.
As mentioned in the comments on the original post - #PaulPearson discovered it worked on his machine, and when I ran the gradle refresh outside of Eclipse (with gradle build via command line) it worked fine.
It must be an eclipse IDE specific issue - not an issue with the build.gradle. My acute issue is resolved. Thanks all.
I am not sure what this error means.
Execution failed for task ':excelSior:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/util/TimeUtils.class
I am currently using android-support-v4.jar for my libraries
dependencies {
compile project(':addThisSDK')
compile project(':centeredContentButton')
compile project(':googleplayservices_lib')
compile files('libs/adxtag2.4.6.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/aws-android-sdk-1.7.1.1-debug.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/crittercism_v4_4_0_sdkonly.jar')
compile files('libs/dd-plist.jar')
compile files('libs/FiksuAndroidSDK_4.1.1.jar')
compile files('libs/iqengines-sdk-barcode.jar')
compile files('libs/irEventTracker-1.2.jar')
compile files('libs/jolt-core-0.0.7.jar')
compile files('libs/json-utils-0.0.7.jar')
compile files('libs/jsoup-1.7.2.jar')
compile files('libs/kooaba-api-v4-java.jar')
compile 'com.android.support:multidex:1.0.0'
}
Error does not show up during gradle sync. Just when I try to run the application
What could be the problem?
You've probably fixed this by now but just so this doesn't stay unanswered,
Try adding this to your build.gradle:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
You need to check that you have inserted v4 library and compile library? You must not repeat library in your app or your dependence program.
delete the repeat library so that just one V4 remains.
in your app dir build.gradle file
add this command:
android{
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'support-annotations'
}
}
it works for me! You can try it!
I also came across this kind issue when re import old eclipse project. It occurred some old dependency as jar file in the project.
just remove
compile fileTree(dir: 'libs', include: '*.jar')
in gradle file
and add dependency in the gradle file.
It works for me ..
In my case the mentioned "duplicate entry" error arised after settingmultiDexEnable=true in the build.gradle.
In order to fully resolve the error first of all have a look at Configure Apps with Over 64K Methods (espescially "Configuring Your App for Multidex with Gradle").
Furthermore search for occurences of the class that causes the "duplicate entry" error using ctrl+n in Android Studio. Determine the module and dependency that contains the duplicate and exclude it from build, e.g.:
compile ('org.roboguice:roboguice:2.0') {
exclude module: 'support-v4'
}
I had to try multiple module labels till it worked. Excluding "support-v4" solves issues related to "java.util.zip.ZipException: duplicate entry: android/support/v4/*"
My understanding is that there are duplicate references to the same API (Likely different version numbers). It should be reasonably easy to debug when building from the command line.
Try ./gradlew yourBuildVariantName --debug from the command line.
The offending item will be the first failure. An example might look like:
14:32:29.171 [INFO] [org.gradle.api.Task] INPUT: /Users/mydir/Documents/androidApp/BaseApp/build/intermediates/exploded-aar/theOffendingAAR/libs/google-play-services.jar
14:32:29.171 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':BaseApp:packageAllyourBuildVariantNameClassesForMultiDex'
14:32:29.172 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :BaseApp:packageAllyourBuildVariantNameClassesForMultiDex FAILED'
In the case above, the aar file that I'd included in my libs directory (theOffendingAAR) included the Google Play Services jar (yes the whole thing. yes I know.) file whilst my BaseApp build file utilised location services:
compile 'com.google.android.gms:play-services-location:6.5.87'
You can safely remove the offending item from your build file(s), clean and rebuild (repeat if necessary).
check your dependencies versions, you must have compatible versions put attention specially to com.google packages, must have same version like:
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
Both are 8.3.0, if you have another version compilation will throw that exception.
Simple Remove Your Jar file from dependencies gardle.project as v7
and run your project
For Expose.class Error i.e
java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class
use the below code
configurations {
all*.exclude module: 'gson'
}
find out the lib depends on the support v4, and exclude it.
code in build.gradle is like this:
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
// http://stackoverflow.com/a/30931887/5210
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
In my situation, the lib 'espresso' has a jar called support-v4 and in my project 'app' have the same support-v4, exclude the support-v4 when import espresso.
PS: it seems compile project can not work with the exclude
This is because you have added a library and given its dependency on a module more than once.
In my case, I had added a library as a module and as a gradle dependency both.
Removing one source of adding library (I removed gradle dependency) solved my problem.
For Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' com.android.build.api.transform.TransformException java.util.zip.ZipException duplicate entry com/google/gson/annotations/Expose.class
Here is what I did:
1) Delete the gson-2.5.jar file.
2) configurations { all*.exclude module: 'gson-2.5' }
I have faced this issue as i have manually copied the jar in libs as well as mentioned the dependency in gradle file. You also check in your project structure, whether the same jar file is copied in any other folder like libs or in project folder.
I had the same problem after upgrading the android SDK. I was able to run the application in the buildToolsVersion '23.0.1', I got the same error when I changed to buildToolsVersion '24.0.3'
I resolved the problem by updating my java version from 1.7 to 1.8 with compileSdkVersion 24
This problem cost me one whole day. I finally downgraded the firebase-ui library version from 2.0.0 to 1.2.0 and added the following code inside Project level build.gradle file:
allprojects {
repositories {
jcenter()
// Add the following code to your project level build.gradle
maven {
url 'https://maven.fabric.io/public'
}
}
}
I also have the issue because of i have compile 'com.android.support:appcompat-v7:24.0.0-alpha1' but i added recyclerview liberary compile 'com.android.support:recyclerview-v7:24.0.2'..i changed the version as same as compat like (24.0.2 intead of 24.0.0).
i got the answer..may be it will help for someone.
In my case the mentioned "duplicate entry" error arised after settingmultiDexEnable=true in the build.gradle.
and exact error which i was getting was below :
Error:Execution failed for task
':android:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/android/gms/internal/zzqx.class
So first thing I search for class which causes "duplicate entry" error using ctrl+n in Android Studio and searched for com/google/android/gms/internal/zzqx.class and then it was showing 2 entries for gms class with one version 8.4.0 and 1 with version 11.6.0 .
To fix it i made both to use 11.6.0 and it was fixed example
earlier
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:8.4.0"
compile "com.google.android.gms:play-services-ads:11.6.0"
After
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:11.6.0"
compile "com.google.android.gms:play-services-ads:11.6.0"
Rebuilding Fixed .
In my case exact error was below
':android:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqx.class
I was using another version of google apis i.e. in one modules gradle file
if (!project.hasProperty('gms_library_version')) {
ext.gms_library_version = '8.6.0'
}
however in other modules version 11.6.0 as below
compile "com.google.android.gms:play-services-ads:11.6.0"
compile "com.google.android.gms:play-services-games:11.6.0"
compile "com.google.android.gms:play-services-auth:11.6.0"
However to find this i did a ctrl + n in android studio and entered class name zzqx.class and then it displayed 2 jar files being pulled for this class and then i understood that somewhere i am using version 8.6.0 . On changing 8.6.0 to 11.6.0 and rebuilding the project the issue was fixed .
Hope this helps .
More on this here
https://www.versionpb.com/tutorials/step-step-tutorials-libgdx-basic-setup-libgdx/implementing-google-play-services-leaderboards-in-libgdx/
For me something similar happened when I had accidently added
apply plugin: 'kotlin-android'
to my android library module. Removing the line fixes the issue.
I tried all the above solutions but not working for me. I tried update libraries by goto project structure > app. And it works for me! Hope this answer helpful to someone.
Try this:
android {
configurations {
all*.exclude module: 'PhotoView' //去除重复依赖库
}
}
Looked around for this solution for much too long now, and I'm not sure if I missed it or just misstyped something, but my Gradle script will not compile. I am migrating to Gradle, and am very new with it. I am very used to using Maven for dependency management, but Gradle seems best me for now. From running this snippet of code:
dependencies {
compile group: 'org.bukkit', name: 'bukkit', version: '1.7.9-R0.1-SNAPSHOT'
compile('io.ibj:MattLib:1.1-SNAPSHOT') {
exclude group: 'de.bananaco'
exclude 'net.milkbowl:vault:1.2.27'
}
compile group: 'net.citizensnpcs', name: 'citizens', version: '2.0.12'
compile group: 'com.sk89q', name: 'worldedit', version: '5.6.1'
compile group: 'com.sk89q', name: 'worldguard', version: '5.9'
compile group: 'net.milkbowl', name: 'vault', version: '1.2.12'
compile fileTree(dir: 'libs', includes: ['*.jar'])
}
NOTE: I do have the java, maven, nexus, shadow, and rebel plugins applied.
When I run my Gradle task, I encounter this error:
Could not find method compile() for arguments [[io.ibj:MattLib:1.1-SNAPSHOT], build_1b5iofu9r9krp7o8mme0dqo9l$_run_closure2_closure8#66fb45e5] on root project 'project'
If I remove the MattLib dependency from my project and reinsert it as
compile 'io.ibj:MattLib:1.1-SNAPSHOT'
The script completes, but I have dependency issues. I read up here:
dependencies {
compile("org.gradle.test.excludes:api:1.0") {
exclude module: 'shared'
}
}
(From Chapter 50 From the Gradle Manual)
that what I have SHOULD work, but I am confused why it doesn't.
gradle --version output:
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.8.0_05 (Oracle Corporation 25.5-b02)
OS: Windows 7 6.1 amd64
Note that the compile, runtime, testCompile, and testRuntime configurations introduced by the Java plugin have been deprecated since Gradle 4.10 (Aug 27, 2018), and were finally removed in Gradle 7.0 (Apr 9, 2021).
The aforementioned configurations should be replaced by implementation, runtimeOnly, testImplementation, and testRuntimeOnly, respectively.
Make sure that you are editing the correct build.gradle file. I received this error when editing android/build.gradle rather than android/app/build.gradle.
compile is a configuration that is usually introduced by a plugin (most likely the java plugin) Have a look at the gradle userguide for details about configurations. For now adding the java plugin on top of your build script should do the trick:
apply plugin:'java'
It should be exclude module: 'net.milkbowl:vault:1.2.27'(add module:) as explained in documentation for DependencyHandler linked from here because ModuleDependency.exclude(java.util.Map) method is used.
In my case, all the compile statements has somehow arranged in a single line. separating them in individual lines has fixed the issue.
In my case the problem was mismatch in the gradle version. I have installed gradle on mac using
brew install gradle
and got the latest gradle which was 7.0
However when I cloned by project repo and executed the gradle taks it failed with below error
* What went wrong:
A problem occurred evaluating root project 'digital-engineering-course'.
> Could not find method compile() for arguments [org.springframework.boot:spring-boot-starter-web, build_bzpgd6h32w4m8umtmgs76ewog$_run_closure3$_closure8#b55ca3] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
build.gradle file looked pretty normal to me as it has regular dependencies
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
It took me a while to understand the problem is mismatch of version. Gradle is not able to find the method compile() because I was using gradle 7.0 in my bash.
And the project was supposed to be ran with gradle 4.8 (Actually gradle wrapper was to be used, but that was breaking for another interesting issue Could not find or load main class org.gradle.wrapper.GradleWrapperMain
(If interested please follow this for details)
The reason for failure is compile is that the compile, runtime, testCompile, and testRuntime configurations introduced by the Java plugin have been deprecated since Gradle 4.10, and were finally removed in Gradle 7.0.
So, to solve the problem I had to install the lower version of gradle. If you want to manage multiple version of gradle use sdkman (earlier known as gvm)
Installation on macOs / linux is as simple as executing below
curl -s "https://get.sdkman.io" | bash
Once done use
sdk list gradle
It will list out all the available versions of the gradle. As per your need install and use. for e.g
sdk install gradle 4.8 (this will choose the 4.8 by default in current shell)
sdk use gradle 4.8 (if already installed, this is suffice to switch between gradle version)
And now the build.gradle was able to compile and execute the task.
Add the dependency to your project-level build.gradle:
classpath 'com.google.gms:google-services:3.0.0'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
app-level build.gradle:
dependencies {
compile 'com.google.android.gms:play-services-auth:9.8.0'
}
In my case I had to remove some files that were created by gradle at some point in my study to make things work. So, cleaning up after messing up and then it ran fine ...
If you experienced this issue in a git project, do git status and remove the unrevisioned files. (For me elasticsearch had a problem with plugins/analysis-icu).
Gradle Version : 5.1.1
Just for the record: I accidentally enabled Offline work under Preferences -> Build,Execution,Deployment -> Gradle -> uncheck Offline Work, but the error message was misleading