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'
}
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