之前删除重复的罐子
我正在尝试使用两个视频聊天库(Opentok和Skylink)的React-Native应用程序。两者都使用org.webrtc(libjingle),在构建过程中,我们有一个问题:
10:37:08.661 [DEBUG] [com.android.build.gradle.internal.transforms.JarMerger] addJar(/home/(hidden)/Projects/work/(hidden)/android/app/build/intermediates/exploded-aar/com.facebook.fresco/fbcore/0.11.0/jars/classes.jar): entry com/facebook/datasource/SimpleDataSource.class
10:37:08.661 [DEBUG] [com.android.build.gradle.internal.transforms.JarMerger] addJar(/home/(hidden)/Projects/work/(hidden)/android/app/build/intermediates/exploded-aar/com.facebook.fresco/fbcore/0.11.0/jars/classes.jar): entry com/facebook/fbcore/BuildConfig.class
10:37:08.661 [DEBUG] [com.android.build.gradle.internal.transforms.JarMerger] addJar(/home/(hidden)/Projects/work/(hidden)/android/app/build/intermediates/exploded-aar/com.opentok.android/opentok-android-sdk/2.10.1-REL-2756/jars/libs/libjingle_peerconnection_java.jar)
10:37:08.661 [DEBUG] [com.android.build.gradle.internal.transforms.JarMerger] addJar(/home/(hidden)/Projects/work/(hidden)/android/app/build/intermediates/exploded-aar/com.opentok.android/opentok-android-sdk/2.10.1-REL-2756/jars/libs/libjingle_peerconnection_java.jar): entry org/webrtc/NetworkMonitor.class
10:37:08.665 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:transformClassesWithJarMergingForDebug'
10:37:08.665 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :app:transformClassesWithJarMergingForDebug FAILED
10:37:08.665 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :app:transformClassesWithJarMergingForDebug (Thread[main,5,main]) completed. Took 0.523 secs.
10:37:08.665 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 2.954 secs, idle: 0.226 secs
10:37:08.672 [ERROR] [org.gradle.BuildExceptionReporter]
10:37:08.709 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
10:37:08.710 [ERROR] [org.gradle.BuildExceptionReporter]
10:37:08.710 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
10:37:08.710 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
10:37:08.710 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/webrtc/NetworkMonitor.class
10:37:08.710 [ERROR] [org.gradle.BuildExceptionReporter]
10:37:08.710 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
10:37:08.710 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
10:37:08.711 [LIFECYCLE] [org.gradle.BuildResultLogger]
10:37:08.711 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
10:37:08.711 [LIFECYCLE] [org.gradle.BuildResultLogger]
10:37:08.712 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 16.878 secs
10:37:08.836 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileHashes.bin (/home/(hidden)/Projects/work/(hidden)/android/.gradle/2.14.1/taskArtifacts/fileHashes.bin)
10:37:08.836 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileSnapshots.bin (/home/(hidden)/Projects/work/(hidden)/android/.gradle/2.14.1/taskArtifacts/fileSnapshots.bin)
10:37:08.836 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache taskArtifacts.bin (/home/(hidden)/Projects/work/(hidden)/android/.gradle/2.14.1/taskArtifacts/taskArtifacts.bin)
10:37:08.836 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on task history cache (/home/(hidden)/Projects/work/(hidden)/android/.gradle/2.14.1/taskArtifacts).
10:37:08.837 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedRepositoryFactory] In-memory dependency metadata cache closed. Repos cached: 1316, cache instances: 10, modules served from cache: 18503, artifacts: 3602
10:37:08.840 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 0 (avg: 0.0 secs, total: 0.0 secs)
10:37:08.840 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 146 (avg: 0.0 secs, total: 0.125 secs)
10:37:08.840 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.ResolutionResultsStoreFactory] Deleted 2 resolution results binary files in 0.003 secs
10:37:08.840 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-metadata.bin (/home/(hidden)/.gradle/caches/modules-2/metadata-2.16/module-metadata.bin)
10:37:08.840 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache artifact-at-repository.bin (/home/(hidden)/.gradle/caches/modules-2/metadata-2.16/artifact-at-repository.bin)
10:37:08.840 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-versions.bin (/home/(hidden)/.gradle/caches/modules-2/metadata-2.16/module-versions.bin)
10:37:08.840 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-artifacts.bin (/home/(hidden)/.gradle/caches/modules-2/metadata-2.16/module-artifacts.bin)
10:37:08.840 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on artifact cache (/home/(hidden)/.gradle/caches/modules-2).
10:37:08.840 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Generated Gradle JARs cache (/home/(hidden)/.gradle/caches/2.14.1/generated-gradle-jars) was closed 0 times.
10:37:08.840 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Plugin Resolution Cache (/home/(hidden)/.gradle/caches/2.14.1/plugin-resolution) was closed 0 times.
10:37:08.841 [DEBUG] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopping 0 compiler daemon(s).
10:37:08.841 [INFO] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopped 0 compiler daemon(s).
在opentok build.gradle中我们有:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
}
dependencies {
compile 'com.facebook.react:react-native:+'
compile('com.opentok.android:opentok-android-sdk:2.10.+') {
exclude group: 'org.webrtc'
}
compile project(':react-native-permission-helper')
}
和Skylink Build.gradle
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
}
dependencies {
compile fileTree(include: '*.jar', excludes: ['libjingle_peerconnection.jar', 'libjingle_peerconnection_java.jar'], dir: 'libs')
compile(group: 'sg.com.temasys.skylink.sdk', name: 'skylink_sdk', version: '0.9.7-RELEASE', ext: 'aar')
compile 'com.facebook.react:react-native:+'
compile project(':react-native-permission-helper')
}
但是这种配置仍然不起作用。在最终构建步骤中,两个" libjingle_peerconnection.jar"仍在包括。我可以为此获得一些帮助吗?我们可以控制Gradle构建脚本,但不能控制第三方SDK。
我能够通过在我的主构建中添加以下任务来解决此问题(尽管以短速度的方式)。
tasks.create("excludeTask") << {
File file = file("${buildDir}/intermediates/exploded-aar/com.opentok.android/opentok-android-sdk/2.10.1-REL-2756/jars/libs/libjingle_peerconnection_java.jar");
println("Excluding file " + file)
if (file.exists()) {
file.delete();
}
}
tasks.whenTaskAdded({
if (it.name.matches(/^process.*Resources$/)) {
it.dependsOn excludeTask
}
})
这会在链接