Я пытаюсь сохранить в Firebase через Android. Я "подключен", как говорится в моей android студии, и я скачал файл google-services. json из Firebase. Пожалуйста, ознакомьтесь с приведенным ниже кодом о том, как я его реализую.
final Transaction transaction = new Transaction();
transaction.set_amount(Double.parseDouble(textView_receiptTotal.getText().toString().replace("PHP", "").trim()));
transaction.set_conductor(textView_conductorName.getText().toString());
transaction.set_destination(selectedRoutePostDestination.get_routePostCode());
transaction.set_distance(Integer.parseInt(selectedRoutePostDestination.get_routePostDistance()));
transaction.set_origin(currentPost.get_routePostCode());
transaction.set_passenger(Integer.parseInt(textView_receiptPassengers.getText().toString()));
transaction.set_type(selectedTransactionType);
transaction.set_vehicle(textView_vehicle.getText().toString());
ThreadPoolManager.getInstance().executeTask(new Runnable() {
@Override
public void run() {
FirebaseDatabase mDatabase = FirebaseDatabase.getInstance();
DatabaseReference mDatabaseReference = mDatabase.getReference();
mDatabaseReference = mDatabase.getReference("transactions");
mDatabaseReference.setValue(transaction);
Log.e("log", "SOMETHING");
}
});
Это мой проект gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
// 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
}
Это мой app gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.jiebao.demos"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
beta {
matchingFallbacks = ['release', 'debug']
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
repositories { maven { url "https://maven.google.com" } }
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-firestore:21.3.1'
implementation 'androidx.multidex:multidex:2.0.0'
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.google.firebase:firebase-appindexing:19.0.0'
implementation fileTree(dir: 'libs', includes: ['*.jar'])
}
Я не получаю никаких ошибок. Это просто не спасет.