此代码在我能够更改图像并将其上传到firebase之前工作但突然我现在收到此错误,我不知道问题似乎是什么。
public class SettingsActivity extends AppCompatActivity {
private static final int MAX_LENGTH = 100;
private FirebaseUser mFireBaseUser;
private DatabaseReference mDatabaseReference;
private TextView display;
private TextView c_status, id;
private ImageView proPic;
private Button changeStatus, changePic;
private static final int GALLERY_PIC = 1;
private StorageReference mStorage;
private ProgressDialog mProgressBar;
private DatabaseReference onlineDatabase;
private FirebaseUser current;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
mFireBaseUser = FirebaseAuth.getInstance().getCurrentUser();
String uId = mFireBaseUser.getUid();
mDatabaseReference = FirebaseDatabase.getInstance().getReference().child("users").child(uId);
mStorage = FirebaseStorage.getInstance().getReference();
mProgressBar = new ProgressDialog(this);
display = findViewById(R.id.setting_displayName);
c_status = findViewById(R.id.setting_status);
proPic = findViewById(R.id.setting_image);
changeStatus = findViewById(R.id.setting_changeStatusButton);
changePic = findViewById(R.id.setting_changeImageButton);
id = findViewById(R.id.setting_displayId);
current = FirebaseAuth.getInstance().getCurrentUser();
onlineDatabase = FirebaseDatabase.getInstance().getReference().child("users").child(current.getUid()).child("Online");
mDatabaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String name = dataSnapshot.child("Name").getValue().toString();
String image = dataSnapshot.child("Image").getValue().toString();
String status = dataSnapshot.child("Status").getValue().toString();
final String thumbImage = dataSnapshot.child("Thumb_image").getValue().toString();
String v_id = dataSnapshot.child("Id").getValue().toString();
display.setText(name);
c_status.setText(status);
id.setText(v_id);
if(!thumbImage.equals("default")) {
Picasso.with(SettingsActivity.this).load(thumbImage).placeholder(R.drawable.avatar_default).into(proPic);
}
proPic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplication(), FullScreenImageView.class);
intent.setType(thumbImage);
startActivity(intent);
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
changeStatus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(SettingsActivity.this, ChangeStatus.class));
}
});
changePic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent gallery = new Intent();
gallery.setType("image/*");
gallery.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(gallery, "SELECT IMAGE"), GALLERY_PIC);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_PIC && resultCode == RESULT_OK){
Uri imageUri = data.getData();
CropImage.activity(imageUri)
.setAspectRatio(1, 1)
.start(this);
}
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
mProgressBar.setTitle("Uploading Image");
mProgressBar.setMessage("Please wait while we uploading the image and process...");
mProgressBar.setCanceledOnTouchOutside(false);
mProgressBar.show();
Uri resultUri = result.getUri();
String uId = mFireBaseUser.getUid();
File thumb_filePath = new File(resultUri.getPath());
Bitmap thumb_bitmap = new Compressor(this)
.setMaxWidth(1000)
.setMaxHeight(1000)
.setQuality(1000)
.compressToBitmap(thumb_filePath);
//for uploading thumb image to database
ByteArrayOutputStream baos = new ByteArrayOutputStream();
thumb_bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
final byte[] thumb_byte = baos.toByteArray();
StorageReference store = mStorage.child("Profile picture").child(uId + ".jpg"); // random() er bodole "uId" likhle valo hobe.
final StorageReference thumb_store = mStorage.child("Profile picture").child("Thumb").child(uId + ".jpg");
store.putFile(resultUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if(task.isSuccessful()){
final String download_url = task.getResult().getDownloadUrl().toString();
UploadTask uploadTask = thumb_store.putBytes(thumb_byte);
uploadTask.addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> thumb_task) {
String download_thumb_url = thumb_task.getResult().getDownloadUrl().toString();
if(thumb_task.isSuccessful()) {
Map updateHashMap = new HashMap(); // Map <String, String> likhle hobe na.
updateHashMap.put("Image", download_url);
updateHashMap.put("Thumb_image", download_thumb_url);
mDatabaseReference.updateChildren(updateHashMap).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()) {
mProgressBar.dismiss();
Toast.makeText(SettingsActivity.this, "Uploaded", Toast.LENGTH_LONG).show();
}
else{
mProgressBar.dismiss();
Toast.makeText(SettingsActivity.this, "Error", Toast.LENGTH_LONG).show();
}
}
});
}
else{
}
}
});
}
else{
mProgressBar.dismiss();
Toast.makeText(SettingsActivity.this, "Error", Toast.LENGTH_LONG).show();
}
}
});
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
}
}
}
@Override
public void onResume() {
super.onResume();
onlineDatabase.setValue("true");
}
@Override
public void onPause() {
super.onPause();
onlineDatabase.setValue(ServerValue.TIMESTAMP);
}
}
这是我的个人资料屏幕,只有一个简单的图像视图和两个按钮。当我尝试更改我的个人资料图片时,我收到以下错误。
I/DynamiteModule: Considering local module com.google.android.gms.firebasestorage:0 and remote module com.google.android.gms.firebasestorage:6
I/DynamiteModule: Selected remote version of com.google.android.gms.firebasestorage, version >= 6
W/System: ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/00000039/DynamiteModulesC_GmsCore_prodmnc_xhdpi_release.apk
W/System: ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/00000039/DynamiteModulesC_GmsCore_prodmnc_xhdpi_release.apk
E/ChimeraFileApk: Failed to validate DexClassLoader.
java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.chimera.DynamiteModuleInitializer" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib, /system/vendor/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at ddb.loadClass(:com.google.android.gms@12673021@12.6.73 (040306-194189626):3)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at day.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):22)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):84)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):52)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):117)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):114)
at ryk.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):13)
at com.google.android.gms.chimera.container.DynamiteLoaderImpl.createModuleContext(:com.google.android.gms@12673021@12.6.73 (040306-194189626):18)
at ryf.onTransact(:com.google.android.gms@12673021@12.6.73 (040306-194189626):12)
at android.os.Binder.transact(Binder.java:499)
at com.google.android.gms.internal.zzed.zza(Unknown Source)
at com.google.android.gms.dynamite.zzk.zza(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zzb(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.internal.ace.<init>(Unknown Source)
at com.google.android.gms.internal.ace.zzg(Unknown Source)
at com.google.firebase.storage.StorageReference.zzKO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.zzr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
E/ChimeraModuleLdr: Failed to load code for module FileApk(/data/user_de/0/com.google.android.gms/app_chimera/m/00000039/DynamiteModulesC_GmsCore_prodmnc_xhdpi_release.apk)
ddp: Failed to load code for /data/user_de/0/com.google.android.gms/app_chimera/m/00000039/DynamiteModulesC_GmsCore_prodmnc_xhdpi_release.apk
at day.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):23)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):84)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):52)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):117)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):114)
at ryk.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):13)
at com.google.android.gms.chimera.container.DynamiteLoaderImpl.createModuleContext(:com.google.android.gms@12673021@12.6.73 (040306-194189626):18)
at ryf.onTransact(:com.google.android.gms@12673021@12.6.73 (040306-194189626):12)
at android.os.Binder.transact(Binder.java:499)
at com.google.android.gms.internal.zzed.zza(Unknown Source)
at com.google.android.gms.dynamite.zzk.zza(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zzb(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.internal.ace.<init>(Unknown Source)
at com.google.android.gms.internal.ace.zzg(Unknown Source)
at com.google.firebase.storage.StorageReference.zzKO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.zzr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
W/ChimeraDebugLogger: Singleton logger instance not set.
E/DynamiteLoaderV2: Failed to create module context.
ddp: Failed to load code for /data/user_de/0/com.google.android.gms/app_chimera/m/00000039/DynamiteModulesC_GmsCore_prodmnc_xhdpi_release.apk
at day.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):23)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):84)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):52)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):117)
at ddn.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):114)
at ryk.a(:com.google.android.gms@12673021@12.6.73 (040306-194189626):13)
at com.google.android.gms.chimera.container.DynamiteLoaderImpl.createModuleContext(:com.google.android.gms@12673021@12.6.73 (040306-194189626):18)
at ryf.onTransact(:com.google.android.gms@12673021@12.6.73 (040306-194189626):12)
at android.os.Binder.transact(Binder.java:499)
at com.google.android.gms.internal.zzed.zza(Unknown Source)
at com.google.android.gms.dynamite.zzk.zza(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zzb(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.internal.ace.<init>(Unknown Source)
at com.google.android.gms.internal.ace.zzg(Unknown Source)
at com.google.firebase.storage.StorageReference.zzKO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.zzr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
W/DynamiteModule: Failed to load remote module: Failed to load remote module.
E/NetworkRqFactoryProxy: NetworkRequestFactoryProxy failed with a RemoteException:
com.google.android.gms.dynamite.DynamiteModule$zzc: Remote load failed. No local fallback found.
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.internal.ace.<init>(Unknown Source)
at com.google.android.gms.internal.ace.zzg(Unknown Source)
at com.google.firebase.storage.StorageReference.zzKO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.zzr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
Caused by: com.google.android.gms.dynamite.DynamiteModule$zzc: Failed to load remote module.
at com.google.android.gms.dynamite.DynamiteModule.zzb(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.internal.ace.<init>(Unknown Source)
at com.google.android.gms.internal.ace.zzg(Unknown Source)
at com.google.firebase.storage.StorageReference.zzKO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.zzr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
E/UploadTask: Unable to create a network request from metadata
android.os.RemoteException
at com.google.android.gms.internal.ace.<init>(Unknown Source)
at com.google.android.gms.internal.ace.zzg(Unknown Source)
at com.google.firebase.storage.StorageReference.zzKO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.zzr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0
E/StorageException: null
android.os.RemoteException
at com.google.android.gms.internal.ace.<init>(Unknown Source)
at com.google.android.gms.internal.ace.zzg(Unknown Source)
at com.google.firebase.storage.StorageReference.zzKO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.zzr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0
null
android.os.RemoteException
at com.google.android.gms.internal.ace.<init>(Unknown Source)
at com.google.android.gms.internal.ace.zzg(Unknown Source)
at com.google.firebase.storage.StorageReference.zzKO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.zzr.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:776)
E/HW-JPEG-DEC: [HME_JPEG_DEC_Delete](3321): HME_JPEG_DEC_Delete: decoder_ctx=null
E/HW-JPEG-DEC: [HME_JPEG_DEC_Delete](3321): HME_JPEG_DEC_Delete: decoder_ctx=null
I/HwPointEventFilter: do not support AFT because of no config
的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId 'com.example.sarin.guff'
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.firebase:firebase-client-android:2.5.2+'
implementation 'com.android.support:mediarouter-v7:26.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.5.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.dimorinny:floating-text-button:0.0.4'
implementation 'com.firebaseui:firebase-ui-database:2.3.0'
implementation 'id.zelory:compressor:2.0.0'
implementation 'com.willowtreeapps.spruce:spruce-android:1.0.1'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
implementation 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.1@aar'
implementation 'com.zhihu.android:matisse:0.4.3'
implementation 'com.github.mancj:MaterialSearchBar:0.7.6'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'com.hanks:passcodeview:0.1.2'
implementation "com.google.android.gms:play-services-maps:11.0.4"
implementation 'org.apache.commons:commons-lang3:3.6'
implementation 'com.google.android.gms:play-services-places:11.0.4'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.flaviofaria:kenburnsview:1.0.7'
}
apply plugin: 'com.google.gms.google-services'
项目构建gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/hani-momanii/maven"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
FIREBASE STORAGE RULE:
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}