amazon-web-servicesparse-platformparse-serverparse-android-sdk

Can't upload data to my Parse Server throught my Android Studio project


I have trouble using my Parse Server that I created using Amazon Web Service.

I try to add a user through ParseUser in my MainActivity with a Button onClick method but it doesn't work for some reason... The error is : Error : com.parse.ParseRequest$ParseRequestException: i/o failure

It all worked well yesterday btw, but it was in Android Studio version 2.2.1. But today I want to try it on the updated version 3.4.1. I had to modify some lines in the Gradle files but nothing elsewhere so I don't know if it's relevant.

I don't know either what info you need to help me so I'm gonna put everything that might be implied... Sorry for the very long message

My MainActivity class:

public class MainActivity extends AppCompatActivity {



    public void signUpClick(View view) {

        EditText usernameEditText = (EditText) findViewById(R.id.usernameEditText);
        EditText passwordEditText = (EditText) findViewById(R.id.passwordEditText);

        if (passwordEditText.getText().toString().equals("") || usernameEditText.getText().toString().equals("")) {

            Toast.makeText(this, "As username and password are required", Toast.LENGTH_SHORT).show();

        } else {

            ParseUser user = new ParseUser();

            user.setUsername(usernameEditText.getText().toString());
            user.setPassword(passwordEditText.getText().toString());
            user.signUpInBackground(new SignUpCallback() {
                @Override
                public void done(ParseException e) {

                    if (e == null) {

                        Log.i("test", "Success");

                    } else {

                        Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                        Log.i("test", "Fail. Error : " + e.toString());
                        e.printStackTrace();

                    }

                }
            });

        }
    }

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


        ParseAnalytics.trackAppOpenedInBackground(getIntent());

    }

} 

A screenshot of my PuTTY session where I read the info of my server in the config.json :

[screenshot][1]

My StarterApplication class where I define my server information:

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("myappID")
                .clientKey("eXK4EAJ8lO7I")
                .server("http://18.191.227.26/parse/")
                .build()
        );


        //ParseUser.enableAutomaticUser();

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

    }
}

Thank you for your time, please tell me if you need other info.


Solution

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

    This means there is a problem with your connection. Your parse server may be down or your phone doesn't have internet access.

    If you are sure you have an internet connection and a working parse server, then its probably your server doesnt have SSL sertificate(which means you are using http instead of https. See: .server("http://18.191.227.26/parse/"))

    After Android 9(including 9) Android prevents connection to unsafe adresses.(ie http connections)

    Add this line between your application tag in your AndroidManifiest file

    android:usesCleartextTraffic="true"
    

    You can use this while development phase but I recommend you to switch to https.