我正在使用Android Studio 3.5 Gradle插件3.5.0版本5.6.2
我面临着这两个错误
错误:程序包android.support.v4.content不存在
错误:找不到符号变量FileProvider
有任何想法吗?
AndroidManifest.xml
android:name="android.support.v4.content.FileProvider"
android:authorities="com.scanlibrary.provider"
android:exported="false"
android:grantUriPermissions="true">
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
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(模块: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);
}