首页 文章

GeoFire SetLocation不工作

提问于
浏览
0

我正在尝试将位置保存到地理位置,但没有从控制台和日志中获得任何响应 .

我在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永远不会被解雇,我的数据库中没有任何更新 . 其他人遇到这个问题或我错误配置了吗?

这是我的gradle文件:

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'

1 回答

  • 1

    在app 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'
    

相关问题