找不到从方法`com.mashape.relocation.conn.ssl.AbstractVerifier.extractCN`引用的类`javax.naming.ldap.LdapName`

时间:2015-04-03 14:39:31

标签: java android unirest

我有以下示例活动:

package teste.myapplication;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;


public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView text = (TextView) findViewById(R.id.mainText);
        try {
            text.setText(Unirest.get("http://google.com").asString().getBody());
        }catch (UnirestException e){
            throw new RuntimeException(e);
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

我在official guide之后从源代码编译了Unirest,最后得到了一个名为.jar的{​​{1}}。

当我运行活动时,它会立即中断标题上的错误。这是完整的堆栈跟踪(带有错误过滤器的logcat):

unirest-java-1.4.6-SNAPSHOT-withDependency-ShadedForAndroid.jar

的build.gradle:

04-03 10:50:55.150    1767-1767/teste.myapplication E/dalvikvm﹕ Could not find class 'javax.naming.ldap.LdapName', referenced from method com.mashape.relocation.conn.ssl.AbstractVerifier.extractCNs
04-03 10:50:55.170    1767-1767/teste.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: teste.myapplication, PID: 1767
    java.lang.VerifyError: com/mashape/relocation/conn/ssl/AbstractVerifier
            at com.mashape.relocation.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:126)
            at com.mashape.relocation.impl.conn.PoolingHttpClientConnectionManager.getDefaultRegistry(PoolingHttpClientConnectionManager.java:98)
            at com.mashape.relocation.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:105)
            at com.mashape.unirest.http.options.Options.refresh(Options.java:73)
            at com.mashape.unirest.http.options.Options.<clinit>(Options.java:46)
            at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:154)
            at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:134)
            at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)
            at teste.myapplication.MainActivity.onCreate(MainActivity.java:22)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)

我不知道会是什么。我已经尝试重新编译库,但我没有改变。

2 个答案:

答案 0 :(得分:0)

在Android设备上,转到&#34;设置&#34;,&#34;关于软件&#34;,&#34;系统更新&#34;,&#34;更新&#34;

答案 1 :(得分:-1)

我最终使用的Retrofit就像一个魅力。

最后,在运行API 21的AVD中我的错误消失了(我之前在运行API 19的AVD上进行了测试,我的手机也在19号),可能更新是关键,但如果你的应用程序目标是API 19及更低版本,你无法更改库,那我就不知道了。