GeoFire SetLocation не работает

Я пытаюсь сохранить местоположение в geofire, но не получаю ответа от консоли и в журналах.

Я добавил зависимость в файлы gradle и создал ссылку на свою базу данных следующим образом:

    DatabaseReference pickupRef = FirebaseDatabase.getInstance().getReference(AppConstants.PICK_UP_REF);
    pickupRef.keepSynced(true);

и строка AppConstants.PICK_UP_REF равна PickUpRef. В своей деятельности я сделал это:

Log.d(TAG, "UID in PUR:\t" + uid);
    GeoFire mGeoFire = new GeoFire(pickupRef.child(uid));

    if (mLastLocation != null) {
        mGeoFire.setLocation(uid, new GeoLocation(mLastLocation.getLatitude(), mLastLocation.getLongitude()), new GeoFire.CompletionListener() {
            @Override
            public void onComplete(String key, DatabaseError error) {
                if (error != null){
                    Log.d(TAG, "Write complete");
                } else {
                    Log.d(TAG, "Write Failed:\t" + error.getMessage());
                }
            }
        });

Слушатель oncompletionlistener никогда не запускается, и в моей базе данных ничего не обновляется. Кто-нибудь еще сталкивался с этой проблемой или я неправильно настроил?

Вот мой файл градиента:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.jjoey.transportr"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 
        "android.support.test.runner.AndroidJUnitRunner"
    }
     buildTypes {
         release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
    }
 }

 dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'  
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.reginald:editspinner:1.0.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.google.firebase:firebase-core:12.0.1'
    implementation 'com.google.firebase:firebase-auth:12.0.1'
    implementation 'com.google.firebase:firebase-database:12.0.1'
    implementation 'com.google.firebase:firebase-storage:12.0.1'
    implementation 'com.firebase:geofire-android:2.3.1'
    implementation 'com.google.android.gms:play-services-nearby:12.0.1'
    implementation 'com.google.android.gms:play-services-maps:12.0.1'
    implementation 'com.google.android.gms:play-services-places:12.0.1'
    implementation 'com.google.android.gms:play-services-location:12.0.1'
    implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:cardview-v7:27.1.1'
}
apply plugin: 'com.google.gms.google-services'

person Andromeda    schedule 04.06.2018    source источник
comment
Вероятно, это не связано, но ваша логика onComplete обратная - вы проверяете, не является ли оно нулевым, и поэтому, если оно равно нулю, вы затем пытаетесь получить ошибку доступа. Другими словами, в случае успеха вы получите исключение нулевого указателя.   -  person Andy    schedule 05.06.2018
comment
@Andromeda, пожалуйста, добавьте файлы grandle, спасибо   -  person Paraskevas Ntsounos    schedule 05.06.2018
comment
@Энди, это из документации geofire   -  person Andromeda    schedule 05.06.2018
comment
@ParaskevasNtsounos, проверьте еще раз   -  person Andromeda    schedule 05.06.2018
comment
@Андромеда проверь мой ответ и скажи мне, что случилось   -  person Paraskevas Ntsounos    schedule 05.06.2018
comment
@Andromeda очень хорошо, вы знаете лучше, но когда ошибка равна нулю (часть «else»), вы затем выполняете error.getMessage(), который является доступом к нулевому указателю. Я предполагаю, что вы ловите исключения выше...   -  person Andy    schedule 06.06.2018
comment
Да, остальная часть должна бросить NPE .. спасибо, хотя   -  person Andromeda    schedule 06.06.2018


Ответы (1)


Измените свои зависимости, как показано ниже, в приложении grandle:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.reginald:editspinner:1.0.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.firebase:geofire-android:2.3.1'
    implementation 'com.google.android.gms:play-services-nearby:15.0.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-places:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:cardview-v7:27.1.1'
}

И изменение в Project grandle:

classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
person Paraskevas Ntsounos    schedule 05.06.2018
comment
Это работает, я понял, что устанавливаемые значения были пустыми из-за неправильных имен переменных. Я приму ваш ответ, хотя никто другой не пытался помочь. Большое тебе спасибо. - person Andromeda; 05.06.2018