question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.io.FileNotFoundException

See original GitHub issue

since switching from v0.14.1 to v1.0.0 fresco will not load images from local storage.

AbstractDraweeController: controller a65fcb9 125: setHierarchy: com.facebook.drawee.generic.GenericDraweeHierarchy@8328fe
AbstractDraweeController: controller a65fcb9 125: onAttach: request needs submit
PipelineDraweeController: controller a65fcb9: getDataSource
AbstractDraweeController: controller a65fcb9 125: submitRequest: dataSource: ca085f
AbstractDraweeController: controller 230cb7b null -> 126: initialize
AbstractDraweeController: controller 230cb7b 126: setHierarchy: com.facebook.drawee.generic.GenericDraweeHierarchy@8e84d98
AbstractDraweeController: controller 230cb7b 126: onAttach: request needs submit
PipelineDraweeController: controller 230cb7b: getDataSource
AbstractDraweeController: controller 230cb7b 126: submitRequest: dataSource: e1d89f1
AbstractDraweeController: controller a65fcb9 125: final_failed @ onFailure: failure: java.io.FileNotFoundException: torage/emulated/0/Images/1482147242789-1165.jpg (No such file or directory)
AbstractDraweeController: controller 230cb7b 126: final_failed @ onFailure: failure: java.io.FileNotFoundException: torage/emulated/0/Images/1481641781949-2816.jpg (No such file or directory)
AbstractDraweeController: controller 240eaeb 103: onDetach
AbstractDraweeController: controller 16f66d9 104: onDetach
AbstractDraweeController: controller 33fba98 105: onDetach
AbstractDraweeController: controller 240eaeb 103: release: image: CloseableReference ac1e844
AbstractDraweeController: controller 16f66d9 104: release: image: CloseableReference d89775a```

you can see that first part of image path (`file:/s`) is missing in log

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
prgometcommented, Dec 22, 2016

@lambdapioneer I have solved the issue, problem is that following code doesn’t work when you try to load image from folder with empty space in name

Uri uri = new Uri.Builder()
                            .scheme(UriUtil.LOCAL_FILE_SCHEME)
                            .path(imagePath)
                            .build();

instead of that use this

Uri uri = Uri.parse("file://" + imagePath);

also i have tested it in fresco sample app (zoomableapp) and issue is persist there, here is the code i changed in test app

 * This file provided by Facebook is for non-commercial testing and evaluation
 * purposes only.  Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.facebook.samples.zoomableapp;

import android.net.Uri;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.facebook.common.util.UriUtil;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.samples.zoomable.DoubleTapGestureListener;
import com.facebook.samples.zoomable.ZoomableDraweeView;

class MyPagerAdapter extends PagerAdapter {

    private static final String[] SAMPLE_URIS = {
            "/storage/emulated/0/test images/99.jpg",
            "/storage/emulated/0/test images/98.jpg",
            "/storage/emulated/0/test images/97.jpg",
            "/storage/emulated/0/test images/96.jpg",
            "/storage/emulated/0/test images/95.jpg",
            "/storage/emulated/0/test images/94.jpg",
            "/storage/emulated/0/test images/93.jpg",
            "/storage/emulated/0/test images/92.jpg"
    };

    private final int mItemCount;
    private boolean mAllowSwipingWhileZoomed = true;

    public MyPagerAdapter(int itemCount) {
        mItemCount = itemCount;
    }

    public void setAllowSwipingWhileZoomed(boolean allowSwipingWhileZoomed) {
        mAllowSwipingWhileZoomed = allowSwipingWhileZoomed;
    }

    public boolean allowsSwipingWhileZoomed() {
        return mAllowSwipingWhileZoomed;
    }

    public void toggleAllowSwipingWhileZoomed() {
        mAllowSwipingWhileZoomed = !mAllowSwipingWhileZoomed;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        FrameLayout page = (FrameLayout) container.getChildAt(position);
        if (page == null) {
            return null;
        }
        ZoomableDraweeView zoomableDraweeView =
                (ZoomableDraweeView) page.findViewById(R.id.zoomableView);
        zoomableDraweeView.setAllowTouchInterceptionWhileZoomed(mAllowSwipingWhileZoomed);
        // needed for double tap to zoom
        zoomableDraweeView.setIsLongpressEnabled(false);
        zoomableDraweeView.setTapListener(new DoubleTapGestureListener(zoomableDraweeView));
        
        // this doesn't work
        /*Uri uri = new Uri.Builder()
                .scheme(UriUtil.LOCAL_FILE_SCHEME)
                .path(SAMPLE_URIS[position % SAMPLE_URIS.length])
                .build();*/

        //this works
        Uri uri = Uri.parse("file://" + SAMPLE_URIS[position % SAMPLE_URIS.length]);

        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setUri(uri)
                .build();
        zoomableDraweeView.setController(controller);
        page.requestLayout();
        return page;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        FrameLayout page = (FrameLayout) container.getChildAt(position);
        ZoomableDraweeView zoomableDraweeView = (ZoomableDraweeView) page.getChildAt(0);
        zoomableDraweeView.setController(null);
    }

    @Override
    public int getCount() {
        return mItemCount;
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public int getItemPosition(Object object) {
        // We want to create a new view when we call notifyDataSetChanged() to have the correct behavior
        return POSITION_NONE;
    }
}
1reaction
succlz123commented, Dec 31, 2016
// 0.14.1 ImageRequest
  public synchronized File getSourceFile() {
    if (mSourceFile == null) {
      mSourceFile = new File(mSourceUri.getPath());
    }
    return mSourceFile;
  }
// 1.0.0 ImageRequest
  public synchronized File getSourceFile() {
    if (mSourceFile == null) {
      String filepath = mSourceUri.toString();
      filepath = filepath.substring("file://".length());
      mSourceFile = new File(filepath);
    }
    return mSourceFile;
  }

Fresco 1.0.0 X Uri uri = Uri.fromFile(“/storage/哈哈/123.jpg”); Uri uri = Uri.parse(“file://” + “/storage/哈哈/123.jpg”);

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.io.FileNotFoundException in Java - GeeksforGeeks
java.io.FileNotFoundException which is a common exception which occurs while we try to access a file. FileNotFoundExcetion is thrown by ...
Read more >
How to Fix the FileNotFoundException in Java.io - Rollbar
The FileNotFoundException is a checked exception in Java that occurs when an attempt to open a file denoted by a specified pathname fails....
Read more >
java.io.FileNotFoundException: the system cannot find the file ...
First thing you would need to do (in this particular) case is make sure that the file get built into the classpath. With...
Read more >
FileNotFoundException (Java Platform SE 8 )
Signals that an attempt to open the file denoted by a specified pathname has failed. This exception will be thrown by the FileInputStream...
Read more >
Solving java.io.FileNotFoundException
java.io.filenotfoundexception is thrown during a failed attempt to open the file denoted by a specified pathname.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found