https://kotlinlang.org logo
#android
Title
# android
a

Ananiya

06/17/2020, 1:26 PM
hello there , my app is crashing 💥 and returning null path error in piccasso while i am sending text to server, hence i protect every code with "*IfNotNull(
if(x != null)
)*" i spend over 1 n half week stucked trying to solve this problem 😭 please please help me
z

Zach Klippenstein (he/him) [MOD]

06/17/2020, 1:35 PM
Can you post the exception with the stacktrace?
m

marstran

06/17/2020, 1:40 PM
Is it this?
Copy code
if (uri == null) return
val filename = UUID.randomUUID().toString()
val rf = FirebaseStorage.getInstance().getReference("images/$filename")

Rf.putFile(uri!!)
The
uri
could be mutated and set to null before
RS.putFile(uri!!)
. Doing
!!
is kind of asking for null pointers here 😛
I see you are doing
!!
multiple other places as well.
a

Ananiya

06/17/2020, 1:47 PM
@Zach Klippenstein (he/him) [MOD]
the path must not be empty
@marstran but i am able to send the picture . the error is while i am sending the text
z

Zach Klippenstein (he/him) [MOD]

06/17/2020, 2:05 PM
If you could post a stack trace that would help show what is going on when the error occurs (it's the bunch of lines of class names with line numbers).
a

Ananiya

06/17/2020, 2:52 PM
@Zach Klippenstein (he/him) [MOD] sorry for delay
java.lang.IllegalArgumentException: Path must not be empty.
at com.squareup.picasso.Picasso.load(Picasso.java:332)
at com.ultraone.contakt.messaging.SendFile.bind(ChattingActivity.kt:55)
at com.xwray.groupie.Item.bind(Item.java:63)
at com.xwray.groupie.Item.bind(Item.java:49)
at com.xwray.groupie.GroupAdapter.onBindViewHolder(GroupAdapter.java:166)
at com.xwray.groupie.GroupAdapter.onBindViewHolder(GroupAdapter.java:21)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1680)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3175)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2776)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2477)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1544)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7602)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:622)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148
)
Copy code
java.lang.IllegalArgumentException: Path must not be empty.
        at com.squareup.picasso.Picasso.load(Picasso.java:332)
        at com.ultraone.contakt.messaging.SendFile.bind(ChattingActivity.kt:55)
        at com.xwray.groupie.Item.bind(Item.java:63)
        at com.xwray.groupie.Item.bind(Item.java:49)
        at com.xwray.groupie.GroupAdapter.onBindViewHolder(GroupAdapter.java:166)
        at com.xwray.groupie.GroupAdapter.onBindViewHolder(GroupAdapter.java:21)
        at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
        at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
        at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
        at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
        at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
        at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
        at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
        at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
        at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
        at android.view.View.layout(View.java:18010)
        at android.view.ViewGroup.layout(ViewGroup.java:5911)
        at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1680)
        at android.view.View.layout(View.java:18010)
        at android.view.ViewGroup.layout(ViewGroup.java:5911)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
        at android.view.View.layout(View.java:18010)
        at android.view.ViewGroup.layout(ViewGroup.java:5911)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
        at android.view.View.layout(View.java:18010)
        at android.view.ViewGroup.layout(ViewGroup.java:5911)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
        at android.view.View.layout(View.java:18010)
        at android.view.ViewGroup.layout(ViewGroup.java:5911)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
        at android.view.View.layout(View.java:18010)
        at android.view.ViewGroup.layout(ViewGroup.java:5911)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
        at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3175)
        at android.view.View.layout(View.java:18010)
        at android.view.ViewGroup.layout(ViewGroup.java:5911)
        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2776)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2477)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1544)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7602)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
        at android.view.Choreographer.doCallbacks(Choreographer.java:686)
        at android.view.Choreographer.doFrame(Choreographer.java:622)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
m

marstran

06/17/2020, 2:57 PM
Ok, so your stacktrace says that you are sending in a
null
to Picasso on this line:
.load(fileUri?.imageUri)
. So either
fileUri
is null or
imageUrl
is null.
I think this line is the culprit:
fileUri?.imageUri != null || fileUri?.imageUri != ""
. Should it be
&&
instead of
||
?
a

Ananiya

06/17/2020, 3:01 PM
I know when I send text the image URL returns null so to get rid of that I put picasso in If image uri not null As I do it in my code
m

marstran

06/17/2020, 3:02 PM
Yes, but your if-test is wrong. See my previous message.
a

Ananiya

06/17/2020, 3:02 PM
Ok I am going to try
@marstran ohh my god , ohh my God, oh my God, oh My God Ohh ohh ohh 🤑🤑🤑🤑🤑🤑🤑🤑🤑🤑🤑🤑🤑🤑🤑 it works, I haven't think this little code can affect all my project thank you very much very very much!!!!
m

marstran

06/17/2020, 3:19 PM
Haha, great! 🙂
8 Views