You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to integrate my android project with unirest. I followed manual at http://blog.mashape.com/using-unirest-java-for-your-android-projects/ and my project is successfully compiled. But when I try to create simple activity which gets google.com I have a runtime exception. Here is my activity:
package com.example.stas.testapp;
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);
}
}
And here's exception I got:
03-11 15:43:35.395: E/AndroidRuntime(26171): java.lang.ExceptionInInitializerError
03-11 15:43:35.395: E/AndroidRuntime(26171): at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:154)
03-11 15:43:35.395: E/AndroidRuntime(26171): at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:134)
03-11 15:43:35.395: E/AndroidRuntime(26171): at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)
03-11 15:43:35.395: E/AndroidRuntime(26171): at com.example.stas.testapp.MainActivity.onCreate(MainActivity.java:22)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.app.Activity.performCreate(Activity.java:5188)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.app.ActivityThread.access$700(ActivityThread.java:140)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.os.Handler.dispatchMessage(Handler.java:99)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.os.Looper.loop(Looper.java:137)
03-11 15:43:35.395: E/AndroidRuntime(26171): at android.app.ActivityThread.main(ActivityThread.java:4921)
03-11 15:43:35.395: E/AndroidRuntime(26171): at java.lang.reflect.Method.invokeNative(Native Method)
03-11 15:43:35.395: E/AndroidRuntime(26171): at java.lang.reflect.Method.invoke(Method.java:511)
03-11 15:43:35.395: E/AndroidRuntime(26171): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
03-11 15:43:35.395: E/AndroidRuntime(26171): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
03-11 15:43:35.395: E/AndroidRuntime(26171): at dalvik.system.NativeStart.main(Native Method)
03-11 15:43:35.395: E/AndroidRuntime(26171): Caused by: java.lang.ExceptionInInitializerError
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:494)
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:149)
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:138)
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:114)
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:105)
03-11 15:43:35.395: E/AndroidRuntime(26171): at com.mashape.unirest.http.options.Options.refresh(Options.java:73)
03-11 15:43:35.395: E/AndroidRuntime(26171): at com.mashape.unirest.http.options.Options.<clinit>(Options.java:46)
03-11 15:43:35.395: E/AndroidRuntime(26171): ... 18 more
03-11 15:43:35.395: E/AndroidRuntime(26171): Caused by: java.lang.ExceptionInInitializerError
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:72)
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:84)
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<clinit>(ManagedHttpClientConnectionFactory.java:59)
03-11 15:43:35.395: E/AndroidRuntime(26171): ... 25 more
03-11 15:43:35.395: E/AndroidRuntime(26171): Caused by: java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)
03-11 15:43:35.395: E/AndroidRuntime(26171): at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)
03-11 15:43:35.395: E/AndroidRuntime(26171): ... 28 more
From #76
Hello,
I'm trying to integrate my android project with unirest. I followed manual at http://blog.mashape.com/using-unirest-java-for-your-android-projects/ and my project is successfully compiled. But when I try to create simple activity which gets google.com I have a runtime exception. Here is my activity:
And here's exception I got:
Device Android version: 4.1.2
Gradle file:
Help please, what I'm doing wrong?
The text was updated successfully, but these errors were encountered: