【问题标题】:Multiple dex files define: when I am adding admob. this is due to ActionbarSherlock Lib多个 dex 文件定义:当我添加 admob.这是由于 ActionbarSherlock Lib
【发布时间】:2015-07-14 18:27:12
【问题描述】:

当我将 admob 添加到 gradle 文件时,我收到“com.android.dex.DexException: Multiple dex files defined Landroid/support/annotation/AnimRes;”。这是由于 ActionBarSherlock 库而发生的。在google上搜索后,有人建议删除support v4 jar文件。但是这个解决方案也不起作用。请帮我解决问题。

编辑

我的 Gradle 文件:

buildscript {
    repositories {
        mavenCentral() // or jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3'
    }
}
apply plugin: 'com.android.application'
dependencies {
    compile files('libs/bolts-android-1.1.4.jar')
    compile files('libs/bolts-android-1.1.4-javadoc.jar')
    compile files('libs/picasso-2.3.4.jar')
    compile files('libs/Parse-1.8.3.jar')
    compile project(':CustomTabLib')
    compile project(':simple-crop-image-lib')
    compile project(':slideDateTimePicker')
    compile files('libs/gcm.jar')
    //    compile files('libs/google-play-services.jar')
    //    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.google.android.gms:play-services-ads:7.5.0'
    compile files('libs/libphonenumber-7.0.7.jar')
    compile project(':ActionbarSherlockLibrary')
}
android {
    compileSdkVersion 21
    buildToolsVersion "22.0.0"
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    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')
    }
//    dexOptions {
//        preDexLibraries = false
//    }

}

我已经编辑了我的问题@Destro。

【问题讨论】:

  • 有没有加注解jar?
  • 感谢您的及时回复。我没有添加注释罐。由于 ActionbarSherlock Lib,我收到此错误。但无法找到解决方案。
  • 给我看看腰带文件代码..
  • 然后检查是否有注释jar可用
  • @user3676184 你的意思是在我的代码中吗?

标签: android


【解决方案1】:

试试这个如果您与 v4 支持库存在依赖冲突,您可以通过 gradle 脚本将其从其中一个库中排除:

例如

compile ('com.android.support:recyclerview-v7:+') {
    exclude module: 'support-v4'
}

【讨论】:

猜你喜欢
  • 2013-01-22
  • 1970-01-01
  • 1970-01-01
  • 2015-03-24
  • 1970-01-01
  • 1970-01-01
  • 2014-03-14
  • 2023-03-03
相关资源
最近更新 更多