Adding library in Android Studio make "UNEXPECTED TOP-LEVEL EXCEPTION"
Asked Answered
M

3

1

I'm trying to add libraries from maven, specifically, Crouton library. I can add it, Sync and use the Crouton object in my project, but when trying to run the app, i get this

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

EDIT: gradle file added

this is my 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')
}

if i use all three without "de.keyboardsurfer.android.widget:crouton-library:1.8.2" then it all works ok.

Mccartan answered 10/1, 2014 at 22:13 Comment(2)
What you're doing seems pretty straightforward, but could you please share your whole build.gradle file?Rachealrachel
Thanks for finding that issue. I fixed it in the repository and am deploying to maven central again. The fix should be distributed soon.Ferous
F
2

Yeah, the build was broken. I didn't notice it locally. But thanks to you it's fixed and deployed to maven central. Clear your cache to get the new build of 1.8.2.

Ferous answered 11/1, 2014 at 18:33 Comment(2)
new to Maven, how do i clean cache?Mccartan
Usually by using the -U flag.Ferous
R
2

It looks like the crouton library is mispackaged. If you examine its contents:

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

Everything is inside a release directory, but based on the error message, Configuration$1.class is in the package de.keyboardsurfer.android.widget.crouton (without release). You can contact the library author, or you could disassemble the jar, pull everything inside the release directory one level up, and repackage it.

Rachealrachel answered 10/1, 2014 at 23:7 Comment(0)
F
2

Yeah, the build was broken. I didn't notice it locally. But thanks to you it's fixed and deployed to maven central. Clear your cache to get the new build of 1.8.2.

Ferous answered 11/1, 2014 at 18:33 Comment(2)
new to Maven, how do i clean cache?Mccartan
Usually by using the -U flag.Ferous
T
1

The packing is wrong for the library on maven repository. So by the time it is corrected by author you can use the this libary as module by downloading and adding it in your project structure .

The path is https://github.com/keyboardsurfer/Crouton

I have informed author Benjamin Weiss on Google plus regarding the same.

Toweling answered 11/1, 2014 at 11:4 Comment(3)
Thanks a lot. I didn't get the notification on G+, but fixed the issue and propagated the changes to maven central. So the fix should be available soon.Ferous
Ok Thanks alot, I had messaged you on personal chat.Toweling
Ah, I don't see these from people outside my circles. The fix is live now. Same version, so make sure to flush your cache.Ferous

© 2022 - 2024 — McMap. All rights reserved.