Я пытаюсь создать коллекцию в Firebase (java) через android studio. Я не получаю ошибок сборки или отладочных заметок, но на FB ничего не происходит - я не получаю никаких изменений коллекции и тостов от методов OnSuccess и OnFailure. когда я отлаживаю код, команда fStore.collection(userID).document
в методе saveUserData()
пропускается. Я попытался обновить свои зависимости от Gradle, но все еще ничего ..
Буду признателен за любую помощь.
Java Код:
fAuth.createUserWithEmailAndPassword(inputStrings[2], inputStrings[4]).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
saveUserData(v);
Toast.makeText(getApplicationContext(), "Registered", Toast.LENGTH_LONG).show();
if (fAuth.getCurrentUser() != null)
fAuth.getInstance().signOut();
startActivity(new Intent(getApplicationContext(), _01_Login.class));
finish();
} else {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
showRegisterButton();
}
}
});
private void saveUserData(View v) {
Map<String, Object> userMap = new HashMap<>();
userMap.put("businessName", inputStrings[0]);
userMap.put("fullName", inputStrings[1]);
userMap.put("email", inputStrings[2]);
userMap.put("phone", inputStrings[3]);
userMap.put("pw", inputStrings[4]);
userID = fAuth.getCurrentUser().getUid();
fStore.collection(userID).document("UserData").set(userMap)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Toast.makeText(getApplicationContext(), "Success!", Toast.LENGTH_LONG).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getApplicationContext(), "User not registered", Toast.LENGTH_LONG).show();
}
});
}
Gradle (приложение):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
multiDexEnabled true
applicationId "com.example.myapp"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:const
raintlayout:1.1.3'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.google.firebase:firebase-firestore:21.4.2'
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
Gradle (myApp):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}