- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在我的项目中使用了多个 Android 库和模块。每个都有自己的 v4.Support 库。我收到了 java.util.zip.ZipException: duplicate entry 。 当我在项目中搜索重复的类文件时,这些类有多个文件,因为每个库中有多个 v4.support 库。我知道这个问题在这里被问过很多次,但对我没有任何帮助。
我的问题是:如何删除这些多个 v4.support 文件?我只想把这个 v4.support 库放一次,所有其他模块都应该从那里引用它。我如何实现这一点?
以下是我的build.gradle脚本
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
//classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
classpath 'io.fabric.tools:gradle:1.15.2'
}
}
apply plugin: 'android'
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
transitive = true
}
compile('com.android.support:multidex:1.0.0')
//compile ('com.android.support:appcompat-v7:22.1.0')
compile project(':..:..:..:..:..:..:android_libraries:appcompat')
compile project(':..:..:..:..:..:..:android_libraries:facebook')
compile project(':..:..:..:..:..:..:android_libraries:google_play_services:libproject:google-play-services_lib')
compile project(':..:..:..:..:..:..:android_libraries:SlidingMenu')
compile project(':..:..:..:..:..:..:android_libraries:StickingGridViewLibrary')
compile project(':..:..:..:..:..:..:android_libraries:view_pager_library')
compile project(':..:..:..:..:..:..:android_libraries:ZXing2.3')
compile project(':..:..:..:..:..:..:android_libraries:xyz')
compile project(':..:..:..:..:..:..:android_libraries:apptentive')
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 15
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
ant.importBuild './../../../../../../buildscripts/wlbuild.xml'
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
resourcePackageName 'com.kohls.mcommerce.opal'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.applicationId
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildDir = './../../../../../../build/native'
lintOptions {
abortOnError false
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
我遇到了这样的错误。每次我清理项目时,它都会成功遵守。但是,当我尝试发出 Run 命令时,它会显示以下类型的错误。
Execution failed for task ':packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/media/TransportMediatorCallback.class
最佳答案
当我解决上述问题并找到克服它的方法时。 packageAllDebugClassesForMultiDex 错误的主要原因与您在 Stackoverflow 的所有其他帖子中发现的相同,即您必须有一些类文件在项目中多次可用。就我而言,我在上面的项目中有很多模块,如 Facebook、谷歌支付服务和滑动菜单等。所有这些模块都有自己的 v4.support jar 文件副本。我所做的是从所有这些库 libs 文件夹中删除所有 v4.support 文件。然后从我的 sdk 添加对 v4.support 库的依赖,即来自 Android Studio 项目结构的 com.android.support 库。为此..
2* 一一选择这些模块中的每一个。
3* 在最后一个名为 Dependency 的选项卡中,如果您只有 v4.support lib(或有问题的)在该模块的 libs 文件夹中。
4* 单击 + 添加 v4.support 库,然后添加库并选择v4.support 来自您的 sdk 的库。
完成了。清理项目并重新构建它。packageAllDebugClassesForMultiDex 问题已经解决。
至于传递依赖,如果你在构建项目时知道导致Duplicate file in dex错误的确切依赖,你可以将其排除为belo
compile(project(':..:..:..:..:..:..:android_libraries:walletsdkandroidmodule')) {
exclude group: 'com.google.code.gson'
}
如果你想要任何模块中的任何传递依赖,例如。
compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
transitive = true
}
关于java.util.zip.ZipException : duplicate entry :how to overcome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30567821/
我在这个网站上发布的代码有这个问题 https://developers.google.com/drive/quickstart-cs是 Google Drive 快速入门的开发人员站点。我按照网站上
我正在尝试制作一个非常简单的 Kafka Producer,目前正在关注 producer example除了我的制作人没有分区程序类。 将所需文件导出到 jar 后,我将它们传输到我的 Linux
问题 在java中,我有一个“Util项目”,在进行单元测试时使用另一个“Mock项目”。 我的问题是“模拟项目”也使用“Util项目”来构建一些模拟对象。 当我使用 Maven 构建项目时,我无法构
据我所知,这些包已经存在很长时间了。但是,我从未见过它们的实际用法。而且这些包似乎不成熟,不再维护。如果是,为什么这些包现在存在? 最佳答案 包裹automata被 scala.xml.dtd 使用,
关闭。这个问题需要debugging details .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 1年前关闭。 Improve this question Co
在java.util.Collections中,有一个方法: public static void fill(List list, T obj) 用第二个参数指定的对象填充第一个参数指定的List。
我不明白它要我做什么。分配给 sentence正在工作: val sentences : java.util.List[CoreMap] = document.get(classOf[Sentence
在我的 React 应用程序中,我想使用一些实用程序。我见过两种不同的方法。第一个是,只是创建函数并将其导出。第二个是,创建一个 Util 类并导出一个对象,这样它就不能被实例化(静态类)。 clas
我有一个 util 类,它接受 String jwtToken 和 Key key 并使用 io.jsonwebtoken.jwts 解码 jwt。 但是,我无法对此进行测试。原因是,我无法模拟公钥并
我有使用目标命名空间的专有架构 xmlns:ax216="http://util.java/xsd" 这给我带来了从 java (java.util.xsd) 开始生成禁止的(由 Java 安全管理器
我正在阅读集合以查看 Javadocs 中的实现层次结构。 Collections声明为public class Collections extendds Object Collection声明为pu
我正在使用 Spring-boot 应用程序,我可以在其中连接 Azure 应用程序配置。但是当我尝试使用内容类型应用程序/JSON 读取值时出现错误。 我的Java类 @ConfigurationP
我正在使用 Spring-boot 应用程序,我可以在其中连接 Azure 应用程序配置。但是当我尝试使用内容类型应用程序/JSON 读取值时出现错误。 我的Java类 @ConfigurationP
我在使用格式说明符时遇到问题。这是否意味着我正在使用 %d? public static void main(String[] args) { double y, x; for (x =
鉴于此代码 import java.util.Iterator; private static List someList = new ArrayList(); public static void
我正在 HackerEarth 解决问题,我无法弄清楚为什么我的程序在命令行上正确运行并给出正确的结果,但在代码编辑器上运行时却给出 java.util.NoSuchElementException
我正在尝试使用以下代码使用对象列表列表中的数据填充tableModel readExcel.readSheet(0): TableModel tableModel = new DefaultTabl
java.util.Set 、 java.util.List 和其他 Collection 接口(interface)不可序列化。需要一个简单、直接的解决方案来在可序列化的 POJO 中使用它。 pu
我试图从 servlet 返回数据库搜索结果的 ArrayList 以显示在 jsp 页面上。 在servlet中设置arraylist作为请求的属性,并将请求转发到jsp页面。当我尝试在 jsp 页
我是android新手,最近我试图从firebase中提取数据到recyclerview/cardview中以垂直布局显示数据,它显示将Hashmap转换为Arraylist的错误,其中代码是:
我是一名优秀的程序员,十分优秀!