Skip to content

Commit f7e74f5

Browse files
madeyeclaude
andcommitted
Dedupe jniLibs.srcDirs to fix mergeJniLibFolders dup on AGP 8.5
MergeSourceSetFolders does not expose duplicatesStrategy. The actual fix is to dedupe android.sourceSets.*.jniLibs.srcDirs at configure time so each ABI's libproxydroid_tun2socks.so is only listed once. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 385f2fe commit f7e74f5

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

app/build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ android {
8686
}
8787
}
8888

89-
// rust-android-gradle 0.9.6 registers its build/rustJniLibs/<abi> output as a
90-
// JNI source dir, while AGP 8.5+ also captures the same path via the
91-
// cargoBuild task outputs, making mergeJniLibFolders see each .so twice and
92-
// fail with "Duplicate resources". Tell the merge Copy task to silently keep
93-
// one copy.
94-
tasks.matching {
95-
it.name.startsWith("merge") && it.name.endsWith("JniLibFolders")
96-
}.configureEach {
97-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
89+
// rust-android-gradle 0.9.6 ends up registering its build/rustJniLibs/<abi>
90+
// directory in jniLibs.srcDirs twice under AGP 8.5+, causing
91+
// mergeJniLibFolders to fail with "Duplicate resources" on every ABI's .so.
92+
// Deduplicate srcDirs at configure time. MergeSourceSetFolders is not a
93+
// Copy task, so duplicatesStrategy doesn't help here.
94+
afterEvaluate {
95+
android.sourceSets.configureEach { sourceSet ->
96+
sourceSet.jniLibs.srcDirs = sourceSet.jniLibs.srcDirs.toSet().toList()
97+
}
9898
}
9999

100100
cargo {

0 commit comments

Comments
 (0)