0 votes
in Education by (1.7m points)
I looked at all the answers on StackOverflow and there no answer for me.

Same error for real device and emulators.

Fileprovider always throws IllegalArgumentException

There is Manifest













There is filepath.xml




    path="logs/" /></paths>

And there is code which always throw exception

        final Intent emailIntent = new Intent(Intent.ACTION_SEND);


        File file = new File(logger.getFileName());

        Uri uri = null;

        try {

            uri = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID, file);

        } catch (IllegalArgumentException e) {



logger.getFileName() - returns real file name for example: "logs_22032019.txt"

What I already tried: Changes in Manifest such as: android:authorities="com.realname.of.package" Changes in filepath.xml


1) same name of file 2) just /


1) . 2) / 3) full path 4) files 5) /files 6) files/ e.t.g

What I'm noted - there is really the path of files:


But FileProvider in it goes to:

"log.txt" -> "/data/data/com.app.realname/files/log.txt"-->

NOTE: I need only INTERNAL storage.

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by (1.7m points)
logger.getFileName() - returns real file name for example: "logs_22032019.txt"

That is not a valid filesystem path. It is a valid filename, but it does not say where that file is supposed to be on the device.

This is your FileProvider configuration:



    path="logs/" />

For that, a File that would work is:

File file = new File(getFilesDir(), "logs/"+logger.getFileName());

there is really the path of files... But FileProvider in it goes to

Those are the same filesystem location, for the primary device user.