-2
私はアンドロイドの初心者です。私はudemyのコースを続けています。私は解析を使用しようとしたが、コードを実行しようとするたびにエラーが出る。相続人は解析クラスのコード:構文解析を使用してログインしようとしてエラーが発生しました
import android.app.Application;
import com.parse.Parse;
import com.parse.ParseACL;
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("4e188aaea9fd210545126d11e6dc4b2463265310")
.clientKey("00f12c54779ba75af4d6deb7c599c5de77ddd47a")
.server("http://ec2-13-59-193-44.us-east-2.compute.amazonaws.com:80/parse/")
.build()
);
//ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
defaultACL.setPublicWriteAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
}
}
は、ここでの主なクラスです:
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.parse.FindCallback;
import com.parse.GetCallback;
import com.parse.LogInCallback;
import com.parse.Parse;
import com.parse.ParseAnalytics;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;
import com.parse.SaveCallback;
import com.parse.SignUpCallback;
import java.util.List;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Boolean signUpModeActive = true;
TextView changeSignupModeTextView;
@Override
public void onClick(View view) {
if (view.getId() == R.id.changeSignupModeTextView) {
Button signupButton = (Button) findViewById(R.id.signupButton);
if (signUpModeActive) {
signUpModeActive = false;
signupButton.setText("Login");
changeSignupModeTextView.setText("Or, Signup");
} else {
signUpModeActive = true;
signupButton.setText("Signup");
changeSignupModeTextView.setText("Or, Login");
}
}
}
public void signUp(View view) {
EditText usernameEditText = (EditText) findViewById(R.id.usernameEditText);
EditText passwordEditText = (EditText) findViewById(R.id.passwordEditText);
if (usernameEditText.getText().toString().matches("") || passwordEditText.getText().toString().matches("")) {
Toast.makeText(this, "A username and password are required.", Toast.LENGTH_SHORT).show();
} else {
if (signUpModeActive) {
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("Signup", "Successful");
} else {
Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
} else {
ParseUser.logInInBackground(usernameEditText.getText().toString(), passwordEditText.getText().toString(), new LogInCallback() {
@Override
public void done(ParseUser user, ParseException e) {
if (user != null) {
Log.i("Signup", "Login successful");
} else {
Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
changeSignupModeTextView = (TextView) findViewById(R.id.changeSignupModeTextView);
changeSignupModeTextView.setOnClickListener(this);
ParseAnalytics.trackAppOpenedInBackground(getIntent());
}
}
PS:HERESにエラー:ここ
07-13 23:55:44.169 2603-2603/com.parse.starter E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.parse.starter, PID: 2603
java.lang.RuntimeException: Unable to instantiate application com.parse.starter.StarterApplication: java.lang.ClassNotFoundException: Didn't find class "com.parse.starter.StarterApplication" on path: DexPathList[[zip file "/data/app/com.parse.starter-1/base.apk"],nativeLibraryDirectories=[/data/app/com.parse.starter-1/lib/x86, /system/lib, /vendor/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:802)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.parse.starter.StarterApplication" on path: DexPathList[[zip file "/data/app/com.parse.starter-1/base.apk"],nativeLibraryDirectories=[/data/app/com.parse.starter-1/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newApplication(Instrumentation.java:992)
at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
詳細情報が必要です。あなたは何を得ているのですか? – Kai
解析が終了しました。Firebase –
残念です。それを追加するのを忘れましたが、ここにあります。 – kadirkid