我是firebase存储新手。这样我就可以学习它,我正在尝试将图像从ImageView上传到firebase存储。我的应用程序有一个按钮。当我单击按钮时,图像(来自drawable)将显示在imageview上,同时,单击该按钮后,图像应上传到firebase存储。到目前为止,我已经在按钮点击时显示了图像,但我无法将其上传到firebase存储。调用addOnFilureListener (我正在检查通过烤面包调用哪一个)这是我的主java文件和错误我正在接收。我还将我的firebase存储设置为public以防万一。我需要做出哪些更改?
07-29 20:18:50.034 2888-3011/com.example.asad.save_photo E/NetworkRqFactoryProxy: NetworkRequestFactoryProxy failed with a RemoteException:
com.google.android.gms.internal.zzsj$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.android.gms.internal.zzsj.zza(Unknown Source)
at com.google.android.gms.internal.zzaml.<init>(Unknown Source)
at com.google.android.gms.internal.zzaml.zzi(Unknown Source)
at com.google.firebase.storage.StorageReference.zzcyb(Unknown Source)
at com.google.firebase.storage.UploadTask.zzcyn(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
07-29 20:18:50.034 2888-3011/com.example.asad.save_photo E/UploadTask: Unable to create a network request from metadata
android.os.RemoteException
at com.google.android.gms.internal.zzaml.<init>(Unknown Source)
at com.google.android.gms.internal.zzaml.zzi(Unknown Source)
at com.google.firebase.storage.StorageReference.zzcyb(Unknown Source)
at com.google.firebase.storage.UploadTask.zzcyn(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
07-29 20:18:50.034 2888-3011/com.example.asad.save_photo 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
07-29 20:18:50.034 2888-3011/com.example.asad.save_photo E/StorageException: null
android.os.RemoteException
at com.google.android.gms.internal.zzaml.<init>(Unknown Source)
at com.google.android.gms.internal.zzaml.zzi(Unknown Source)
at com.google.firebase.storage.StorageReference.zzcyb(Unknown Source)
at com.google.firebase.storage.UploadTask.zzcyn(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
07-29 20:18:52.389 2888-2961/com.example.asad.save_photo E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaa384ed0
这是我收到的错误
service firebase.storage {
match /b/savephoto-a1cc3.appspot.com/o {
allow read,write;
}
}
以下是我的firebase存储规则:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.asad.save_photo.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/button"
android:id="@+id/image" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
这是我的activity_main布局:
# -*- coding: iso-8859-15
import sys
import requests
import os
if len(sys.argv) >= 2:
os.system('clear')
print "Please wait.."`enter code here`
P1 = str(sys.argv[1])
url = "http://example.com/index.php"
data= {
'getp1':'%s'%(P1)
}
r = requests.get(url,params=data) -o text.txt
os.system('clear')
print r.content
else:
print "[ERROR] Este programa nerrcesita un parámetro";
答案 0 :(得分:2)
解决了它。需要更新Google Play服务并将我的firebase存储规则更改为:
service firebase.storage {
match /b/savephoto-a1cc3.appspot.com/o {
match /{allPaths=**} {
allow read, write;
}
}
}
答案 1 :(得分:0)
service firebase.storage {
match /b/fbstorage-fd9ef.appspot.com/o {
match /{allPaths=**} {
allow read, write;
}
}
}
第二,您需要通过以下链接检查并更新您的Google Play服务:(重要)
https://play.google.com/store/apps/details?id=com.google.android.gms&hl=en
然后重新运行应用程序。古德勒克!
答案 2 :(得分:0)
对我来说,我发现模拟器没有播放服务。所以我从android studio的sdk Manager安装它并创建一个新的模拟器。最后,它在那个模拟器上运行。希望它会有所帮助。