stfalcon-studio / StfalconImageViewer

A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures
http://stfalcon.com
Apache License 2.0
1.99k stars 252 forks source link

Tired of resource not found don't know why it is coming in library #51

Open varunjain0888 opened 4 years ago

varunjain0888 commented 4 years ago

Describe the bug

android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:237)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2281)
    at android.content.res.Resources.getLayout(Resources.java:1175)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
    at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
    at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
    at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
    at android.app.Dialog.dispatchOnCreate(Dialog.java:421)
    at android.app.Dialog.show(Dialog.java:315)
    at com.stfalcon.imageviewer.viewer.dialog.ImageViewerDialog.show(ImageViewerDialog.kt:57)
vzhovnitsky commented 3 years ago

I think it is caused by the wrong context, that you construct StfalconImageViewer.Builder with

hitesh-dhamshaniya commented 3 years ago

I am facing the same issue:

Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x7f070073 at android.content.res.Resources.getValue(Resources.java:1351) at androidx.appcompat.widget.ResourceManagerInternal.loadDrawableFromDelegates(ResourceManagerInternal.java:252) at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:139) at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:132) at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:104) at com.myapp.domain.wp.extentions.ContextKt.getDrawableCompat(Context.kt:20) at com.myapp.domain.wp.MainActivity.loadPosterImage(MainActivity.kt:126) at com.myapp.domain.wp.MainActivity.access$loadPosterImage(MainActivity.kt:28) at com.myapp.domain.wp.MainActivity$openViewer$1.invoke(MainActivity.kt:109) at com.myapp.domain.wp.MainActivity$openViewer$1.invoke(MainActivity.kt:28) at com.myapp.domain.wp.MainActivity$sam$com_stfalcon_imageviewer_loader_ImageLoader$0.loadImage(MainActivity.kt) at com.stfalcon.imageviewer.viewer.view.ImageViewerView.open$imageviewer_release(ImageViewerView.kt:193) at com.stfalcon.imageviewer.viewer.dialog.ImageViewerDialog$$special$$inlined$apply$lambda$1.onShow(ImageViewerDialog.kt:50) at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1329) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5421) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I calling it from MainActivity and providing Activity context, Is there any solution for the issue. However, I only face in some devices like Brand: LGE Model: Nexus 5X Orientation: Portrait RAM free: 3 GB Disk free: 771.13 MB Version: 6.0.1

hitesh-dhamshaniya commented 3 years ago

@varunjain0888 : Did you get any solution for the problem?

hitesh-dhamshaniya commented 3 years ago

I think it is caused by the wrong context, that you construct StfalconImageViewer.Builder with

I have used an activity context than also get the above error, should I use application context instead?

Can you please help me out to resolve the issue of the resource not found? @troy379 @vzhovnitsky

vzhovnitsky commented 3 years ago

@hitesh-dhamshaniya @varunjain0888 Ive found out that the issue was that we had the wrong theme in the context. So I fixed it with force applying theme to the context. <style name="PhotoGallery" parent="Theme.AppCompat" />

val context: Context? = context context?.theme?.applyStyle(R.style.PhotoGallery, true)

hitesh-dhamshaniya commented 3 years ago

Thank you for your answer and time, I will check and let you know. Thanks.