2014-01-10 88 views
1

我試圖從maven,特別是Crouton庫中添加庫。 我可以添加它,同步在我的項目中使用Crouton對象,但試圖運行應用程序時,我得到這個在Android Studio中添加庫使「意外的頂級例外」

FAILURE: Build failed with an exception. 

    * What went wrong: 
    Execution failed for task ':timetable:preDexDebug'. 
    > com.android.ide.common.internal.LoggedErrorException: Failed to run command: 
     C:\Program Files (x86)\Android\android-studio\sdk\build-tools\19.0.1\dx.bat --dex --output D:\Developer\TimeTable3\timetable\build\pre-dexed\debug\crouton-library-1.8.2-c968ce53b92080dec516373cec51e9993ca5051f.jar C:\Users\Shahar\.gradle\caches\modules-2\files-2.1\de.keyboardsurfer.android.widget\crouton-library\1.8.2\725b0873131748c8c1bf2e1a27465e5bea857ab3\crouton-library-1.8.2.jar 
    Error Code: 
     1 
    Output: 



error: 

    UNEXPECTED TOP-LEVEL EXCEPTION: 
    com.android.dx.cf.iface.ParseException: class name (de/keyboardsurfer/android/widget/crouton/Configuration$1) does not match path (release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class) 
     at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:520) 
     at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406) 
     at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388) 
     at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251) 
     at com.android.dx.command.dexer.Main.processClass(Main.java:665) 
     at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634) 
     at com.android.dx.command.dexer.Main.access$600(Main.java:78) 
     at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572) 
     at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) 
     at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) 
     at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) 
     at com.android.dx.command.dexer.Main.processOne(Main.java:596) 
     at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498) 
     at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264) 
     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) 
    ...while parsing release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class 

編輯:gradle這個文件添加

這是我的gradle產出:

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.7.+' 
    } 
} 
apply plugin: 'android' 

android { 
    compileSdkVersion 15 
    buildToolsVersion '19.0.1' 

    defaultConfig { 
     minSdkVersion 15 
     targetSdkVersion 19 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      runProguard false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
} 

dependencies { 
    compile 'com.android.support:support-v4:+' 
    compile 'com.google.android.gms:play-services:4.0.30' 
    compile 'de.keyboardsurfer.android.widget:crouton-library:1.8.2' 
    compile files('libs/ActiveAndroid.jar') 
} 

如果我使用所有三個沒有「de.keyboardsurfer.android.widget:crouton-library:1.8.2」 那麼它一切正常。

+0

你在做什麼看起來很直截了當,但是請你分享一下你的整個build.gradle文件嗎? –

+0

當然,現在編輯。 – Shahar

+1

感謝您發現該問題。我將它修復到存儲庫中,然後再次部署到maven central。修補程序應儘快分發。 – keyboardsurfer

回答

2

是的,構建被打破。我沒有在當地注意到它。但是多虧了你,它已經修復並部署到maven central。清理緩存以獲取1.8.2的新版本。

+0

Maven新增功能,如何清理緩存? – Shahar

+1

通常使用'-U'標誌。 – keyboardsurfer

2

它看起來像麪包房庫是錯誤包裝。如果你檢查它的內容:

jar -tf /Users/sbarta/.gradle/caches/modules-2/files-2.1/de.keyboardsurfer.android.widget/crouton-library/1.8.2/725b0873131748c8c1bf2e1a27465e5bea857ab3/crouton-library-1.8.2.jar 

META-INF/ 
META-INF/MANIFEST.MF 
release/ 
release/de/ 
release/de/keyboardsurfer/ 
release/de/keyboardsurfer/android/ 
release/de/keyboardsurfer/android/widget/ 
release/de/keyboardsurfer/android/widget/crouton/ 
release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class 
release/de/keyboardsurfer/android/widget/crouton/Configuration$Builder.class 
release/de/keyboardsurfer/android/widget/crouton/Configuration.class 
release/de/keyboardsurfer/android/widget/crouton/Crouton.class 
release/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.class 
release/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.class 
release/de/keyboardsurfer/android/widget/crouton/Manager$1.class 
release/de/keyboardsurfer/android/widget/crouton/Manager$Messages.class 
release/de/keyboardsurfer/android/widget/crouton/Manager.class 
release/de/keyboardsurfer/android/widget/crouton/Style$1.class 
release/de/keyboardsurfer/android/widget/crouton/Style$Builder.class 
release/de/keyboardsurfer/android/widget/crouton/Style.class 
release/de/keyboardsurfer/mobile/ 
release/de/keyboardsurfer/mobile/app/ 
release/de/keyboardsurfer/mobile/app/android/ 
release/de/keyboardsurfer/mobile/app/android/widget/ 
release/de/keyboardsurfer/mobile/app/android/widget/crouton/ 
release/de/keyboardsurfer/mobile/app/android/widget/crouton/BuildConfig.class 

一切都是release目錄裏面,但是基於錯誤信息,Configuration$1.class在包de.keyboardsurfer.android.widget.crouton(不release)。您可以聯繫圖書館作者,或者您可以拆開罐子,將release目錄中的所有內容拉上一層,然後重新打包。

1

maven存儲庫上的庫的打包錯誤。因此,在作者糾正的時候,您可以通過下載並將其添加到您的項目結構中來將此庫用作模塊。

的路徑是https://github.com/keyboardsurfer/Crouton

我已經在谷歌通知作者本傑明·韋斯以及就同一。

+0

非常感謝。我沒有收到關於G +的通知,但解決了問題並將更改傳播到maven central。所以修補程序應該很快就可以使用。 – keyboardsurfer

+1

好的非常感謝,我曾通過個人聊天給你發過消息。 – pyus13

+0

啊,我看不到我的圈子以外的人。該修復程序現在正在運行。同一版本,所以請確保刷新緩存。 – keyboardsurfer

相關問題