私はfirebaseのユーザー登録のための簡単なアプリケーションを作っています。サインアップのためのユーザーとボタンからメールアドレスとパスワードを取得するための2つのEditText。私はすでにデフォルトfirebaseAppを初期化するために、アプリケーションを拡張するクラスを追加したすべてのコードを以下に追加されます。このエラーを並べ替えるために私を助けて。私は "java.lang.IllegalArgumentException:与えられた文字列が空であるかヌル"を取得し続けており、auth = FirebaseAuth.getInstance();と何か関係があります "
MainActivity.java
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
EditText ed_email, ed_pass;
Button but_signup;
ProgressBar progressBar;
FirebaseAuth auth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//FirebaseApp.initializeApp(getApplicationContext());
//Get Firebase auth instance
auth = FirebaseAuth.getInstance();
but_signup = (Button) findViewById(R.id.but_login);
ed_email = (EditText) findViewById(R.id.ed_email);
ed_pass = (EditText) findViewById(R.id.ed_pass);
but_signup.setOnClickListener(this);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public void onClick(View v) {
String email = ed_email.getText().toString().trim();
String password = ed_pass.getText().toString().trim();
if (TextUtils.isEmpty(email)) {
Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show();
return;
}
if (TextUtils.isEmpty(password)) {
Toast.makeText(getApplicationContext(), "Enter password!", Toast.LENGTH_SHORT).show();
return;
}
if (password.length() < 6) {
Toast.makeText(getApplicationContext(), "Password too short, enter minimum 6 characters!", Toast.LENGTH_SHORT).show();
return;
}
//create user
auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Toast.makeText(MainActivity.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show();
if (!task.isSuccessful()) {
Toast.makeText(MainActivity.this, "Authentication failed." + task.getException(),
Toast.LENGTH_SHORT).show();
} else {
startActivity(new Intent(MainActivity.this, MainActivity.class));
finish();
}
}
});
}
}
FireApp.java
public class FireApp extends Application {
@Override
public void onCreate() {
super.onCreate();
FirebaseApp.initializeApp(getApplicationContext());
}}
logcat
FATAL EXCEPTION: main
Process: com.skapsdevelopment.firebase, PID: 13582
Theme: themes:{default=overlay:com.resurrectionremix.pitchblack, iconPack:com.baranovgroup.nstyle, fontPkg:com.resurrectionremix.pitchblack, com.android.systemui=overlay:com.resurrectionremix.pitchblack, com.android.systemui.navbar=overlay:com.resurrectionremix.pitchblack}
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.skapsdevelopment.firebase/com.skapsdevelopment.firebase.MainActivity}: java.lang.IllegalArgumentException: Given String is empty or null
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2450)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
Caused by: java.lang.IllegalArgumentException: Given String is empty or null
at com.google.android.gms.common.internal.zzac.zzhz(Unknown Source)
at com.google.android.gms.internal.zzagt$zza$zza.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
at com.google.android.gms.internal.zzahe.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.zzd(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.zzc(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
at com.skapsdevelopment.firebase.MainActivity.onCreate(MainActivity.java:36)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
このエラーを解決するために私を助けてください。
アプリケーションクラスをマニフェストに追加します。 'getApplicationContext'の代わりに' this'を使用してください –
すでにマニフェストファイルに追加しました。 –