Photoview: java.lang.IllegalStateException: ImageView no longer exists. You should not use this PhotoViewAttacher any more.

Created on 9 Jul 2014  路  7Comments  路  Source: Baseflow/PhotoView

The following ISE started to appear after update to the 1.3-SNAPSHOT due to #199.

java.lang.IllegalStateException: ImageView no longer exists. You should not use this PhotoViewAttacher any more.
        at uk.co.senab.photoview.PhotoViewAttacher.getImageView(SourceFile:209)
        at uk.co.senab.photoview.PhotoViewAttacher.onGlobalLayout(SourceFile:311)
        at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:667)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2000)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1139)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4879)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
        at android.view.Choreographer.doCallbacks(Choreographer.java:579)
        at android.view.Choreographer.doFrame(Choreographer.java:548)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
        at android.os.Handler.handleCallback(Handler.java:725)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:153)
        at android.app.ActivityThread.main(ActivityThread.java:5299)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
        at dalvik.system.NativeStart.main(Native Method)
bug

Most helpful comment

Don't do both:

mAttacher = new PhotoViewAttacher(mImageView);

and

    <uk.co.senab.photoview.PhotoView android:id="@+id/full_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

Pick one or the other (this solved it for me -- I have it inside a ViewPager).

All 7 comments

i'm facing the same strange issue

found the source of the issue: PhotoViewAttacher - the ImageView is hold only by a WeakReference and is getting garbage collected

Solution?

Same issue here as per code given in the README

Using latest build from dev my logs are still spamed with "ImageView no longer exists. You should not use this PhotoViewAttacher any more."

Can confirm, still seeing the same issue using the attacher in a ViewPager. Looks like its an info log now and the attacher is still around even though the imageview no longer exists.

Don't do both:

mAttacher = new PhotoViewAttacher(mImageView);

and

    <uk.co.senab.photoview.PhotoView android:id="@+id/full_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

Pick one or the other (this solved it for me -- I have it inside a ViewPager).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhangzhen92 picture zhangzhen92  路  11Comments

AnthonyKoueik picture AnthonyKoueik  路  9Comments

sunshaobei picture sunshaobei  路  5Comments

hameno picture hameno  路  3Comments

usmanrana07 picture usmanrana07  路  5Comments