我正在尝试在具有Android Studio的Windows上使用Parse。
我遵循了有关在解析仪表板中进行映射的实习和创建本地解析服务器的教程,并通过了此测试http://localhost:1337/test,但是当我在android studio中运行项目时,我得到了: com.parse。 ParseRequest $ ParseRequestException:I / O失败。
这是我的源代码:
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());
}
我添加了:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
以buildGradle(Project)
和
implementation 'com.github.parse-community.Parse-SDK-Android:fcm:1.18.4'
以buildGradle(Module:app)