I am having issues with app crashing and giving this stack trace
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/codec/digest/DigestUtils;
at com.ryko.fstwo.wrapper.DigestUtilsWrapper.sha1(DigestUtilsWrapper.java:7)
...
Didn't find class "org.apache.commons.codec.digest.DigestUtils" on path: <really long path name>
I have gone through all the threads on here I can find about this problem, but cant find a resolution. In my libs folder I have commons-collections-3.2.1.jar, In my dependencies section on build.gradle I have
compile 'org.apache.commons:commons-collections4:4.1' and
compile files('libs/commons-collections-3.2.1.jar').
I have read through these but can't find a working solution
1, 2, 3 and many others
I guess that you need a dependency to commons-codec. It is available in maven central repo.
For example, add this to the dependencies section of your build.gradle:
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
Or you you prefer the shorter option:
compile group: 'commons-codec:commons-codec:1.10'
you need have changes,such as
dependencies {
implementation 'commons-codec:commons-codec:1.10'
}
Related
./gradlew test
Task :compileTestJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileTestJava'.
> Could not find snakeyaml-1.27-android.jar (org.yaml:snakeyaml:1.27).
Searched in the following locations:
file:/Users/user/.m2/repository/org/yaml/snakeyaml/1.27/snakeyaml-1.27-android.jar
I get the above error with the following definition in my build.gradle file, trying to exclude from javafaker doesn't help either. What should I do here?
// faker
testImplementation('com.github.javafaker:javafaker:1.0.2')
testImplementation group: 'org.yaml', name: 'snakeyaml', version: '1.27'
In my case, I just deleted snakeyaml dependencies directory manually (*/.m2/repository/org/yaml/snakeyaml), it works.
// https://mvnrepository.com/artifact/com.github.javafaker/javafaker
implementation 'com.github.javafaker:javafaker:1.0.2'
Result: Could not find snakeyaml-1.30-android.jar (org.yaml:snakeyaml:1.30).
Searched in the following locations:
https://repo.maven.apache.org/maven2/org/yaml/snakeyaml/1.30/snakeyaml-1.30-android.jar
Solution: Use dataFaker instead of javaFaker that will resolve all the issues, like so:
// https://mvnrepository.com/artifact/net.datafaker/datafaker
implementation 'net.datafaker:datafaker:1.5.0'
You need to exclude the org.yaml from the java faker dependency.
implementation ('com.github.javafaker:javafaker:1.0.2') { exclude module: 'org.yaml' }
implementation group: 'org.yaml', name: 'snakeyaml', version: '1.26'
Workaround: Copy existing snakeyaml jar to the filename being searched
cp /Users/user/.m2/repository/org/yaml/snakeyaml/1.27/snakeyaml-1.27.jar /Users/user/.m2/repository/org/yaml/snakeyaml/1.27/snakeyaml-1.27-android.jar
We have a project that make use of 'jrs-rest-java-client', version: '6.3.1'
The site we used to get the jar from has a certificate issue since September. https://jaspersoft.artifactoryonline.com
We then had to get the jar from a different site.
https://jaspersoft.jfrog.io/
The problem is that a dependency require is missing, but if we use the jar that has "-jar-with-dependencies" it is working. I tried by downloading that jar locally and changing the .gradle to use the local version.
What I would prefer is to have the build to fetch that version directly without having to download first.
How do we specify what jar to use?
dependencies {
compile fileTree(dir: 'lib',
includes: [
'ojdbc8.jar',
])
//compile group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1'
compile group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', USETHISONE: 'jar-with-dependencies'
//compile files("${buildDir}/jrs-rest-java-client-6.3.1-jar-with-dependencies.jar")
}
I have now tried as suggested;
repositories {
mavenCentral()
// to handle broked jasper reports dependencies
maven {
url 'http://jasperreports.sourceforge.net/maven2'
url 'https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/'
url "https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases"
}
}
dependencies {
implementation project(':common:project-common-properties')
implementation project(':common:project-common-mail')
implementation fileTree(dir: 'lib', includes: [
'ojdbc8.jar'
])
implementation group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', classifier: 'jar-with-dependencies'
}
I'm still getting errors at build time...
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':services:notificationService:compileClasspath'.
> Could not find com.jaspersoft.jasperserver:jasperserver-dto:6.3.0.
Required by:
project :services:notificationService > com.jaspersoft:jrs-rest-java-client:6.3.1
That library is not required if the jrs-rest-java-client-6.3.1-jar-with-dependencies.jar is used.
Thanks all,
The solution was, as seen if the video (Thanks!)
adding a new url:
url "https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-releases"
From the jfrog repo, it shows you how to do this:
compile(group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', classifier: 'jar-with-dependencies')
Add the repo for gradle:
repositories {
jcenter {
name "jaspersoft-releases"
url "https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases"
}
}
I'd recommend switching from compile to implementation and using a shorthand to declare the dependency:
implementation "com.jaspersoft:jrs-rest-java-client:6.3.1:jar-with-dependencies"
Give a man a fish and you feed him for a day. Teach him how to fish and you feed him for his life time.
I decided to record a short clip of how I found the appropriate repositories for the artifacts you needed, on jfrog:
I am trying to run CnnSentenceClassification from deeplearning4j example. I moved this file to my Gradle project. When I run the class from the eclipse it works fine. However when I run it from ./gradlew run I get following error:
Exception in thread "main" java.lang.ExceptionInInitializerError
at
main.CnnSentenceClassification.main(CnnSentenceClassification.java:75)
Caused by: java.lang.RuntimeException:
org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException:
Please ensure that you have an nd4j backend on your classpath. Please
see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:6089)
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:201)
... 1 more
Caused by:
org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException:
Please ensure that you have an nd4j backend on your classpath. Please
see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:258)
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:6086)
... 2 more
I checked and nd4j-api-0.9.1.jar is in my classpath. This is my build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
repositories {
jcenter()
}
mainClassName="main.CnnSentenceClassification"
dependencies {
compile group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '0.9.1'
compile group: 'org.deeplearning4j', name: 'deeplearning4j-nlp', version: '0.9.1'
testCompile group: 'org.nd4j', name: 'nd4j-native-platform', version: '0.9.1'
compile group: 'org.nd4j', name: 'nd4j-api', version: '0.9.1'
compile "org.slf4j:slf4j-simple:1.7.25"
compile "org.slf4j:slf4j-api:1.7.25"
}
I was having the same problem. You need an ND4J backend, which means updating your dependency tree.
For Maven builds, add the following dependency to your project's pom:
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native</artifactId>
<version>0.9.1</version>
</dependency>
For Gradle builds, just add the following line in your dependencies:
compile "org.nd4j:nd4j-native:0.9.1"
This native backend uses the CPU for computations.
There is another dependency for a CUDA-enabled graphics card.
I found this link helpful:
DL4J Performance Debugging
Edit: new link is here. https://deeplearning4j.konduit.ai/config/backends
Old content below:
You have test scope on the nd4j backend. An nd4j backend is NEVER optional.
https://nd4j.org/backend.html
The error is right in the message. We even give you a link with an explanation right in the stack trace.
I have recently been getting the following error by attempting to start an instance of JavaCV's FFmpegFrameGrabber:
java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at org.bytedeco.javacpp.Loader.load(Loader.java:413)
at org.bytedeco.javacpp.Loader.load(Loader.java:381)
at org.bytedeco.javacpp.avformat$AVFormatContext.<clinit>(avformat.java:2597)
at org.bytedeco.javacv.FFmpegFrameGrabber.startUnsafe(FFmpegFrameGrabber.java:386)
at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:380)...
While solutions to this problem exist, none worked for me.
Through many trials i have discovered that weirdly enough, if i do not include Realm in my project, i no longer receive this error.
Here is the part of my build.gradle file in which I include all of these libraries:
compile group: 'org.bytedeco', name: 'javacv', version: '1.1'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.0.0-1.1', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.0.0-1.1', classifier: 'android-x86'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.8.1-1.1', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.8.1-1.1', classifier: 'android-x86'
// ORM
compile 'io.realm:realm-android:0.87.2' // Tested NOT OK - Causes JavaCV to crash
//
I am thinking that there may be a solution to this problem that i am not aware of. I found no mention anywhere on the internet about library incompatibility or why this behaviour may occur.
I will edit this post with any additional details that anyone might need.
Any help would be greatly appreciated.
EDIT
I attempted to apply the fix described here.
Now my packaging options look like this:
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
exclude "lib/arm64-v8a/librealm-jni.so"
}
Unfortunately, this change has no effect. I'm still stuck.
With the help of one of my coleagues i have been able to solve this issue.
In adition to the steps described in the question, we:
Copyed all of the .so files in the app/src/main/jniLibs/armeabi and app/src/main/jniLibs/armeabi-v7a folders
Added
ndk {
abiFilters "armeabi-v7a"
}
to the defaultConfig part of the module's build.gradle file
Added
lintOptions {
abortOnError false
}
to the android part of the module's build.gradle file
I will try to provide further clarifications to anyone that needs them if i am able.
Firstly this issue occurs because of Gradle doesn't resolve dependencies properly from maven profile ..In my case only x86 depdendecies shipped to APK. that means code above works only on x86 cpu architecture. solution should be done on Android Studio. but as workaround I did this:
Download binary javacv-platform-1.3.1-bin.zip. It's from: https://github.com/bytedeco/javacv
Inside directory javacv-bin copy these jars to new directory
ffmpeg-android-arm.jar
opencv-android-arm.jar
ffmpeg-android-x86.jar
opencv-android-x86.jar
For 2.1 2.2 files, Extract these jars and go to lib then or armeabi. Then copy all *.so files into your project under:
app/src/main/jniLibs/armeabi/
app/src/main/jniLibs/armeabi-v7a/
you might do the same with 2.3 * 2.4 jars by copying dependencies into app/src/main/jniLibs/x86/ . just check your apk if it really doesn't have them.
That's it.
I've set up an Gradle App Engine project and ported over my code that was working perfectly well. But on building the project through Gradle I get the following error:
20:28:32.036 [INFO] [org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler] Compiling with JDK Java compiler API.
20:28:32.088 [ERROR] [system.err] D:\Projects\WordBuzzIntegrated\wordbuzzserver\src\com\wrc\wordbuzzweb\service\Login.java:21: error: cannot access QueryResultIterable
20:28:32.088 [ERROR] [system.err] User user = ofy().load().type(User.class).id(facebookUser.id).now();
20:28:32.089 [ERROR] [system.err] ^
20:28:32.089 [ERROR] [system.err] class file for com.google.appengine.api.datastore.QueryResultIterable not found
I don't really have a clue what's causing the problem and Googling the error returns zero results. My dependencies list is as follows:
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.15'
providedCompile 'javax.servlet:servlet-api:2.5'
testCompile group: 'junit', name: 'junit', version: '4.11'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.3'
compile 'com.googlecode.objectify:objectify:5.1.1'
}
If anyone has any idea what might be going on here then your help would be greatly appreciated.
There are other App Engine dependencies that need to be included in the Gradle build. I ended up including all of the following for good measure - although I'm not sure all are required:
dependencies {
appengineSdk "com.google.appengine:appengine-java-sdk:$appEngineVersion"
compile "com.google.appengine:appengine-api-1.0-sdk:$appEngineVersion"
compile "com.google.appengine:appengine-endpoints:$appEngineVersion"
compile "com.google.appengine:appengine-endpoints-deps:$appEngineVersion"
compile "com.googlecode.objectify:objectify:5.1.1"
compile group: "com.google.guava", name: "guava", version: "18.0"
}
If using IntelliJ be sure to add the jars to your artifact for deployment.
If you want to run unit tests (junit included below) then you'll also need to add the following
testCompile group: "junit", name: "junit", version: "4.11"
testCompile "com.google.appengine:appengine-testing:$appEngineVersion"
testCompile "com.google.appengine:appengine-api-labs:$appEngineVersion"
testCompile "com.google.appengine:appengine-api-stubs:$appEngineVersion"
You'll also need to include the following in your Gradle script to set the app engine version. (Check what the latest version is)
ext.appEngineVersion = '1.9.21'
The Problem can be solved by adding the following dependendy in Gradle:
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.21'
You do not need to have the dependency for Cloud Endpoints if you are not using it, although it will also solve the problem as it has itself a dependeny on the missing one.
Ran into the same issue when generating a module with Android Studio which did not include this API. I could not even find any information on it in the documentation.