我想在我的应用程序中添加新的 Twitter SDK - Fabric。 (用于登录的 Crashlitycs 和 Twitter 套件)。当我从文档中添加代码行时,我发现了异常。 这可能是由于 twitter4j 造成的吗?
这个build.gradle
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc4'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':facebookSDK')
compile project(':vKOpenAuthActivity')
compile project(':easyFousquareActivity')
compile project(':pullToRefresh')
compile project(':volley')
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.android.support:support-v4:20.+'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'com.nineoldandroids:library:2.4.0+'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.daimajia.slider:library:1.0.9@aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile files('libs/commons-codec-1.9.jar')
compile files('libs/signpost-commonshttp-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.2.jar')
compile files('libs/twitter4j-core-4.0.1.jar')
compile files('libs/libGoogleAnalytics.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/gson-2.2.4.jar')
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5'
compile 'org.apache.httpcomponents:httpmime:4.3.5'
compile('com.crashlytics.sdk.android:crashlytics:2.2.0@aar') {
transitive = true;
}
compile('com.twitter.sdk.android:twitter:1.0.0@aar') {
transitive = true;
}
}
还有这个异常日志
Error:Execution failed for task ':driverNotes:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\adt-bundle-windows-x86_64-20140702\sdk\build-tools\19.1.0\dx.bat --dex --no-optimize --output D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\dex\debug D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\classes\debug D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\support-annotations-21.0.0-b76b65b1fe9276422260c698604a040d15a30153.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-e77b301e38499bac0683d399ce255f21d43d2e14.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-1471c5ae018b4f413dc93e3546e88ff79e13bc04.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\signpost-commonshttp-1.2.1.1-641257b3c31db915e3858b4266dcc3a6153e50e1.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-241f53d6fd8b59b693390c641bfb3b8877361b85.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-41f8026282447b753e85078b5dd173dfa8989225.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\httpmime-4.3.5-56919f65c3584d0b98a7e247552b9427eac0cbaa.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\signpost-core-1.2.1.2-9b230f95742f31cfb79e3303773f76639b28b354.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-3fc943c5785dbc91d555ed02c7c8252152bc6f52.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-e13865fc62be229a69c66fb1d81901e8ebd98615.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\foursquare-api-1.0.2-1f909ec752123e1158d9e956253859c675f4453f.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-bede49833ea7cbdd4ca9965ea52dd515fe74700f.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-dc28c85505292d80b395127e9824768e432d0320.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\retrofit-1.6.1-3bf1c4b59241cccd941e439573b05ed91c4886dc.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\picasso-2.3.2-62e14047ad0695f009395914b496e7279ce782ac.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-be9a9f6a36233e384e74ff6672300938f36504f1.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\library-2.4.0-590a4e742b44e83fca3a0546ede5ec930023d5d0.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-877237691edd2c392c558a6eaefe28dc7e3e3532.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-4b122984047a57ff9560d698f658f2ef85cd3067.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-0f4ba61c083440e56391b356482ca5ced85b325c.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\universal-image-loader-1.9.3-50b9178bd6cee57d6177abde857149aa90afc906.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\gson-2.2.4-adee139b6e2670ab4f82fcecbc540d430e77ee0b.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\internal_impl-21.0.0-98e60b91b24856e48c7058957c93f80e7c732681.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-beb20ef4ae650b0835e63e7d58d6246b1e034dd6.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-86a4433c71f88575414c3ef5e9816bc2e57695b2.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\twitter4j-core-4.0.1-493690d4e6f9047118f98178cd21a288a3901b94.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-8a8fb9046b2cc29b2e69e8e1dd15187709842d8a.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\libGoogleAnalyticsServices-17df1f02116ba584bfcb670f0e5ea92e5871fd38.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\commons-codec-1.9-198008a46436afd389140080f2156973ae8c0503.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-23979b468ac8776e64ad0cd0d099c32459dc5cab.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\httpclient-android-4.3.5-1425ca5477b96fdbb1651eda36856e9713d7ab07.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-ca7e29e37e4059f857d27716965b311d65f95f67.jar D:\Users\Noname\work\drivernotes-android\driverNotes\build\intermediates\pre-dexed\debug\classes-2da44f5dc5c49b53278ec88648efc52e17a55c67.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Cannot merge new index 66123 into a non-jumbo instruction!
at com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:108)
at com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:25)
at com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:71)
at com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)
at com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)
at com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:48)
at com.android.dx.merge.DexMerger.transformCode(DexMerger.java:840)
at com.android.dx.merge.DexMerger.transformMethods(DexMerger.java:811)
at com.android.dx.merge.DexMerger.transformClassData(DexMerger.java:783)
at com.android.dx.merge.DexMerger.transformClassDef(DexMerger.java:680)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:540)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
最佳答案
请遵循此代码示例以确保您的 build.gradle 文件类似:
buildscript {
repositories {
jcenter() // <- *add this
maven { url 'https://maven.fabric.io/repo' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.3'
// The Fabric Gradle plugin uses an open ended version to
// react quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application' // <- *make sure this is the same
//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'
repositories {
jcenter() // <- *add this
maven { url 'https://maven.fabric.io/repo' }
}
我有同样的问题,花了半天时间,直到打开推特的官方文档,看到了这个: https://dev.twitter.com/twitter-kit/android/integrate
Fabric 团队在 SO 和其他论坛上提供了太多无效的答案。这行得通。
关于android - 使用新的 twitter sdk 开始编译应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28146756/