gpt4 book ai didi

android - 错误找不到符号变量 FileProvider 包 android.support.v4.content 不存在

转载 作者:行者123 更新时间:2023-12-02 10:53:24 27 4
gpt4 key购买 nike

我正在使用 Android studio 3.5 gradle plugin 3.5.0 版本 5.6.2

克隆并导入此 Scanlibrary

我正面临这两个错误

error: package android.support.v4.content does not exist

error: cannot find symbol variable FileProvider



有任何想法吗?

AndroidManifest.xml
    <provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.scanlibrary.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>

build.gradle(模块:应用程序)
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.capturedocf"
minSdkVersion 19
targetSdkVersion 29
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation'com.github.chernovdmitriy.injectionholder:appcompat:1.0.0'
implementation project(path: ':scanlibrary')
}

build.gradle(模块:扫描库)
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
ndk
{
moduleName "Scanner"
}
}
sourceSets.main
{
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:29.0.2'
}

PickImageFragement.java
import android.support.v4.content.FileProvider;

public class PickImageFragment extends Fragment {
public void openCamera() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Uri tempFileUri =
FileProvider.getUriForFile(getActivity().getApplicationContext(),
"com.scanlibrary.provider", // As defined in Manifest
file);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, tempFileUri);
} else {
Uri tempFileUri = Uri.fromFile(file);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, tempFileUri);
}

最佳答案

您的项目支持 androidx 并且您使用的库不支持 androidx ,因此您需要启用 jetifier在你的项目中,
所以要启用 jetifier ,将这两行添加到您的 gradle.properties文件:

android.useAndroidX=true
android.enableJetifier=true

第一行 android.useAndroidX=true表示你想从现在开始使用AndroidX
第二行 android.enableJetifier=true表示您希望有工具支持

关于android - 错误找不到符号变量 FileProvider 包 android.support.v4.content 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58156246/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com