获取java.lang.nosuchmethoderror使用android studio

时间:2015-11-26 11:21:09

标签: android apache apache-httpclient-4.x

在android studio中将编译版本更改为23后,我现在收到java.lang.nosuchmethoderror没有虚拟方法执行错误

请查看我的gradle文件

申请插件:' com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "my.test.app"
        minSdkVersion 14
        targetSdkVersion 14
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    packagingOptions {

        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

repositories {
    maven {
        url 'https://zendesk.artifactoryonline.com/zendesk/repo/'
    }
}

dependencies {
    compile project(':gestureimageview')
    compile 'com.android.support:support-v4:18.0.0'
    compile files('libs/android-hipmob-2.9.8.jar')
    compile files('libs/apache-mime4j-0.6.1.jar')
    compile files('libs/HockeySDK-3.5.0.jar')
    compile files('libs/httpclient-4.3.jar')
    compile files('libs/httpcore-4.3.jar')
    compile files('libs/libphonenumber-5.2v1.5.jar')
    compile files('libs/NineOldAndroid-2.4.0.jar')
    compile files('libs/org.apache.commons.io.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')
    compile files('libs/httpmime-4.3.jar')

    compile group: 'com.zopim.android', name: 'sdk', version: '1.1.0', changing: false
    compile 'com.android.support:appcompat-v7:23.0.0'
}

任何人都可以帮忙吗?

修改

我使用的版本是

  • 的HttpClient-4.3
  • 的HttpCore-4.3
  • httpmime-4.3

并且完整的堆栈跟踪是

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
Caused by: java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute
at 

1 个答案:

答案 0 :(得分:2)

经过大量搜索,我发现了

org.apache.http.impl.client.DefaultHttpClient.execute方法在版本22中已弃用,在版本23中已完全删除

并且为了解决这个问题,我改为使用HttpURLConnection

http://developer.android.com/reference/java/net/HttpURLConnection.html