【发布时间】:2018-02-22 14:53:59
【问题描述】:
我正在尝试学习 geofire 我尝试实现 SFVehicle 应用程序,但它显示错误,请您帮忙,这是我项目的关键部分
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private static final GeoLocation INITIAL_CENTER = new GeoLocation(37.7789, -122.4017);
private static final int INITIAL_ZOOM_LEVEL = 14;
private static String GEO_FIRE_DB = "https://learngoef.firebaseio.com";
private static String GEO_FIRE_REF = GEO_FIRE_DB+ "/_geofire";
private Circle searchCircle;
private GeoFire geoFire;
private GeoQuery mGeoQuery;
private Map<String,Marker> markers;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
FirebaseDatabase database = FirebaseDatabase.getInstance();
geoFire = new GeoFire(database.getReference().child("geofire_location"));
String key = geoFire.getDatabaseReference().push().getKey();
geoFire.setLocation(key,new GeoLocation(37.7789, -122.4017));
}
这是我得到的错误:
java.lang.NoSuchMethodError: 没有虚拟方法 setValue(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/firebase/tasks/Task; 在 Lcom/google/firebase/database/DatabaseReference 类中;或其超级 类(声明 'com.google.firebase.database.DatabaseReference' 出现在 /data/app/com.myapps.learninggeofire-2/split_lib_dependencies_apk.apk)
【问题讨论】:
-
java.lang.NoSuchMethodError: 没有虚拟方法 setValue(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/firebase/tasks/Task;在 Lcom/google/firebase/database/DatabaseReference 类中;或其超类(“com.google.firebase.database.DatabaseReference”的声明出现在 /data/app/com.myapps.learninggeofire-2/split_lib_dependencies_apk.apk 中)这是我遇到的错误
-
请从您的应用程序的
build.gradle文件中发布依赖项。您的错误似乎来自那里 -
实现 fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.google.android .gms:play-services-maps:11.8.0' implementation 'com.google.android.gms:play-services-location:11.8.0' testImplementation 'junit:junit:4.12' compile 'com.firebase:geofire-java :2.3.0' 编译 'com.google.firebase:firebase-database:11.8.0' 编译 'com.google.firebase:firebase-auth:11.8.0' 编译 'com.google.firebase:firebase-core:11.8 .0'
-
我已经添加了依赖项
-
与 2.3.0 版本有同样的问题...回滚到 2.1.1 并且工作正常
标签: java android firebase firebase-realtime-database geofire