Я пытаюсь создать приложение флеш-чата из «курса», используя Firebase, но я продолжаю зацикливаться на этой проблеме.Помощь будет принята с благодарностью.Я также буду публиковать файл моего приложения Gradle.Преподаватель может использовать устаревшую Android Studio и, возможно, использовал старые зависимости в файле Gradle, поэтому после исследования я решил изменить его, но он все равно не работает.Пожалуйста, помогите мне, чтобы я мог пройти этот курс.Спасибо
05-09 09:17:44.777 2668-2668/com.lucianvibez.flashchatnewfirebase E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.lucianvibez.flashchatnewfirebase, PID: 2668
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.lucianvibez.flashchatnewfirebase/com.online.lucianvibez.flashchatnewfirebase.LoginActivity}: java.lang.ClassNotFoundException: Didn't find class "com.online.lucianvibez.flashchatnewfirebase.LoginActivity" on path: DexPathList[[zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/base.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.lucianvibez.flashchatnewfirebase-1/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2548)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.online.lucianvibez.flashchatnewfirebase.LoginActivity" on path: DexPathList[[zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/base.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.lucianvibez.flashchatnewfirebase-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.lucianvibez.flashchatnewfirebase-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.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2538)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
05-09 09:18:15.891 2668-2761/com.lucianvibez.flashchatnewfirebase
E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE
05-09 09:19:15.958 2668-2761/com.lucianvibez.flashchatnewfirebase
E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE
05-09 09:20:45.975 2668-2761/com.lucianvibez.flashchatnewfirebase
E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE
Ниже находится файл оценки моего приложения .:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.lucianvibez.flashchatnewfirebase"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-database:15.0.1'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
LoginActivity.java
package com.lucianvibez.flashchatnewfirebase;
public class LoginActivity extends AppCompatActivity {
// TODO: Add member variables here:
// UI references.
private AutoCompleteTextView mEmailView;
private EditText mPasswordView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mEmailView = (AutoCompleteTextView) findViewById(R.id.login_email);
mPasswordView = (EditText) findViewById(R.id.login_password);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.integer.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
// TODO: Grab an instance of FirebaseAuth
}
// Executed when Sign in button pressed
public void signInExistingUser(View v) {
// TODO: Call attemptLogin() here
}
// Executed when Register button pressed
public void registerNewUser(View v) {
Intent intent = new Intent(this, com.lucianvibez.flashchatnewfirebase.RegisterActivity.class);
finish();
startActivity(intent);
}
// TODO: Complete the attemptLogin() method
private void attemptLogin() {
// TODO: Use FirebaseAuth to sign in with email & password
}
// TODO: Show error on screen with an alert dialog
RegisterActivity.Ява
package com.lucianvibez.flashchatnewfirebase;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.TextView;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
public class RegisterActivity extends AppCompatActivity {
// Constants
public static final String CHAT_PREFS = "ChatPrefs";
public static final String DISPLAY_NAME_KEY = "username";
// TODO: Add member variables here:
// UI references.
private AutoCompleteTextView mEmailView;
private AutoCompleteTextView mUsernameView;
private EditText mPasswordView;
private EditText mConfirmPasswordView;
// Firebase instance variables
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
mEmailView = (AutoCompleteTextView) findViewById(R.id.register_email);
mPasswordView = (EditText) findViewById(R.id.register_password);
mConfirmPasswordView = (EditText) findViewById(R.id.register_confirm_password);
mUsernameView = (AutoCompleteTextView) findViewById(R.id.register_username);
// Keyboard sign in action
mConfirmPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.integer.register_form_finished || id == EditorInfo.IME_NULL) {
attemptRegistration();
return true;
}
return false;
}
});
// TODO: Get hold of an instance of FirebaseAuth
mAuth = FirebaseAuth.getInstance();
}
// Executed when Sign Up button is pressed.
public void signUp(View v) {
attemptRegistration();
}
private void attemptRegistration() {
// Reset errors displayed in the form.
mEmailView.setError(null);
mPasswordView.setError(null);
// Store values at the time of the login attempt.
String email = mEmailView.getText().toString();
String password = mPasswordView.getText().toString();
boolean cancel = false;
View focusView = null;
// Check for a valid password, if the user entered one.
if (TextUtils.isEmpty(password) || !isPasswordValid(password)) {
mPasswordView.setError(getString(R.string.error_invalid_password));
focusView = mPasswordView;
cancel = true;
}
// Check for a valid email address.
if (TextUtils.isEmpty(email)) {
mEmailView.setError(getString(R.string.error_field_required));
focusView = mEmailView;
cancel = true;
} else if (!isEmailValid(email)) {
mEmailView.setError(getString(R.string.error_invalid_email));
focusView = mEmailView;
cancel = true;
}
if (cancel) {
// There was an error; don't attempt login and focus the first
// form field with an error.
focusView.requestFocus();
} else {
// TODO: Call create FirebaseUser() here
createFirebaseUser();
}
}
private boolean isEmailValid(String email) {
// You can add more checking logic here.
return email.contains("@");
}
private boolean isPasswordValid(String password) {
//TODO: Add own logic to check for a valid password (minimum 6 characters)
String confirmPassword = mConfirmPasswordView.getText().toString();
return confirmPassword.equals(password) && password.length() > 4;
}
// TODO: Create a Firebase user
private void createFirebaseUser(){
String email = mEmailView.getText().toString();
String password = mPasswordView.getText().toString();
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d("FlashChat", "createUser onComplete: " + task.isSuccessful());
if (!task.isSuccessful()){
Log.d("FlashChat", "user creation failed");
}
}
});
}
// TODO: Save the display name to Shared Preferences
// TODO: Create an alert dialog to show in case registration failed
}