-1

Here is the problem in its minimal version. I have an android app that does nothing except print the sdk version in its onCreate method. I am using the AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.ascaryalipi">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="28"
        tools:ignore="ScopedStorage" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AscaryaLipi">
        <activity
            android:name="MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
<!--
<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="${applicationId}.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>
-->
    </application>

</manifest>

Things work as expected. Then I uncomment the provider. The app compiles and installs (installDebug) fine. But it crashes the moment the app is run. Logcat gives no relevant message. At least I know that even the first line in onCreate after super.onCreate is not reached.

Following similar SO posts I have added:

android.useAndroidX=true #Was already there
android.enableJetifier=true

to my gradle.properties file. But nothing changed.

Please note that I am NOT using Android-Studio, just plain gradle. No Unity is used, as a similar SO post does. While I do not really use the FileProvider in my minimal example, I do have

import androidx.core.content.FileProvider;

in my MainActivity.java. My device runs SDK version 28.

PS: I am not a dev in absolute need of a quick answer. I would prefer answers that provide insight into the nature of the problem rather than just some "add this magic line to that magic file" type of answer :-)

Edit: I also have the provider_paths.xml in my res/xml:

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

1 Answer 1

-1

I have figured out the problem thanks to this SO post. I used

androidx.core.content.FileProvider

in my java file, but used the following in my manifest: android.support.v4.content.FileProvider.

I have now changed the manifest to match the java file. Things work now.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.