简体   繁体   English

无法通过我的 Android Studio 项目将数据上传到我的 Parse 服务器

[英]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.我在使用使用 Amazon Web 服务创建的 Parse 服务器时遇到问题。

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我尝试使用按钮 onClick 方法在我的 MainActivity 中通过 ParseUser 添加用户,但由于某种原因它不起作用......错误是:错误:com.parse.ParseRequest$ParseRequestException:i/o 失败

It all worked well yesterday btw, but it was in Android Studio version 2.2.1.顺便说一句,昨天一切正常,但它在 Android Studio 版本 2.2.1 中。 But today I want to try it on the updated version 3.4.1.但今天我想在更新的 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.我不得不修改 Gradle 文件中的一些行,但其他地方没有,所以我不知道它是否相关。

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:我的主要活动 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:我的 PuTTY session 的屏幕截图,我在 config.json 中读取了我的服务器信息:

[screenshot][1] [截图][1]

My StarterApplication class where I define my server information:我的 StarterApplication class 我在其中定义了我的服务器信息:

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.感谢您的宝贵时间,如果您需要其他信息,请告诉我。

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/") ) 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) Android 9(包括9个)Android后防止连接到不安全的地址。(即http连接)

Add this line between your application tag in your AndroidManifiest file在您的 AndroidManifiest 文件中的应用程序标记之间添加此行

android:usesCleartextTraffic="true"

You can use this while development phase but I recommend you to switch to https.您可以在开发阶段使用它,但我建议您切换到 https。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么Elasticsearch批量API无法解析我的JSON? - Why can't Elasticsearch bulk API parse my JSON? 无法通过Web浏览器访问我的nodejs服务器 - Can't get to my nodejs server through web browser 通过 ACM 将其添加到我的 EBS 后,HTTPS 不起作用 - HTTPS not working after adding it to my EBS throught ACM Amazon Web Services为什么无法解析我的CloudFront失效批处理请求XML文档? - Why can’t Amazon Web Services parse my CloudFront invalidation batch request XML document? 我无法从外部访问我的AWS EC2上的node.js服务器 - I can't access my node.js server on my AWS EC2 isntance from the outside 在AWS Windows Server 2012 R2 iis8.5中找不到我的Codeigniter网站 - Can't find my codeigniter website in my aws windows server 2012 R2 iis8.5 为什么我无法使用我的 Lambda 函数将文件上传到 s3? - Why can't I upload a file to s3 with my Lambda function? 在我的 android 项目中使用 firebase 和 AWS - Using firebase and AWS for my android project 我在哪里可以找到通过AWS Cognito在我的android应用中输入的数据 - Where can i find my data that i entered in my android app through AWS Cognito AWS Elastic beanstalk - 我部署的应用程序似乎无法将 pdf 写入我在项目文件夹中设置的目录 - AWS Elastic beanstalk - My deployed app can't seem to write pdf's into this directory i've set up in my project folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM