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.

Crash when selecting Camera

See original GitHub issue

When I open the photo picker fragment and click Camera, I immediately get the following exception:

pl.baftek.discoverrudy E/AndroidRuntime: FATAL EXCEPTION: main
    Process: pl.baftek.discoverrudy, PID: 10220
    java.lang.RuntimeException: Unable to start activity ComponentInfo{pl.baftek.discoverrudy/lv.chi.photopicker.utils.CameraActivity}: java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/pl.baftek.discoverrudy/cache/camera/tmp6252440890878372045.jpg
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/pl.baftek.discoverrudy/cache/camera/tmp6252440890878372045.jpg
        at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:744)
        at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:418)
        at lv.chi.photopicker.utils.FileProvidersKt.providerUri(FileProviders.kt:9)
        at lv.chi.photopicker.utils.CameraActivity.provideImageUri(CameraActivity.kt:77)
        at lv.chi.photopicker.utils.CameraActivity.onCreate(CameraActivity.kt:29)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 

What should I do?

I’m on Android 10 and have the following in my AndroidManifest.xml:

<provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="pl.baftek.discoverrudy.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

This is file_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path
        name="Comment images"
        path="Android/data/pl.baftek.discoverrudy/files/Pictures" />
    <external-path
        name="Chili image cache"
        path="/data/data/pl.baftek.discoverrudy/cache/camera" />
</paths>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
bartekpaciacommented, Aug 23, 2020

oh god, sorry

I did but I forgot to post it and don’t remember anything

sorry I’m dumb

0reactions
koolkiran005commented, Apr 17, 2021

Hi Team,

I got the solution for this by implementing like below

/file_paths.xml/

<?xml version="1.0" encoding="utf-8"?> <paths> <external-path name="external_files" path="." /> <cache-path name="cache_files" path="."/> </paths>

/***** In Manifest file inside application*******/

<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/> </provider>

/***** In Manifest file outside application*******/

<queries> <intent> <action android:name="android.media.action.IMAGE_CAPTURE" /> </intent> </queries>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webcam Keeps Freezing or Crashing in Windows 10 FIX [2022]
Webcam Keeps Freezing or Crashing in Windows 10 FIX [2022]Issues addressed in this tutorial: webcam keeps freezing streamlabswebcam keeps ...
Read more >
Windows Crashes when I open my Camera
In Device Manager, press and hold (or right-click) your webcam, and then select Properties. Select the Driver tab, select Uninstall > Delete the ......
Read more >
9 Ways to Fix Camera App Crashing or Not Working on ...
Open Settings on your Android phone. · Go to Apps & notifications > See all apps. · Here, scroll and select the Camera...
Read more >
Why does the recorder crash or the webcam window freeze ...
If the screen recorder crashes (or you only see a static image in the webcam window) when you try to record your webcam,...
Read more >
T74136 Crash when selecting camera objects
Load any project, click on camera as if to select it, program crashes. Select camera from dropdown/object list, still crashes ALMOST every time...
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