Android app在API19 上調試運行閃退

Unable to get provider android.support.v4.content.FileProvider 解決方法

問題:java

ava.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.test.bpush-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.test.bpush-1, /vendor/lib, /system/lib]]
...

step-1. 在build.gradle中添加: multiDexEnabled true compile 'com.android.support:multidex:1.0.2'android

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
       ...
        ***multiDexEnabled true***
        ndk {
            abiFilters 'armeabi-v7a'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
    buildTypes {
        release {
            ...
        }
    }
    compileOptions {
        ...
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    ...
    **compile 'com.android.support:multidex:1.0.2'**
}

step-2. 在BaseApplication中重寫attachBaseContext方法app

@Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(base);
    }
相關文章
相關標籤/搜索