gpt4 book ai didi

java - 由于拒绝先前失败的类java.lang.Class错误而拒绝重新初始化,因此无法在Firebase上上传图像

转载 作者:行者123 更新时间:2023-12-03 05:43:59 25 4
gpt4 key购买 nike

我正在尝试通过从手机的图片库中选择图片来上传图片。但是选择它后什么也不做,甚至根本不上传它。

我尝试过干净的构建和重建,仍然没有帮助。

它只是通过说出以下内容自动断开连接:

V/FA: Connection attempt already in progress D/FA: Connected to remote service V/FA: Processing queued up service tasks: 2 V/FA: Inactivity, disconnecting from the service


public class MainActivity extends AppCompatActivity {

Button uploadButton;
ImageView downloadedImage;
private static final int CAMERA_REQUEST_CODE=1;
private StorageReference storageReference;
//private ProgressDialog progressDialog;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

uploadButton = findViewById(R.id.button);
downloadedImage = findViewById(R.id.imageView);
storageReference = FirebaseStorage.getInstance().getReference();

//progressDialog = new ProgressDialog(this);

uploadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent,CAMERA_REQUEST_CODE);
Log.i("Done","Till here");
}
});

}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if(requestCode == CAMERA_REQUEST_CODE && requestCode == RESULT_OK)
{

Log.i("Not Done","This log is not visible");

Uri uri = data.getData();
StorageReference filepath = storageReference.child("Photo").child(uri.getLastPathSegment());
filepath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//progressDialog.dismiss();
Toast.makeText(MainActivity.this,"Uploaded...",Toast.LENGTH_LONG).show();
}
});


}
}
}

我得到的错误是:

I/art: Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;

最佳答案

在&&之后将requestCode更改为resultCode,它将起作用。

if(requestCode == CAMERA_REQUEST_CODE && resultCode == RESULT_OK)
{
}

关于java - 由于拒绝先前失败的类java.lang.Class错误而拒绝重新初始化,因此无法在Firebase上上传图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51055377/

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