API 15 и AndroidX - ClassNotFoundException: androidx.core.content.FileProvider - PullRequest
0 голосов
/ 23 января 2019

После миграции на AndroidX возникает ошибка в API 15. В API 23 и выше ошибок нет.Перед миграцией приложение работает на API 15 без ошибок.

Ошибка:

java.lang.RuntimeException: Unable to get provider androidx.core.content.FileProvider: java.lang.ClassNotFoundException: androidx.core.content.FileProvider
        at android.app.ActivityThread.installProvider(ActivityThread.java:4240)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:3992)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3946)
        at android.app.ActivityThread.access$1300(ActivityThread.java:123)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4424)
        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:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.ClassNotFoundException: androidx.core.content.FileProvider
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
        at android.app.ActivityThread.installProvider(ActivityThread.java:4225)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:3992) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3946) 
        at android.app.ActivityThread.access$1300(ActivityThread.java:123) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:137) 
        at android.app.ActivityThread.main(ActivityThread.java:4424) 
        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:784) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
        at dalvik.system.NativeStart.main(Native Method) 

build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    flavorDimensions "versionCode"

    repositories {
        flatDir {
            dirs 'libs'
        }
    }
    dexOptions {
        preDexLibraries true
        javaMaxHeapSize "4g"
        dexInProcess = true
    }
    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName '1'

        resConfigs "en", "ru"
        multiDexEnabled true
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
        }
    }
}

dependencies {
    implementation 'com.google.android.material:material:1.0.0'

    implementation 'androidx.core:core:1.0.1'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.exifinterface:exifinterface:1.0.0'

    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'

    implementation 'androidx.lifecycle:lifecycle-runtime:2.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "org.jetbrains.anko:anko:$anko_version"
}

configurations {
    all*.exclude group: 'commons-logging', module: 'commons-logging'
}

поставщик файлов в манифесте

<provider
    android:name="androidx.core.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>

Есть ли способ запустить приложение на API 15?Я добавил «реализацию» androidx.core: core: 1.0.1 », но ничего не изменилось.Та же ошибка при сборке отладки и выпуска.

...