我想向我的应用添加存储访问框架支持。
我为一些 SAF 操作创建了一个实用程序 Java 类。
我使用
将其添加到示例项目中compileSdkVersion 29
buildToolsVersion "29.0.0"
minSdkVersion 25
targetSdkVersion 29
和
import androidx.documentfile.provider.DocumentFile;
包含在内。
编译成功。
我的应用程序有
compileSdkVersion 21
buildToolsVersion '28.0.3'
minSdkVersion 21
targetSdkVersion 26
但我看到方法名称在
DocumentContracts.copyDocument()
和
DocumentContracts.removeDocument()
为红色(但它们属于 API 级别 19)。
如果我包括
import androidx.documentfile.provider.DocumentFile;
我看到了
documentfile
为红色。
请注意,自动完成功能适用于
DocumentsContract
并向我展示了 SAF 的许多方法。
此外,我发现不再需要某些异常(exception),例如
renameDocument()
或
createDocument()
被使用。
出了什么问题?解决方法是什么?
最佳答案
您的应用程序具有 minSdkVersion 21
(= 应用程序 promise 在 android-21 及更高版本上运行),而您的库具有 minSdkVersion 25
(=库表明它可以不能在 android-24 或更早版本上运行)
所以你的 21-app 不能使用你的 25-lib
关于java - 存储访问框架 - DocumentsContract 的某些方法在包含在我的 Android 应用程序中时未编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56787330/