2

This is my build.gradle file

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

apply plugin: 'android'

allprojects {
    repositories {
        mavenCentral()
    }
}

dependencies {
    repositories {
        mavenCentral()
    }

    // Google Play Services
    compile 'com.google.android.gms:play-services:3.2.25'

    // Support Libraries
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.android.support:gridlayout-v7:18.0.0'
    compile 'com.android.support:support-v13:18.0.0'

    // Note: these libraries require the "Google Repository" and "Android Repository"
    //       to be installed via the SDK manager.

    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.nineoldandroids:library:2.4.0'

    compile 'org.apache.httpcomponents:httpmime:4.3'
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 18
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }
}

Project build successfully, no errors no warnings.

:preBuild UP-TO-DATE                                  
:preDebugBuild UP-TO-DATE  
:preReleaseBuild UP-TO-DATE  
:prepareComActionbarsherlockActionbarsherlock440Library UP-TO-DATE  
:prepareComAndroidSupportGridlayoutV71800Library UP-TO-DATE  
:prepareComGoogleAndroidGmsPlayServices3225Library UP-TO-DATE  
:prepareDebugDependencies             
:compileDebugAidl UP-TO-DATE  
:compileDebugRenderscript UP-TO-DATE  
:generateDebugBuildConfig UP-TO-DATE  
:mergeDebugAssets UP-TO-DATE  
:mergeDebugResources UP-TO-DATE  
:processDebugManifest UP-TO-DATE  
:processDebugResources UP-TO-DATE  
:generateDebugSources UP-TO-DATE  
:nativeLibsToJar UP-TO-DATE  
:compileDebug UP-TO-DATE  
:dexDebug UP-TO-DATE  
:processDebugJavaRes UP-TO-DATE  
:validateDebugSigning             
:packageDebug UP-TO-DATE  
:assembleDebug UP-TO-DATE  
:prepareReleaseDependencies             
:compileReleaseAidl             
:compileReleaseRenderscript             
:generateReleaseBuildConfig UP-TO-DATE  
:mergeReleaseAssets UP-TO-DATE  
:mergeReleaseResources UP-TO-DATE  
:processReleaseManifest UP-TO-DATE  
:processReleaseResources UP-TO-DATE  
:generateReleaseSources             
:compileRelease             
:dexRelease             
:processReleaseJavaRes UP-TO-DATE  
:packageRelease             
:assembleRelease             
:assemble             
:check UP-TO-DATE  
:build             

BUILD SUCCESSFUL

Total time: 39.311 secs

But when I run project on emulator or usb device I get the error NoClassDefFoundError: org.apache.http.entity.mime.MultipartEntityBuilder

This problem appear only with org.apache.httpcomponents:httpmime:4.3 with other libs like com.actionbarsherlock:actionbarsherlock:4.4.0@aar no problem

3
  • 1
    make sure all the jar files needed was kept in the libs folder Commented Sep 17, 2013 at 13:07
  • It's necessary even if gralde used? Commented Sep 17, 2013 at 14:09
  • @beholderrk no, it's not necessary, as long as those are added in gradle.build as dependencies, and I don't see in your config any dependency on physical JAR files (eg. fileTree). Have you managed to solve the problem? Would be nice of you to provide answer. Commented Oct 14, 2013 at 11:58

1 Answer 1

3

Google have native httpcore package in android SDK (v18), and this package is httpcore:4.2.x. In order the org.apache.httpcomponents:httpmime works properly it must have the same version as native httpcore ie org.apache.httpcomponents:httpmime:4.2.1

I downloaded httpclient-4.2.1.jar httpmime-4.2.1.jar libs to the <project>/libs folder.

Delete the build folder before make project.
This config solved all my problems with httpmime:

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

apply plugin: 'android'

allprojects {
    repositories {
        mavenCentral()
    }
}

dependencies {
    repositories {
        mavenCentral()
    }

    // Google Play Services
    compile 'com.google.android.gms:play-services:3.2.25'

    // Support Libraries
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.android.support:gridlayout-v7:18.0.0'
    compile 'com.android.support:support-v13:18.0.0'

    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

    compile fileTree(dir: "libs", include: '*.jar')
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 18
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        debug.setRoot('debug')
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.