这是我的 build.gradle 文件
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']
}
}
}
项目构建成功,没有错误没有警告。
: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
但是当我在模拟器或 USB 设备上运行项目时,我得到了错误NoClassDefFoundError: org.apache.http.entity.mime.MultipartEntityBuilder
这个问题只出现在 org.apache.httpcomponents:httpmime:4.3 和其他库,比如 com.actionbarsherlock:actionbarsherlock:4.4.0@aar 没问题