I'm having some trouble with Gradle and Android Studio. When trying to compile the dependency com.nukkitx.protocol:bedrock-v407:2.6.0-SNAPSHOT I'm getting duplicate class errors, but when compiled in a normal desktop Gradle project it compiles fine. Any help would be greatly appreciated.
Code: https://github.com/rtm516/GeyserAndroid
Error:
Duplicate class it.unimi.dsi.fastutil.ints.IntIterator found in modules jetified-fastutil-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-common:8.3.1) and jetified-fastutil-int-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-int-common:8.3.1)
Duplicate class it.unimi.dsi.fastutil.longs.LongIterator found in modules jetified-fastutil-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-common:8.3.1) and jetified-fastutil-long-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-long-common:8.3.1)
Duplicate class it.unimi.dsi.fastutil.objects.ObjectIterator found in modules jetified-fastutil-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-common:8.3.1) and jetified-fastutil-object-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-object-common:8.3.1)
Managed to fix this by using https://github.com/shevek/jarjar and removing the duplicate classes using the below.
implementation jarjar.repackage {
from 'com.nukkitx.fastutil:fastutil-common:8.3.1'
classDelete "it.unimi.dsi.fastutil.ints.IntIterator"
classDelete "it.unimi.dsi.fastutil.longs.LongIterator"
classDelete "it.unimi.dsi.fastutil.objects.ObjectIterator"
}
Related
Good morning friends, I need help.
This project needs to use these two libraries. And when compiling they are having a conflict because there are certain classes.
In fact, I already separated them as "independent" modules and I keep getting the error.
I call the two libraries in the build.gradle (:app) like this:
implementation project(path: ':smartill')
implementation project(path: ':smartill-mini-plus')
also, add in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Any ideas to separate them?
Error text:
Execution failed for task ':app:checkPaStagingDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class com.dm.commonlib.ThreadPoolManager found in
modules jetified-smart_minilib_v1.0.9-runtime.jar
(smart_minilib_v1.0.9.aar) and jetified-tilllib-runtime.jar (tilllib.aar)
Duplicate class com.dm.commonlib.Utils found in modules jetified-smart_minilib_v1.0.9-
runtime.jar (smart_minilib_v1.0.9.aar) and jetified-tilllib-runtime.jar (tilllib.aar)
I'm resuming work on an Android app that I haven't touched for a year. It used to build fine at the time. Now when I open it in Android Studio it complains that various libs, plugins, etc. are out of date. Trying to fix this myself, I couldn't get rid of all the sync/build errors, so in the end I updated Android Studio (from around 3.3, I think) to 3.5.2 and let it update whatever plugins etc. it wanted to.
Then I ran into issues indicating I should migrate from the old support packages to AndroidX (don't remember the details). To migrate, I then did the following:
Set compileSdkVersion to 28 for all modules
In all modules' build.gradle, updated the dependencies to 28
Added android.useAndroidX=true and android.enableJetifier=true to gradle.properties
Ran Refactor | Migrate to AndroidX...
Now Gradle sync works, but building fails with this error:
> Task :app:kaptDebugKotlin FAILED
e: [...]\app\build\tmp\kapt3\stubs\debug\com\[...]\MyClass.java:9: error: no interface expected here
public final class MyClass extends java.lang.Cloneable {
^
FAILURE: Build failed with an exception.
The above error is in generated code. My code, from which the above is generated, looks like this:
// MyClass.kt
class MyClass : Cloneable {
...
}
I understand java.lang.Cloneable is an interface, and the generated code has extends instead of implements. But as mentioned, this used to work, so what am I doing wrong?
I took another look at the project-level build.gradle and found it. Android Studio was suggesting to update the Kotline version again. I changed it to
ext.kotlin_version = '1.3.61'
and now I can compile.
I have to use PKCS10 class into my project. I tried to import sun.security.pkcs.PKCS10; into my activity code but studio shows "Cannot resolve symbol PKCS10" at both places where I have imported it and where I want to instantiat it.
Note: I haven't added any dependency or library (like .jar) to my project.
I want to know whether can it be automatically?
The class sun.security.pkcs10.PKCS10 was removed from the JDK. Using a class that was internal and already removed from the JDK is going a step beyond just using an internal API.
Put this into your build.gradle file.
compileJava {
options.forkOptions.javaHome = file(System.properties['java.home'])
}
And if this does not work, put this into you build.gradle(app) dependencies.
compile group: 'com.sun', name: 'rt', version: '1.5.0_06'
I was just starting to use the BodyEditorLoader.jar library but i got a NoSuchMethodError without any reason. Then i googled it and found a post on stackoverflow which wasn't useful and links were also broken but i came to know that the official library out there is buggy.
How do i fix this? Could not found the updated version of the library. Also some people provided the updated java file but how do i make it a library file as the library file contains the .class file and not the .java file.
Anyways here is the error:
java.lang.NoSuchMethodError: com.badlogic.gdx.utils.JsonReader.parse
and here is the code that gives the error:
BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json"));
From question it's seems you have some buggy BodyEditorLoader class, you can inject gdx-utils jar inside your core module and after that you can access BodyEditorLoader class inside your project, May be it solve your problem.
dependencies {
compile group: 'com.github.itsabhiaryan', name: 'gdx-utils', version: '1.0.1-SNAPSHOT'
}
Don't forget to refresh all of your gradle module.
I'm trying to import ActionBarSherlock (ABS) into my Android app using Gradle, but unfortunately, when building I get a list of errors saying:
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:248: error: Attribute "titleTextStyle" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:250: error: Attribute "subtitleTextStyle" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:256: error: Attribute "divider" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:258: error: Attribute "background" has already been defined
[etc. etc.]
* What went wrong:
Execution failed for task ':processDebugResources'.
> Could not call IncrementalTask.taskAction() on task ':processDebugResources'
I'm trying to import ABS using the following in build.gradle:
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.google.android.gms:play-services:4.0.30'
instrumentTestCompile(files('libs/espresso-1.0-SNAPSHOT-bundled.jar'))
}
and in my settings.gradle I've got the following line:
include ':OurPackage', ':Libraries:ActionBarSherlock'
Does anybody know what I'm doing wrong? All tips are welcome!
The same attributes titleTextStyle, subtitleTextStyle, divider, background are defined in 2 different libraries.
The 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar' and the support library 'com.android.support:support-v4:18.0.+' which introduced the v7 appcompat library can't work together.