Bootstrap

java.lang.RuntimeException: Unable to get provider android.provider.DocumentsProvider: java.lang.Ins

照着第二版第一行代码敲的调用摄像头部分,因为编译器提示没有android.support.v4.content.fileprovider。就自己导了一个名字带provider的

android.provider.DocumentsProvider

报错信息如下:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.cameraalbumtest, PID: 13140
    java.lang.RuntimeException: Unable to get provider android.provider.DocumentsProvider: java.lang.InstantiationException: java.lang.Class<android.provider.DocumentsProvider> cannot be instantiated
        at android.app.ActivityThread.installProvider(ActivityThread.java:7400)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6917)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6823)
        at android.app.ActivityThread.access$1400(ActivityThread.java:255)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2089)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:230)
        at android.app.ActivityThread.main(ActivityThread.java:7768)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:508)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)
     Caused by: java.lang.InstantiationException: java.lang.Class<android.provider.DocumentsProvider> cannot be instantiated
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:147)
        at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:60)
        at android.app.ActivityThread.installProvider(ActivityThread.java:7384)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6917) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6823) 
        at android.app.ActivityThread.access$1400(ActivityThread.java:255) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2089) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:230) 
        at android.app.ActivityThread.main(ActivityThread.java:7768) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:508) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034) 
<provider
            android:authorities="${applicationId}.fileprovider"
            android:name="androidx.core.content.FileProvider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"/>
        </provider>

可以

;