gpt4 book ai didi

android - Gradle依赖问题android

转载 作者:行者123 更新时间:2023-11-29 17:31:33 26 4
gpt4 key购买 nike

我注意到 io.reactive 和 estimote 的 sdk 之间存在冲突,但我似乎无法弄清楚如何解决它。老实说,我只是通过删除 estimote 依赖项然后删除两个 reactivex 依赖项并找到项目功能来注意到冲突。我尝试排除公共(public)库,但似乎没有任何效果。这是我所有的东西:

原始错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

Gradle :

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


buildscript {
repositories {

//
maven { url 'https://maven.fabric.io/public' }
}

dependencies {



classpath 'io.fabric.tools:gradle:1.+'
}
}



repositories {
mavenCentral()
//
maven { url 'https://maven.fabric.io/public' }
}

android {

compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "com.whats.up"
minSdkVersion 18
targetSdkVersion 18
versionCode 49
versionName "2.0"
}



buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}

lintOptions {
abortOnError false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'uk.co.chrisjenx:calligraphy:2.0.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mixpanel.android:mixpanel-android:4.5.3'
compile 'com.google.android.gms:play-services:6.+'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile project(":libs:library")
compile 'io.realm:realm-android:0.81.1'
compile files('libs/cwac-merge-1.1.1-2.jar')
compile files('libs/cwac-camera-0.6.12.jar')
compile 'com.makeramen:roundedimageview:2.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.android.support:cardview-v7:22.1.1'
compile('com.twitter.sdk.android:twitter:1.0.0@aar') {
transitive = true;
}
compile 'io.reactivex:rxandroid:1.0.1'
compile 'io.reactivex:rxjava:1.0.0'
compile ('com.estimote:sdk:0.8.6@aar'){
//
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
exclude module: 'support-annotations'
exclude module: 'junit'
exclude module: 'io.reactivex'
exclude group: 'com.google.android'
exclude group: 'com.google.android.*'
exclude group: 'com.google.code.findbugs'
exclude group: 'com.android.dx'
}
compile('com.twitter.sdk.android:tweet-composer:0.7.0@aar')
{
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
transitive = true;

}
}

./gradlew -q 应用程序:依赖项:

compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:21.0.+ -> 21.0.3
| \--- com.android.support:support-v4:21.0.3 -> 22.0.0
| \--- com.android.support:support-annotations:22.0.0
+--- com.android.support:support-v4:20.0.+ -> 22.0.0 (*)
+--- uk.co.chrisjenx:calligraphy:2.0.1
+--- com.squareup.retrofit:retrofit:1.9.0
| \--- com.google.code.gson:gson:2.3.1
+--- com.squareup.picasso:picasso:2.5.2
+--- com.mixpanel.android:mixpanel-android:4.5.3
+--- com.google.android.gms:play-services:6.+ -> 6.5.87
| \--- com.android.support:support-v4:21.0.0 -> 22.0.0 (*)
+--- com.github.ksoichiro:android-observablescrollview:1.5.2
| \--- com.android.support:recyclerview-v7:21.0.0
| \--- com.android.support:support-v4:21.0.0 -> 22.0.0 (*)
+--- com.nineoldandroids:library:2.4.0
+--- com.github.castorflex.smoothprogressbar:library:1.1.0
+--- project :libs:library
| \--- com.android.support:support-v4:22.0.0 (*)
+--- io.realm:realm-android:0.81.1
+--- com.makeramen:roundedimageview:2.1.0
+--- com.facebook.android:facebook-android-sdk:4.0.0
| +--- com.android.support:support-v4:[21,22) -> 22.0.0 (*)
| \--- com.parse.bolts:bolts-android:1.1.4
+--- com.android.support:cardview-v7:22.1.1
+--- com.twitter.sdk.android:twitter:1.0.0
| +--- com.twitter.sdk.android:tweet-composer:0.7.0
| | +--- com.twitter.sdk.android:twitter-core:1.0.0
| | | +--- com.squareup.retrofit:retrofit:1.6.1 -> 1.9.0 (*)
| | | +--- io.fabric.sdk.android:fabric:1.0.0 -> 1.3.5
| | | \--- com.google.code.gson:gson:2.2.4 -> 2.3.1
| | \--- io.fabric.sdk.android:fabric:1.0.0 -> 1.3.5
| +--- com.digits.sdk.android:digits:1.0.0
| | +--- com.twitter.sdk.android:twitter-core:1.0.0 (*)
| | +--- io.fabric.sdk.android:fabric:1.0.0 -> 1.3.5
| | \--- com.twitter.sdk.android:tweet-ui:1.0.0
| | +--- com.twitter.sdk.android:twitter-core:1.0.0 (*)
| | +--- com.squareup.picasso:picasso:2.3.2 -> 2.5.2
| | +--- io.fabric.sdk.android:fabric:1.0.0 -> 1.3.5
| | \--- com.android.support:support-v4:21.0.0 -> 22.0.0 (*)
| +--- com.twitter.sdk.android:twitter-core:1.0.0 (*)
| +--- io.fabric.sdk.android:fabric:1.0.0 -> 1.3.5
| \--- com.twitter.sdk.android:tweet-ui:1.0.0 (*)
+--- io.reactivex:rxandroid:1.0.1
| \--- io.reactivex:rxjava:1.0.13
+--- io.reactivex:rxjava:1.0.0 -> 1.0.13
+--- com.estimote:sdk:0.8.6
+--- com.twitter.sdk.android:tweet-composer:0.7.0 (*)
\--- com.crashlytics.sdk.android:crashlytics:2.5.1
+--- io.fabric.sdk.android:fabric:1.3.5
+--- com.crashlytics.sdk.android:crashlytics-core:2.3.4
| +--- io.fabric.sdk.android:fabric:1.3.5
| \--- com.crashlytics.sdk.android:answers:1.3.1
| \--- io.fabric.sdk.android:fabric:1.3.5
+--- com.crashlytics.sdk.android:beta:1.1.3
| \--- io.fabric.sdk.android:fabric:1.3.4 -> 1.3.5
\--- com.crashlytics.sdk.android:answers:1.3.1 (*)

我不太确定如何解释那里的最后一部分 - 所以如果我的问题被发现,我很想知道如何找到它以供将来引用!谢谢!

最佳答案

简单的不推荐的修复是:

在您应用的 build.gradle 中:

android {
...
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}

dependencies {
compile 'com.android.support:multidex:1.0.0'
}

在你的 AndroidManifest.xml 中:

<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>

原因:

Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.

此处所有详细信息:Building Apps with Over 65k Methods .

虽然给出的答案将是解决您当前问题的快速方法,但 Android 不建议您这样做,或者至少建议您尽可能避免这样做。

减少您的 dexcount

尽量避免依赖大型开源项目,除非您确实需要它们。如果您无法避免这些,请巧妙地使用它们。 GooglePlayServices 等一些库为您提供了使用其 API 的子集来防止此类问题的发生。

例如,您有:

com.google.android.gms:play-services:6.+ // The ENTIRE play-services library

您真的需要整个播放服务库吗?该库非常庞大,Google 为您提供了仅使用所需组件的方法,假设您想使用 Google 帐户登录,您可以采用以下方式:

com.google.android.gms:play-services-identity:X.+ // Google Account Login only
com.google.android.gms:play-services-analytics:X.+ // Google Analytics
com.google.android.gms:play-services-maps:X.+ // Google Maps...
// ... and so on.

有关播放服务的各个 API 列表,请参阅 Setting Up Google Play Services

跟踪您的 dexcount

有几个库可以帮助您跟踪您的 dexcount 以防止您达到限制。一个例子:

Dexcount Gradle Plugin

此库将跟踪您的 dexcount 并在您构建时报告它,例如:

> ./gradlew assembleDebug

...buildspam...
:app:compileDebugSources
:app:preDexDebug UP-TO-DATE
:app:dexDebug
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug
Total methods in MyApp-debug-5.3.14.apk: 56538

关于android - Gradle依赖问题android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32622181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com