Skip to content

Local Parse Server works with dashboard , but not with android studio #5045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Mastercho321 opened this issue Sep 9, 2018 · 2 comments
Closed

Comments

@Mastercho321
Copy link

I am trying to use Parse on windows with Android Studio.

I have followed tutorials on interned and created local parse server which is appering in parse dashboard, and passed this test http://localhost:1337/test , but when i run my project in android studio I get : com.parse.ParseRequest$ParseRequestException: i/o failure.

Here is my source code :

package com.example.mitaka.parsetest2;

import android.app.Application;
import android.util.Log;

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

public class StarterApplication extends Application {

@OverRide
public void onCreate() {
super.onCreate();

// Enable Local Datastore.
Parse.enableLocalDatastore(this);

// Add your initialization code here
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
        .applicationId("ID")
        .clientKey("KEY")
        .server("http://10.0.2.2:1337/parse/")
        .build()
);

ParseObject object = new ParseObject("ExampleObject");
object.put("myNumber", "123");
object.put("myString", "rob");

object.saveInBackground(new SaveCallback () {
    @Override
    public void done(ParseException ex) {
        if (ex == null) {
            Log.i("Parse Result", "Successful!");
        } else {
            Log.i("Parse Result", "Failed" + ex.toString());
        }
    }
});


ParseUser.enableAutomaticUser();

ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
defaultACL.setPublicWriteAccess(true);
ParseACL.setDefaultACL(defaultACL, true);

}
}

MainActivity:

public class MainActivity extends AppCompatActivity {

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

ParseAnalytics.trackAppOpenedInBackground(getIntent());

}
I have added:

allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
to buildGradle(Project)

and

implementation 'com.github.parse-community.Parse-SDK-Android:fcm:1.18.4'

to buildGradle(Module:app)

@Sadmansamee
Copy link

Use https://ngrok.com/docs to localhost with you android app

@JacobJT
Copy link

JacobJT commented Sep 10, 2018

localhost means the device (or container) that is running the code. On iOS, if I run a simulator, local host works because my device is running on the computer, so it finds my server. But if I run a physical device, the phone has no local host.

You need a remote endpoint, which is where ngrok comes in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants