gpt4 book ai didi

java - Android Firebase 实时异常 java.lang.StackOverflowError : stack size 8MB

转载 作者:太空宇宙 更新时间:2023-11-04 10:38:56 26 4
gpt4 key购买 nike

我在我的应用程序中遇到了异常 java.lang.StackOverflowError: stack size 8MB 的问题,所以我尝试将一个具有其属性(Uri、brand、matricule...)的对象 CAR 添加到其 chlid Cars 中的特定用户这是我的代码

public void uploadtothefirebase() {

progressBar = findViewById(R.id.progressBar3);
auth = FirebaseAuth.getInstance();
database = FirebaseDatabase.getInstance();
reference = database.getReference("User");

// Upload the pic to the Firebase storage and save the Uri and set it in the Realtime
storage= FirebaseStorage.getInstance().getReference();
StorageReference filepath = storage.child("photoscars").child(uricarimage.getLastPathSegment());
filepath.putFile(uricarimage).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
auth = FirebaseAuth.getInstance();
downloadeduri= taskSnapshot.getDownloadUrl();
Toast.makeText(getApplicationContext(),"Uri = "+downloadeduri.toString(),Toast.LENGTH_SHORT).show();

progressBar = findViewById(R.id.progressBar3);
auth = FirebaseAuth.getInstance();
database = FirebaseDatabase.getInstance();
reference = database.getReference("User");
assert firebaseUser != null;
firebaseUser = auth.getCurrentUser();

reference.orderByChild("fullName").equalTo(firebaseUser.getDisplayName()).addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String Uid= dataSnapshot.getKey();
brand = inputbrand.getText().toString();
matricule = inputmatricule.getText().toString();
numcartegrise = inputcartegrise.getText().toString();
progressBar = findViewById(R.id.progressBar3);


car = new Car(downloadeduri,brand,spin_val,matricule,numcartegrise);
reference.child(Uid).setValue(car);

}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {}
@Override
public void onCancelled(DatabaseError databaseError) {}});






progressBar.setVisibility(View.GONE);
final AlertDialog.Builder adb = new AlertDialog.Builder(Setinformationcar.this);
adb.setTitle("The Car has Added ");
adb.setMessage("The Car has Added To Your List You can Use it to Create Trip ");
adb.setCancelable(false);

adb.setPositiveButton(" OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

startActivity(new Intent(getApplication(),Mycars.class));
finish();
}});

adb.show();

}
});
}

你能帮我解决这个问题吗?

enter image description here

最佳答案

更改此:

downloadeduri= taskSnapshot.getDownloadUrl();

对此:

String downloadeduri= taskSnapshot.getDownloadUrl().toString();

Firebase 不接受数据库中的 uri,因此将其转换为字符串以便能够将其添加到数据库中。

关于java - Android Firebase 实时异常 java.lang.StackOverflowError : stack size 8MB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49226502/

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