我正在使用org.apache.http.entity.mime.MultipartEntityBuilder将图像上传到服务器,当我在版本7设备中测试时,它的工作正常但在设备4.x中它通过了像java.lang.NoClassDefFoundError这样的错误在运行时。我不确定这些类在运行时为4.x设备丢失的位置。我正在使用Android Studio 2.3.3。我希望我搞砸了Gradle因此在4.x设备中使用相同的工作方式相同不同的应用。
构建Gradle
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.xx.xx.xx"
minSdkVersion 16
targetSdkVersion 23
versionCode 32
versionName "4.0.2"
multiDexEnabled true
}
lintOptions{
disable 'MissingTranslation'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
android {
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.google.firebase:firebase-messaging:9.2.1'
compile 'com.google.firebase:firebase-crash:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.1'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
}
apply plugin: 'com.google.gms.google-services'
Gradle wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip