我一直在尝试使用Firebase的存储库尝试使用Android Studio中的Google示例代码上传文件:
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://<your-bucket-name>");
UUID imageID = UUID.randomUUID();
StorageReference pendingImageRef = storageRef.child("products/images/"+imageID);
UploadTask uploadTask = pendingImageRef.putBytes(imageData);
....
这给了我这个:
java.lang.NoClassDefFoundError:
Failed resolution of: Lcom/google/firebase/storage/FirebaseStorage;
at com.myprogram.CreateProductFragment$1.onClick(CreateProductFragment.java:304)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:702)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.storage.FirebaseStorage" on path: ....
我的想法是这是dexing的一个问题,所以我重新调整了它并对应用程序进行了多重索引。这并没有消除这个问题。