gpt4 book ai didi

Android Studio : App crashes after adding Firebase

转载 作者:行者123 更新时间:2023-12-02 03:55:57 25 4
gpt4 key购买 nike

我已经尝试了很多方法来寻找解决方案,但没有解决方案可以解决我的问题!

我的应用运行良好,但我想将 TextView 中的结果添加到 Firebase。将 Firebase 添加到 Java 代码后,应用程序崩溃并显示消息“App Unfotunatlly Stop”,并且我在真实设备上打开该应用程序!

这是我添加了 Firebase 的 Java 代码:

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);
...........................

}
}

和我的build.gradle:

dependencies {

compile 'com.android.support:appcompat-v7:26.1.0'

compile 'com.google.firebase:firebase-database:12.0.1'
}

另外,我已将 Android Studio 更新到最新版本 3.0!!

我希望你能帮我解决这个问题。提前致谢。

最佳答案

尝试在 build.gradle(项目版本)中将 google-services 版本更改为 4.2.0。

关于Android Studio : App crashes after adding Firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49707939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com