错误找不到符号变量文件提供程序包 android.support.v4.content 不存在



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

克隆并导入此扫描库后

我面临这两个错误

错误:软件包 android.support.v4.content 不存在

错误:找不到符号变量文件提供程序

有什么想法吗?

安卓清单.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 (Module:app(

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(Module:scanlibrary(

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);
}

你的项目支持安卓X,而你正在使用的库不支持安卓X,所以你需要在你的项目中启用jetifier, 因此,要启用jetifier,请将这两行添加到gradle.properties文件中:

android.useAndroidX=true
android.enableJetifier=true

android.useAndroidX=true的第一行表示您要从现在开始使用 AndroidX 第二行android.enableJetifier=true表示您希望获得工具支持

我通过降级到 sdk 28 来修复它,然后我在我的应用程序构建中添加了这段代码以查找源代码

allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked"
}
}
}

然后我看到有java文件缺少库,所以我导入了文件提供程序,错误消失了

相关内容

最新更新