0
我試圖使用Firebase Storage
和Picasso
在ImageView中加載圖像,但它在logcat中顯示空指針異常。當我錯了please.Below是我MainActiviy.class
畢加索和Firebase存儲
package oerrride.we.huzykamz.imageretrieval;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.squareup.picasso.Picasso;
import oerrride.we.huzykamz.testingappfirebase.R;
public class MainActivity extends AppCompatActivity {
public FirebaseStorage mStorage;
ImageView img;
StorageReference storageRef = mStorage.getReferenceFromUrl("gs://askdoctor-546bf.appspot.com");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mStorage= FirebaseStorage.getInstance();
img =(ImageView) findViewById(R.id.img);
StorageReference spaceRef = storageRef.child("askdoctor/namasuba.jpg");
String url = spaceRef.getBucket();
System.out.println("Here is the print of url : "+url);
Picasso.with(MainActivity.this).load(url)
.error(R.mipmap.ic_launcher).
resize(50, 50)
.placeholder(R.mipmap.ic_launcher).into(img);
}
}
然後,這是我的錯誤logcat中。
09-24 21:05:50.767 17655-17655/oerrride.we.huzykamz.testingappfirebase I/art: Not late-enabling -Xcheck:jni (already on)
09-24 21:05:50.799 17655-17655/oerrride.we.huzykamz.testingappfirebase I/art: Late-enabling JIT
09-24 21:05:50.844 17655-17655/oerrride.we.huzykamz.testingappfirebase I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
09-24 21:05:50.946 17655-17655/oerrride.we.huzykamz.testingappfirebase W/System: ClassLoader referenced unknown path: /data/app/oerrride.we.huzykamz.testingappfirebase-1/lib/x86
09-24 21:05:51.566 17655-17669/oerrride.we.huzykamz.testingappfirebase W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
09-24 21:05:51.789 17655-17662/oerrride.we.huzykamz.testingappfirebase W/art: Suspending all threads took: 53.648ms
09-24 21:05:51.827 17655-17669/oerrride.we.huzykamz.testingappfirebase W/GooglePlayServicesUtil: Google Play services out of date. Requires 9452000 but found 8087470
09-24 21:05:51.829 17655-17655/oerrride.we.huzykamz.testingappfirebase W/GooglePlayServicesUtil: Google Play services out of date. Requires 9452000 but found 8087470
09-24 21:05:51.830 17655-17655/oerrride.we.huzykamz.testingappfirebase I/DynamiteModule: Considering local module com.google.android.gms.flags:1 and remote module com.google.android.gms.flags:0
09-24 21:05:51.830 17655-17655/oerrride.we.huzykamz.testingappfirebase I/DynamiteModule: Selected local version of com.google.android.gms.flags
09-24 21:05:51.850 17655-17655/oerrride.we.huzykamz.testingappfirebase W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
09-24 21:05:51.852 17655-17655/oerrride.we.huzykamz.testingappfirebase W/GooglePlayServicesUtil: Google Play services out of date. Requires 9452000 but found 8087470
09-24 21:05:51.852 17655-17655/oerrride.we.huzykamz.testingappfirebase I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:0
09-24 21:05:51.853 17655-17655/oerrride.we.huzykamz.testingappfirebase E/FirebaseCrash: Failed to initialize crash reporting
com.google.firebase.crash.internal.zzg$zza: com.google.android.gms.internal.zzsb$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.firebase.crash.internal.zzg.zzbq(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: com.google.android.gms.internal.zzsb$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.android.gms.internal.zzsb.zza(Unknown Source)
at com.google.firebase.crash.internal.zzg.zzbq(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.<init>(Unknown Source)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-24 21:05:51.896 17655-17655/oerrride.we.huzykamz.testingappfirebase I/FA: App measurement is starting up, version: 9452
09-24 21:05:51.896 17655-17655/oerrride.we.huzykamz.testingappfirebase I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
09-24 21:05:51.964 17655-17655/oerrride.we.huzykamz.testingappfirebase I/FirebaseInitProvider: FirebaseApp initialization successful
09-24 21:05:52.028 17655-17686/oerrride.we.huzykamz.testingappfirebase W/GooglePlayServicesUtil: Google Play services out of date. Requires 9452000 but found 8087470
09-24 21:05:52.142 17655-17690/oerrride.we.huzykamz.testingappfirebase W/GooglePlayServicesUtil: Google Play services out of date. Requires 9452000 but found 8087470
09-24 21:05:52.143 17655-17690/oerrride.we.huzykamz.testingappfirebase W/DynamiteModule: Local module descriptor class for com.google.android.gms.firebasestorage not found.
09-24 21:05:52.143 17655-17690/oerrride.we.huzykamz.testingappfirebase I/DynamiteModule: Considering local module com.google.android.gms.firebasestorage:0 and remote module com.google.android.gms.firebasestorage:0
09-24 21:05:52.143 17655-17690/oerrride.we.huzykamz.testingappfirebase E/NetworkRqFactoryProxy: NetworkRequestFactoryProxy failed with a RemoteException:
com.google.android.gms.internal.zzsb$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.android.gms.internal.zzsb.zza(Unknown Source)
at com.google.android.gms.internal.zzami.<init>(Unknown Source)
at com.google.android.gms.internal.zzami.zzi(Unknown Source)
at com.google.firebase.storage.StorageReference.zzcxz(Unknown Source)
at com.google.firebase.storage.zzb.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)
09-24 21:05:52.143 17655-17690/oerrride.we.huzykamz.testingappfirebase E/GetMetadataTask: Unable to create firebase storage network request.
android.os.RemoteException
at com.google.android.gms.internal.zzami.<init>(Unknown Source)
at com.google.android.gms.internal.zzami.zzi(Unknown Source)
at com.google.firebase.storage.StorageReference.zzcxz(Unknown Source)
at com.google.firebase.storage.zzb.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)
09-24 21:05:52.144 17655-17690/oerrride.we.huzykamz.testingappfirebase 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
09-24 21:05:52.144 17655-17690/oerrride.we.huzykamz.testingappfirebase E/StorageException: null
android.os.RemoteException
at com.google.android.gms.internal.zzami.<init>(Unknown Source)
at com.google.android.gms.internal.zzami.zzi(Unknown Source)
at com.google.firebase.storage.StorageReference.zzcxz(Unknown Source)
at com.google.firebase.storage.zzb.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)
09-24 21:05:52.172 17655-17666/oerrride.we.huzykamz.testingappfirebase I/art: Background sticky concurrent mark sweep GC freed 11792(944KB) AllocSpace objects, 5(100KB) LOS objects, 66% free, 1226KB/3MB, paused 6.481ms total 46.096ms
09-24 21:05:52.397 17655-17698/oerrride.we.huzykamz.testingappfirebase D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
09-24 21:05:52.481 17655-17655/oerrride.we.huzykamz.testingappfirebase W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-24 21:05:52.579 17655-17698/oerrride.we.huzykamz.testingappfirebase I/OpenGLRenderer: Initialized EGL, version 1.4
09-24 21:05:52.747 17655-17698/oerrride.we.huzykamz.testingappfirebase W/EGL_emulation: eglSurfaceAttrib not implemented
09-24 21:05:52.747 17655-17698/oerrride.we.huzykamz.testingappfirebase W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabe30560, error=EGL_SUCCESS
09-24 21:05:52.899 17655-17662/oerrride.we.huzykamz.testingappfirebase W/art: Suspending all threads took: 6.593ms
09-24 21:06:02.284 17655-17686/oerrride.we.huzykamz.testingappfirebase I/FA: Tag Manager is not found and thus will not be used
09-24 21:06:02.307 17655-17686/oerrride.we.huzykamz.testingappfirebase W/GooglePlayServicesUtil: Google Play services out of date. Requires 9452000 but found 8087470
09-24 21:06:02.310 17655-17655/oerrride.we.huzykamz.testingappfirebase W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
09-24 21:06:09.863 17655-17662/oerrride.we.huzykamz.testingappfirebase W/art: Suspending all threads took: 5.043ms
由於它的工作,但爲什麼火力地堡的未加載圖像的URL,甚至當我在瀏覽器中複製它不加載爲什麼@qbix –
@LutaayaHuzaifah:你需要使用'getDownloadUrl()'而不是'getBucket()'。看到這個例子代碼的答案:http://stackoverflow.com/a/37701878/4815718 –
謝謝@qbix,我已經這樣做,但應用程序加載時,什麼也沒有顯示,它不會崩潰,檢查我的logcat,我已經更新它。我看到它的說法谷歌播放服務已過時,但我剛剛更新它們。代碼中是否有錯誤? –