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)
Related
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"
}
I'm asking you about a very basic question but I hope you can find the time to help me:
I'm trying to realise a java-project, that can spit out several different programs which partially have dependencies on other projects of mine.
In order to keep it simple, I want to have all the code in one project, run by Gradle, so if I make changes to a central library (the database connector for example) all the child-programs automatically recieve the changes.
An example could look like this:
project:
program_A
central_library
program_B
output:
program_A.jar (including central library)
program_B.jar (including central library)
Now I'm having serious troubles finding a correct buildscript for this and was wondering if someone here could help me out.
P.S. : Since I'm new to this, if I should realize this through different modules within the Gradleproject instead of different packages in the Gradleprojects sourcefile, feel free to tell me :)
One way to approach this is to have a root project, that holds the three other projects inside of it.
Specify the sub-projects inside its settings.gradle file:
rootProject.name = 'RootProject'
include 'program_A'
include 'central_library'
include 'program_B'
With this in place, program_a can depend on central_library by adding a dependency in its build.gradle:
dependencies {
compile project(':central_library')
}
I have a similar setup in one of my projects, although the "central library" is the root project and the submodules are test environments.
Create a root directory and put each library or program into its own sub-directory.
Create a gradle project in each subproject.
You can for example create a skeleton gradle project by running
gradle init --type=java-library
or
gradle init --type=java-application
Then in the root directory create a gradle multi-module project. Basically
run only
gradle init
and then create a settings.gradle and list all sub-projects there.
This is actually described very well in the gradle documentation:
https://guides.gradle.org/creating-multi-project-builds/
If I understand correctly, what you want to do is, when you change your local projects, you want other projects to see those details. For this you need to publish your projects to some kind of repo, like maven repo. You can do this from command line gradle publishToMavenLocal, or gradle build pTMl. You can also do this in build.gradle file with something like the following:
task sourceJar (type : Jar) {
classifier = constants.extSources
from sourceSets.main.allSource
}
publications {
mavenJava(MavenPublication) {
from components.java
artifact(sourceJar) {
classifier "sources" //classifier = constants.extSources
}
}
}
I am quite new to React Native but I need to create an Android Module for the Honeywell CT50 barcode scanner.
I have created a libs folder in MyApp/android/app as stated in these two SO posts:
Post 1
Post 2
The second post says I must then add the package name to the dependencies something like this:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile 'com.facebook.react:react-native:0.19.+'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
}
This the part I am struggling with, the formatting of the name. Here's what the contents of the .jar file looks like:
I would like to reference the AidcManager to do this I have tried:
compile "com.honeywell.aidc.AidcManager"
compile "com.honeywell.aidc:AidcManager"
compile "com.honeywell.aidc:"
Each time I get an error during my build saying something like:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.honeywell.aidc:AidcManager:.
Searched in the following locations:
file:/Users/XXX/.m2/repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
file:/Users/XXX/.m2/repository/com/honeywell/aidc/AidcManager//AidcManager-.jar
https://jcenter.bintray.com/com/honeywell/aidc/AidcManager//AidcManager-.pom
https://jcenter.bintray.com/com/honeywell/aidc/AidcManager//AidcManager-.jar
file:/XXX/node_modules/react-native/android/com/honeywell/aidc/AidcManager//AidcManager-.pom
file:/XXX/node_modules/react-native/android/com/honeywell/aidc/AidcManager//AidcManager-.jar
file:/Users/XXX/Library/Android/sdk/extras/android/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
file:/Users/XXX/Library/Android/sdk/extras/android/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.jar
file:/Users/XXX/Library/Android/sdk/extras/google/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.pom
file:/Users/XXX/Library/Android/sdk/extras/google/m2repository/com/honeywell/aidc/AidcManager//AidcManager-.jar
Required by:
MyApp:app:unspecified
Can anyone point me in the right direction? Many thanks in advance.
Just copy .jar files in libs folder and import classes or packages from it in your .java file. There is no need to reference them in .gradle file.
Answering wayyyyyyy to late, but might be helpful to others who are looking for this answer,
just add .jar in libs, then add below into gradle
implementation files('libs/<YourJarName>.jar')
Or
Right click the jar and select "Add jar to project" option
I have the problem after adding module in gradle file.
Earlier I have following structure of my project
---app (main module)
---customview (dependency module add as `compile project` into the main module gradle file)
---daogenerator (separate module)
Daogenerator module was used as separate module to generate dao classes and model classes by Greendao library.
Everything was fine, but one problem that I should duplicate some common lets say Contract classes in both modules, so I decided to optimize and have only one file.
And as far as I cannot use classes from different modules if there are not specified in the gradle file as dependency.
So I added this line into my gradle file in the app module
compile project(':daogenerator')
After that I successfully imported common class but failed to compile the project. I got
finished with non-zero exit value 1 .....
Nothing more about the problem.
What I have already tried to do
Clean/Rebuild
Add dexOptions {
javaMaxHeapSize "4g"
jumboMode true
incremental true
} to the main app gradle file
Invalidate & Restart
Run ./gradlew assembleDebug --info got
Successfully started process 'command
'/usr/lib/jvm/java-8-oracle/bin/java'' PREDEX CACHE HITS: 0 PREDEX
CACHE MISSES: 1 Stopped 0 compiler daemon(s). Could not read standard
output of: command '/usr/lib/jvm/java-8-oracle/bin/java'.
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:170)
I have no idea what is wrong.
Sorry, this was my fault. I have forgotten that GreenDao library is simple java application it has entry point public static void main(String[] args) throws Exception
So it doesn't make any sense to compile it together with android application
Disclaimer:
I'm new to Gradle, have read a lot of docs, and I don't know whether my maven-style understanding is tripping me out, or whether it's the sleep dep (kids - don't ask), but I'm still not getting it.
Problem Background:
I have a project that consists of several modules.
One of the modules, let's call it data-structure defines a data structure
Another module, data-structure-fabsearch, defines an implementation for a data source for the data structure, and finally
A third module, fabsearch-common, defines some common data source classes (eg: connection management to a fabsearch data source etc).
The reason I've done it like this is because there's actually another module that also uses the fabsearch-common stuff.
Anyway, my data-structure-fabsearch build.gradle looks something like this:
dependencies {
compile project(:data-structure)
compile project(:fabsearch-common)
}
The fabsearch-common module declares depedencies for the fabsearch api (let's call it fabsearch-api-1.0.0).
So, the dependency tree for data-structure-fabsearch should look like this:
- data-structure-fabsearch
- data-structure
- fabsearch-common
- fabsearch-api-1.0.0
This was all working wonderfully last night. This morning I came to work and all of a sudden those dependencies don't resolve anymore. References to fabsearch-api-1.0.0 classes are no longer found.
What I've Tried
1. In the parent build.gradle:
project(':data-structure-fabsearch'){
apply plugin: 'java'
dependencies {
compile project(path: ':data-structure', configuration: 'compile')
compile project(path: ':fabsearch-common', configuration: 'compile')
}
}
I've tried this with and without the configuration setting.
2. In the data-structure-fabsearch build.gradle file, adding the configuration parameter.
3. Restarting IntelliJ
4. Clicking the refresh icon in the Gradle tool window (repeatedly)
5. Reading all about transitive dependencies in the Gradle user guides
6. Drinking tea (repeatedly)
None of the above work.
What I'm Expecting
I'm expecting that the fabsearch-common dependencies (the fabsearch-api jars) should also be included in the data-structure-fabsearch dependency tree. All references to fabsearch-api classes in data-structure-fabsearch should resolve etc etc.
My Question[s]
Whilst this is possible in Maven, is it possible in Gradle?
What do I have to do to get it to work?
How much sleep dep can you take without dying?
Many thanks for any help.
Turns out the problem wasn't gradle at all. The problem was IntelliJ.
It got it's knickers into a proper twist!
Solution:
1. Close the project in IntelliJ
2. Delete the .idea directory
3. Delete all .iml files and any other IntelliJ cra-useful files
4. Open project in IntelliJ, choose same directory. Problem disappears.