我无法打开活动,在logcat中,其下面显示的错误是Java代码和logcat。
2018-11-03 11:00:41.871 1950-2087 / com.example.nabil.logindemo E / StorageException:发生StorageException。 对象在该位置不存在。 代码:-13010 HttpResult:404 2018-11-03 11:00:41.883 1950-2087 / com.example.nabil.logindemo E / StorageException:{“错误”: {“ code”:404,“ message”:“未找到。无法获取对象”}} java.io.IOException:{“错误”:{“代码”:404,“消息”:“未找到。无法获取对象”}} com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage @@ 16.0.4:455) com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage @@ 16.0.4:435) 在com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage @@ 16.0.4:426) com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage @@ 16.0.4:280) com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage @@ 16.0.4:294) 在com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage @@ 16.0.4:65) 在com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage @@ 16.0.4:57) com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage @@ 16.0.4:71) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:636) 在java.lang.Thread.run(Thread.java:784)2018-11-03 11:00:42.616 1950-1950 / com.example.nabil.logindemo E / AndroidRuntime: 致命异常:主要 流程:com.example.nabil.logindemo,PID:1950 android.content.res.Resources $ NotFoundException:字符串资源ID#0xfffffffd 在android.content.res.Resources.getText(Resources.java:410) 在android.content.res.HwResources.getText(HwResources.java:465) 在android.widget.Toast.makeText(Toast.java:328) 在com.example.nabil.logindemo.ProfileActivity $ 2.onCancelled(ProfileActivity.java:65) 位于com.google.firebase.database.core.ValueEventRegistration.fireCancelEvent(com.google.firebase:firebase-database @@ 16.0.4:80) com.google.firebase.database.core.view.CancelEvent.fire(com.google.firebase:firebase-database @@ 16.0.4:40) com.google.firebase.database.core.view.EventRaiser $ 1.run(com.google.firebase:firebase-database @@ 16.0.4:55) 在android.os.Handler.handleCallback(Handler.java:808) 在android.os.Handler.dispatchMessage(Handler.java:101) 在android.os.Looper.loop(Looper.java:166) 在android.app.ActivityThread.main(ActivityThread.java:7425) 在java.lang.reflect.Method.invoke(本机方法) 在com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:245) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 2018-11-03 11:00:42.632 731-2760 /? E / iMonitor:FaultDetect: DUMPTOOL_PRINTF返回。 2018-11-03 11:00:42.634 731-2760 /? E / iMonitor: FaultDetect:DUMPTOOL_PRINTF返回。 2018-11-03 11:00:42.634 731-2760 /? E / iMonitor:FaultDetect:DUMPTOOL_PRINTF返回。 2018-11-03 11:00:42.635 731-2760 /? E / iMonitor:FaultDetect:DUMPTOOL_PRINTF 返回。
ProfileActivity.Java
public class ProfileActivity extends AppCompatActivity {
private TextView profilename,emailid,age;
private ImageView imageprofile;
private Button btnedit;
private FirebaseAuth firebaseAuth;
private FirebaseDatabase firebaseDatabase;
private FirebaseStorage firebaseStorage;
private StorageReference storageReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
profilename=findViewById(R.id.profilename);
emailid=findViewById(R.id.emailid);
age=findViewById(R.id.age);
imageprofile=findViewById(R.id.imageprofile);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
firebaseAuth=FirebaseAuth.getInstance();
firebaseDatabase=FirebaseDatabase.getInstance();
firebaseStorage=FirebaseStorage.getInstance();
storageReference=firebaseStorage.getReference();
storageReference.child(firebaseAuth.getUid()).child("Images/Profile Pic").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Picasso.get().load(uri).into(imageprofile);
}
});
DatabaseReference databaseReference=firebaseDatabase.getReference(firebaseAuth.getUid());
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
DatabaseValues databaseValues=dataSnapshot.getValue(DatabaseValues.class);
profilename.setText("Name: "+ databaseValues.getProfile_name());
emailid.setText("Email: "+ databaseValues.getProfile_username());
age.setText("Age: "+ databaseValues.getProfile_age());
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(ProfileActivity.this,databaseError.getCode(),Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case android.R.id.home:
onBackPressed();
}
return super.onOptionsItemSelected(item);
}
} DatabaseValues.Java
public class DatabaseValues {
private String profile_name;
private String profile_username;
private String profile_age;
public DatabaseValues(){
}
public DatabaseValues(String profile_name, String profile_username, String profile_age) {
this.profile_name = profile_name;
this.profile_username = profile_username;
this.profile_age = profile_age;
}
public String getProfile_name() {
return profile_name;
}
public void setProfile_name(String profile_name) {
this.profile_name = profile_name;
}
public String getProfile_username() {
return profile_username;
}
public void setProfile_username(String profile_username) {
this.profile_username = profile_username;
}
public String getProfile_age() {
return profile_age;
}
public void setProfile_age(String profile_age) {
this.profile_age = profile_age;
}
}