2

I've been searching around, but none of the solution fix mine. eg: add the parseLogInterceptor, change version. I'm trying to test my apps to connect to my local Parse-server but it give me the:

com.parse.ParseRequest$ParseRequestException: i/o failure .

and thus no object is created in the database. I tried using the javascript to create object from my browser and it work seamlessly.

I running this on my Emulator and using the Android Monitor. I am using Android Studio 2.2.1.

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.SaveCallback;

public class MainActivity extends AppCompatActivity {

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

    //Parse.addParseNetworkInterceptor(new ParseLogInterceptor());

    Parse.initialize(new Parse.Configuration.Builder(this)
            .applicationId("abc123")
            .server("http://localhost:1337/parse/")
            .clientKey("")
            .build()
    );
    Log.i("ME", "DONE onCreate");

    ParseObject testObject = new ParseObject("SomeObject");
    testObject.put("foo", "bar");
    testObject.saveInBackground(new SaveCallback() {
        @Override
        public void done(ParseException e) {
            Log.v("MAIN", "PARSE ERROR:" + e);
        }
    });

}
}

and this is my app gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "noxasch.com.testParse"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'junit:junit:4.12'
    compile 'com.parse:parse-android:1.13.0'
}
Zoe
  • 27,060
  • 21
  • 118
  • 148
Alexander Dischberg
  • 1,890
  • 2
  • 13
  • 26

7 Answers7

2

The connection between your app and the server is not established.

I was getting the same error, until I turned on WiFi in my emulator. You can also try running it on your phone, ensuring that your phone has a proper connection.

Sagar
  • 9,456
  • 6
  • 54
  • 96
1

I've faced the same error.It can be fixed by adding

Option 1:

android:usesCleartextTraffic="true"

Option 2:

 <uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

in your AndroidManifest.xml

Here is the AndroidManifest.xml ,so you can check it here.I hope this will help you!

1

I was also getting the same error. I followed the following steps to resolve it:

STEP 1: Add this line in your AndroidManifest.xml : android:usesCleartextTraffic="true"

STEP 2: Make sure you have given permission in AndroidManifest.xml :

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

This has worked for me. Hope it works for you too.

Prathamesh
  • 11
  • 1
0

I fix this issue. If using the emulator you are suppose to use http://10.0.2.2/ instead of localhost or 127.0.0.1 to access host. developer site keep changing, i can't find the documentation, but i find it here How to connect to my http://localhost web server from Android Emulator in Eclipse

Community
  • 1
  • 1
Alexander Dischberg
  • 1,890
  • 2
  • 13
  • 26
0

Error : com.parse.ParseRequest$ParseRequestException: i/o failure .

Parse.initialize(new Parse.Configuration.Builder(this)
        .applicationId("abc123")
        .server("http://localhost:1337/parse/")
        .clientKey("")
        .build()
);

use Ip Address of parse server instead of localhost. .server("http://192.168.1.100:1337/parse/") after that delete AVD and recreate it once again

for me its worked

0

If it isn’t localhost

You are not giving the Internet Permission

Add these lines in AndroidManifest.xml ,your problem will be solved

   <uses-permission android:name="android.permission.INTERNET"/>
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
sai Pavan Kumar
  • 1,129
  • 12
  • 20
0

In this case it's not the problem, but for others looking for a solution to same problem, add -

android:usescleartexttraffic="true"

In your manifest file.