Java 从解析下载文件失败:i/o失败

Java 从解析下载文件失败:i/o失败,java,android,parse-server,downloadfile,Java,Android,Parse Server,Downloadfile,我正试图通过ParseObject下载我的ParseServer的一个映像,几秒钟后该映像失败为“I/o失败”。我做了一些研究,发现“I/o故障”可能是连接到服务器的问题。这就是为什么我尝试在同一脚本中只下载同一类的列名,而且效果很好。我的代码甚至响应找到一个对象 这就是为什么我问自己这是一个连接问题还是其他我无法理解的问题 我感谢你的帮助。这是我的密码 import androidx.appcompat.app.AppCompatActivity; import android.graph

我正试图通过ParseObject下载我的ParseServer的一个映像,几秒钟后该映像失败为“I/o失败”。我做了一些研究,发现“I/o故障”可能是连接到服务器的问题。这就是为什么我尝试在同一脚本中只下载同一类的列名,而且效果很好。我的代码甚至响应找到一个对象

这就是为什么我问自己这是一个连接问题还是其他我无法理解的问题

我感谢你的帮助。这是我的密码


import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.Image;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.parse.FindCallback;
import com.parse.GetDataCallback;
import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import java.util.List;

public class MainActivity extends AppCompatActivity {

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


        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
        ImageView imageView = new ImageView(getApplicationContext());
        imageView.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT
        ));



//TestDownload of String in column
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Image");
        query.setLimit(1);

        query.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> objects, ParseException e) {

                if (e == null) {

                    for (ParseObject object : objects)
                    Log.i("Info Testname", object.getString("Name"));

                }
            }
        });



//Download of Image(file)
        ParseQuery<ParseObject> query1 = ParseQuery.getQuery("Image");
        query1.whereEqualTo("Name", "testName");
        query1.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> objects, ParseException e) {
                if (e == null) {

                    Log.i("findInBackground", "Retrieved " + objects.size() + " objects");

                    for (ParseObject object : objects) {
                        ParseFile file = (ParseFile) object.get("Image");
                        file.getDataInBackground(new GetDataCallback() {
                            @Override
                            public void done(byte[] data, ParseException ex) {
                                if (ex == null) {
                                    Bitmap bitmapImage = BitmapFactory.decodeByteArray(data, 0, data.length);

                                    // Do something

                                    Log.i("done", "done");

                                } else {
                                    Log.i("info", ex.getMessage());
                                }
                            }
                        });
                    }
                } else {

                    Log.i("info e", e.getMessage());

                }

            }

        });

        }
    }

您需要在应用程序类中初始化服务器连接,如中所述:


失败的线路是什么?您还可以记录
文件的内容吗
var?失败的部分是
public void done(byte[]data,ParseException ex)
,但我想我知道问题出在哪里:我没有将publicServerUrl配置到我的解析服务器地址。但我真的不知道我在哪里以及如何做到这一点?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.downloadimagefromparse">

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
2020-11-18 10:57:13.706 11155-11177/com.example.downloadimagefromparse I/OpenGLRenderer: Initialized EGL, version 1.4
2020-11-18 10:57:13.706 11155-11177/com.example.downloadimagefromparse D/OpenGLRenderer: Swap behavior 1
2020-11-18 10:57:13.706 11155-11177/com.example.downloadimagefromparse W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2020-11-18 10:57:13.706 11155-11177/com.example.downloadimagefromparse D/OpenGLRenderer: Swap behavior 0
2020-11-18 10:57:13.710 11155-11177/com.example.downloadimagefromparse D/EGL_emulation: eglCreateContext: 0xa9a05340: maj 2 min 0 rcv 2
2020-11-18 10:57:13.715 11155-11177/com.example.downloadimagefromparse D/EGL_emulation: eglMakeCurrent: 0xa9a05340: ver 2 0 (tinfo 0x9ff21ab0)
2020-11-18 10:57:13.728 11155-11177/com.example.downloadimagefromparse D/EGL_emulation: eglMakeCurrent: 0xa9a05340: ver 2 0 (tinfo 0x9ff21ab0)
2020-11-18 10:57:13.913 11155-11155/com.example.downloadimagefromparse I/findInBackground: Retrieved 1 objects
2020-11-18 10:57:13.916 11155-11155/com.example.downloadimagefromparse I/Info Testname: testName
2020-11-18 10:57:38.377 11155-11155/com.example.downloadimagefromparse I/info: i/o failure 
import com.parse.Parse;
import android.app.Application;

public class App extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    Parse.initialize(new Parse.Configuration.Builder(this)
      .applicationId("YOUR_APP_ID")
      // if defined
      .clientKey("YOUR_CLIENT_KEY")
      .server("http://localhost:1337/parse/")
      .build()
    );
  }
}