I've tried soo much searching for a solution but there's no solution that sovled my problem!
My app works fine but I want to add the result in the TextView
to a Firebase. After I add the Firebase to my Java code, app crashes with the message "App Unfotunatlly stopped" and I open the app on a real device!
Here's my Java code with the added Firebase:
public class MainActivity extends AppCompatActivity implements LocationListener ,ValueEventListener {
//here is the added firebase that cause the error -_-
FirebaseDatabase database = FirebaseDatabase.getInstance();
private DatabaseReference myRef = database.getReference();
private DatabaseReference buslocationRef = myRef.child("master");
Button getLocationBtn;
TextView locationText, test1;
LocationManager locationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
...........................
}
}
and my build.gradle
:
dependencies {
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.firebase:firebase-database:12.0.1'
}
plus, I've updated my Android Studio to the latest version 3.0!!
I hope you can help me with this. Thanks in Advance.
尝试在build.gradle(项目版本)中将google-services版本更改为4.2.0。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.