gpt4 book ai didi

java - FirebaseStorage.getReferenceFromUrl(来源未知)

转载 作者:行者123 更新时间:2023-12-02 12:24:18 27 4
gpt4 key购买 nike

过去两天我收到此错误,我不知道如何解决它,我需要在我使用 RecycleView 的 Android 应用程序中获取存储在 Firebase 中的数据(图像)作为 ListView ;

这是主类:

public class MainActivityPersistent extends AppCompatActivity {

private static final String G_DB_URL = "https://fir-test-ca03d.firebaseio.com/tutorial/list";
//where the data stored in the firebase
private boolean isEnabled;

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

if(!isEnabled) {
try {
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
isEnabled = true;
} catch (RuntimeException e) { }
}

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.list);
final ProgressBar mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mProgressBar.setVisibility(View.VISIBLE);
LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager( this );

mRecyclerView.setLayoutManager(mLinearLayoutManager);
DatabaseReference ref = FirebaseDatabase.getInstance().getReferenceFromUrl(G_DB_URL);

FirebaseRecyclerAdapter<DataModel, ListRowHolder> mAdapter = new FirebaseRecyclerAdapter<DataModel, ListRowHolder>(
DataModel.class,
R.layout.list_row_item, ListRowHolder.class, ref
) {
@Override protected void populateViewHolder(final ListRowHolder viewHolder,
DataModel model, int position) {
mProgressBar.setVisibility(View.GONE);

final StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(model.image);

viewHolder.description.setText(model.description);
Glide.with(MainActivityPersistent.this)
.using(new FirebaseImageLoader())
.load(ref)
.into(viewHolder.image);
}
};
}
}

这是我运行应用程序时遇到的错误:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapplication, PID: 21238
java.lang.IllegalArgumentException: The storage Uri could not be parsed.
at com.google.firebase.storage.FirebaseStorage.getReferenceFromUrl(Unknown Source)
at com.myapplication.MainActivityPersistent$1.populateViewHolder(MainActivityPersistent.java:54)
at com.myapplication.MainActivityPersistent$1.populateViewHolder(MainActivityPersistent.java:47)
at com.firebase.ui.database.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:218)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6400)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6433)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5377)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5640)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5482)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5478)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2215)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1542)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1502)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3625)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3354)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3886)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4856)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4856)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4856)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4856)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4856)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4856)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4856)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4856)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2246)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1968)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6388)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer

最佳答案

FirebaseDatabase.getInstance().getReference(G_DB_URL);

从您的 Firebase 引用中更改此设置

关于java - FirebaseStorage.getReferenceFromUrl(来源未知),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45560310/

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