crux
crux copied to clipboard
Type com.novi.serde.ArrayLen is defined multiple times
Hi, I encountered the same problem as #109 . When I was building the release package, it kept failing:
Type com.novi.serde.ArrayLen is defined multiple times: /Users/ontwang/.gradle/caches/transforms-3/0fce63b0b50a8e8efde10c93f35c117f/transformed/jetified-client-sdk-java-1.0.5.jar:com/novi/serde/ArrayLen.class, /Users/ontwang/Documents/xxx/xxxxx/ji_app/platform/android/bloc/build/intermediates/runtime_library_classes_jar/release/classes.jar:com/novi/serde/ArrayLen.class
I tried to get the latest example from crux master. After modifying the build.grale, it still didn’t work with same error. And My global dependencies were also removed from diem. These attempts took me a whole day. I want to know why I still get this error when novi is no longer in my dependency tree.
android {
namespace 'com.minij.app.bloc'
compileSdk 33
ndkVersion '25.2.9519653'
defaultConfig {
minSdk 26
targetSdk 33
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += "${projectDir}/../../../models/generated/java/com"
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation "net.java.dev.jna:jna:5.12.1@aar"
implementation('com.diem:client-sdk-java:1.0.5') {
exclude group: 'org.bouncycastle', module: 'bcprov-jdk15to18'
exclude group: 'com.novi.serde', module: 'ArrayLen'
}
}
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
cargo {
pythonCommand = "python3"
module = "../../.."
libname = "bloc"
targets = ["arm64"]
extraCargoBuildArguments = ['--package', 'bloc']
}
afterEvaluate {
// The `cargoBuild` task isn't available until after evaluation.
android.libraryVariants.all { variant ->
def productFlavor = ""
variant.productFlavors.each {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks.named("compileDebugKotlin") {
it.dependsOn(tasks.named("typesGen"), tasks.named("bindGen"))
}
tasks.named("generate${productFlavor}${buildType}Assets") {
// it.dependsOn(tasks.named("cargoBuild"),tasks["createSymlink"])
it.dependsOn(tasks.named("cargoBuild"))
}
}
}
tasks.register('bindGen', Exec) {
def outDir = "${projectDir}/src/main/java"
workingDir "../../../"
commandLine(
"sh", "-c",
"""\
cargo build -p bloc && \
target/debug/uniffi-bindgen generate bloc/src/bloc.udl \\
--language kotlin \
--out-dir $outDir
"""
)
}
tasks.register('typesGen', Exec) {
workingDir "../../"
commandLine("sh", "-c", "cargo build -p models")
}
tasks.register( 'createSymlink',Exec) {
def libblocPath = "bloc/build/rustJniLibs/android/arm64-v8a/libbloc.so"
def jniLibsPath ="app/src/main/jniLibs/arm64-v8a/libbloc.so"
workingDir "../"
commandLine(
'cp', '-f', libblocPath,jniLibsPath
)
}
and i try to modify bindGen for cargo build -r bloc && \
, not work
and i try to delete anything of diem
,it take error :
Missing class com.google.common.collect.ArrayListMultimap (referenced from: java.lang.Object com.alibaba.fastjson.serializer.GuavaCodec.deserialze(com.alibaba.fastjson.parser.DefaultJSONParser, java.lang.reflect.Type, java.lang.Object))
Missing class com.google.common.collect.Multimap (referenced from: void com.alibaba.fastjson.serializer.GuavaCodec.write(com.alibaba.fastjson.serializer.JSONSerializer, java.lang.Object, java.lang.Object, java.lang.reflect.Type, int))
Missing class dalvik.system.VMStack (referenced from: void com.tencent.smtt.export.external.DexLoader.<init>(java.lang.String, android.content.Context, java.lang.String[], java.lang.String, java.util.Map))
Missing class java.awt.Color (referenced from: java.lang.Object com.alibaba.fastjson.serializer.AwtCodec.deserialze(com.alibaba.fastjson.parser.DefaultJSONParser, java.lang.reflect.Type, java.lang.Object) and 3 other contexts)
Missing class java.awt.Font (referenced from: java.lang.Object com.alibaba.fastjson.serializer.AwtCodec.deserialze(com.alibaba.fastjson.parser.DefaultJSONParser, java.lang.reflect.Type, java.lang.Object) and 3 other contexts)
Missing class java.awt.Point (referenced from: java.lang.Object com.alibaba.fastjson.serializer.AwtCodec.deserialze(com.alibaba.fastjson.parser.DefaultJSONParser, java.lang.reflect.Type, java.lang.Object) and 3 other contexts)
and i try to add
packagingOptions {
exclude 'com/novi/serde/*'
}
still not work ....
Looking forward reply, thanks
Read #108 again and confirm that the solution is probably to remove the reference of diem
, and then modify the missing class reference in another way. This will take much time. I think the best way is to update this part of the function in crux
Hey @wxcaixiaowei thanks for raising this. I did notice that the cat_facts
example still had a couple of references to the diem
deps, which I've now removed and pushed to master. You shouldn't need any external dependencies now, as they are all provided as part of the typesGen
task in the shared build.gradle
. To include them make sure that the sourceSets
are correct. In the examples we have it like this:
sourceSets {
main.java.srcDirs += "${projectDir}/../../shared_types/generated/java"
}
and I noticed you have an extra ../
in yours. Check that it resolves to the correct directory.
LMK if you're still having problems. Happy to work with you until they are resolved (and the feedback is very useful).
i
Hey @wxcaixiaowei thanks for raising this. I did notice that the
cat_facts
example still had a couple of references to thediem
deps, which I've now removed and pushed to master. You shouldn't need any external dependencies now, as they are all provided as part of thetypesGen
task in the sharedbuild.gradle
. To include them make sure that thesourceSets
are correct. In the examples we have it like this:sourceSets { main.java.srcDirs += "${projectDir}/../../shared_types/generated/java" }
and I noticed you have an extra
../
in yours. Check that it resolves to the correct directory.LMK if you're still having problems. Happy to work with you until they are resolved (and the feedback is very useful).
Thanks for your reply.
additional ../
is depends on my project directory, because this project is shared by Android and iOS, we all feel that the location of your rust code is not in line with our habits, so we changed the location independently in the project directory, i think it's not a problem. because in debug
flavor works.
in fact, I have tried the reference method without adding any diem
, but my confusion R8
task will report an error, the specific error path:
Missing class com.google.common.collect.ArrayListMultimap (referenced from: java.lang.Object com.alibaba.fastjson.serializer.GuavaCodec.deserialze(com.alibaba.fastjson.parser.DefaultJSONParser, java.lang.reflect.Type, java.lang.Object))
Missing class com.google.common.collect.Multimap (referenced from: void com.alibaba.fastjson.serializer.GuavaCodec.write(com.alibaba.fastjson.serializer.JSONSerializer, java.lang.Object, java.lang.Object, java.lang.reflect.Type, int))
Missing class dalvik.system.VMStack (referenced from: void com.tencent.smtt.export.external.DexLoader.<init>(java.lang.String, android.content.Context, java.lang.String[], java.lang.String, java.util.Map))
Missing class java.awt.Color (referenced from: java.lang.Object com.alibaba.fastjson.serializer.AwtCodec.deserialze(com.alibaba.fastjson.parser.DefaultJSONParser, java.lang.reflect.Type, java.lang.Object) and 3 other contexts)
Missing class java.awt.Font (referenced from: java.lang.Object com.alibaba.fastjson.serializer.AwtCodec.deserialze(com.alibaba.fastjson.parser.DefaultJSONParser, java.lang.reflect.Type, java.lang.Object) and 3 other contexts)
Missing class java.awt.Point (referenced from: java.lang.Object com.alibaba.fastjson.serializer.AwtCodec.deserialze(com.alibaba.fastjson.parser.DefaultJSONParser, java.lang.reflect.Type, java.lang.Object) and 3 other contexts)
Now it is getting closer to the release time of my project, I have to use cargo build -r
to package my rust code, manually place the so file under the jnilibs
of the project, and then minify enabled false to make my generate signed apk work
So my question is how to make my proguard task
not report an error without relying on diem
. Thanks again for your reply,Looking forward to your reply again if you can help me