Gradle DSL method not found: 'debugImplementation()' - build.gradle

I have included the below dependencies in the gradle.build(app) file to check the memory leaks. But when included the below two dependencies I am getting an error.
dependencies {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
}
Error : Gradle DSL method not found: 'debugImplementation()'
Android Gradle Plugin Version is 3.5.3. And Gradle Version is 5.6.2
Please help in fixing the error.

Put the dependencies in module gradle file, not project gradle.

Related

How do i get logback version 1.3.x

I'm having trouble in logback version up. (1.2.9 -> 1.3.4)
this is my build.gradle file
dependencies {
implementation('org.springframework.boot:spring-boot-starter-web')
//...
testImplementation('org.slf4j:slf4j-api:2.0.3')
testImplementation('ch.qos.logback:logback-classic:1.3.4')
testImplementation('ch.qos.logback:logback-core:1.3.4')
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
The following error logs were found
java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
There is no problem when 1.2.9, but I don't know why it is not work with 1.3.x

java.lang.NoSuchFieldError: defaultReader (JsonSmartJsonProvider.java:39)

I am using json-path-2.4.0 library in spark jobs which has a dependency on json-smart 2.x , but the spark jars default classpath folder (/usr/hdp/2.6.5.0-292/spark2/jars/) has json-smart 1.x which always gets precedence and I am unable to use the json-path 2.x library.
Facing the below error everytime I run :
java.lang.NoSuchFieldError: defaultReader
at com.jayway.jsonpath.spi.json.JsonSmartJsonProvider.(JsonSmartJsonProvider.java:39)
at com.jayway.jsonpath.internal.DefaultsImpl.jsonProvider(DefaultsImpl.java:21)
at com.jayway.jsonpath.Configuration.defaultConfiguration(Configuration.java:174)
Similar issue has been reported earlier :
JSON Path 2.3.0 conflicts with hadoop 2.7 Environment JSON-smart1.2.0.jar
But havent found any working solution. Please help.

spring boot with gradle not starting up

I am trying to build sample hello application using gradle build in Spring tool suite facing below design time error.
I have grade version 4.10.2 installed on my machine.
Error Msg:
Description Resource Path Location Type
Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.10.2-bin.zip'.
Build file 'C:\TFS\Study\Springboot\GradleExamples\workspace\Gradle_Hello\build.gradle' line: 14
Plugin [id: 'org.springframework.boot', version: '2.1.2.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.1.2.RELEASE')
Searched in the following repositories:
Gradle Central Plugin Repository
Plugin [id: 'org.springframework.boot', version: '2.1.2.RELEASE'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.1.2.RELEASE')
Searched in the following repositories:
Gradle Central Plugin Repository build.gradle /Gradle_Hello line 14 Gradle Error Marker
Next time, please include your build.gradle file.
I believe your problem is caused by the fact you are trying to apply the plugin:'org.springframework.boot' without telling your gradle script where to find that plugin. Your buildscript (build.gradle file) actually depends on the org.springframework.boot plugin, however since it can't find it (and doesn't even know what it is), you are getting this issue.
you can fix that issue by adding the following code at the top of your file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
// You are telling gradle that this script (Not the project) depends on the
// following plugin
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.2.RELEASE"
}
}
apply plugin: "org.springframework.boot"
// The rest of your build.gradle file
I had the same problem, so I changed to Gradle 6.5 and also add settings.gradle file in the same dir as your build.gradle with the following info.
// settings.gradle
pluginManagement {
plugins {
id "org.springframework.cloud.contract" version "${verifierVersion}"
}
repositories {
// to pick from local .m2
mavenLocal()
// for snapshots
maven { url "https://repo.spring.io/snapshot" }
// for milestones
maven { url "https://repo.spring.io/milestone" }
// for GA versions
gradlePluginPortal()
}
}
In addition make sure that you can connect to your repositories. In my case if was a internal nexus server and gradle wasn't able to connect to the repositories because of SSL certificate missing from JDK truststore. I added the nexus SSL certificate in to the JDK truststore and it resolved

Gradle: Error listing versions of junit#junit;4.+

I am getting the below error when running gradle build on my gradle.properties file.
I know I am behind a firewall and I have a poxy I can use. I've tried adding the below to my gradle.properties file, but I cannot pull down jUnit. All help appreciated!
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
Error:
Error listing versions of junit#junit;4.+ using class
org.gradle.api.internal.artifacts.repositories.resolver.MavenVersionLister$1.
Will attempt an alternate way to list versions. This behaviour has been
deprecated and is scheduled to be removed in Gradle 2.0
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':testRuntime'.
> Could not resolve junit:junit:4.+.
Required by:
:HealthMonitor:1.0
> Failed to list versions for junit#junit;4.+.
> Could not list versions using M2 pattern 'http://repo1.maven.org/maven2/
[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'.
> Could not GET 'http://repo1.maven.org/maven2/junit/junit/'.
> Connection to http://repo1.maven.org refused
build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Health Monitor', 'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
}
Depending on the proxy, you may have to configure more than just the host and port. See Accessing the web via a proxy in the Gradle User Guide. Also, I recommend to try with a fixed version rather than a version range.

Quartz Scheduler - NoClassDefFoundError

I am using Quratz 1.6.3 API in a Maven project. This is the error message I get when I run it:
java.lang.NoClassDefFoundError: org/apache/commons/collections/SetUtils
at org.quartz.JobDetail.(JobDetail.java:85)
.....
commons.collections 3.2 dependency is included in the project's pom.xml file. What could be the reason for this error?
Thanks in advance.
commons.collections 3.2.1 contains this class
org\apache\commons\collections\SetUtils.class
So the problem should be in your maven project. Double check that the commons.collections gets is the classpath (see logs). Or show the project configuration, so we would be able to help.