当我从java迁移到kotlin或android到androidx时,我面临这个问题,下面是我的错误
java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority androidx.multidex.provider
答复W/System.err: androidx.core.content.FileProvider.b(FileProvider.java:606) 2019-10-05 21:52:23.494 14821-14821/com.prodege.err: androidx.core.content.FileProvider.a(FileProvider.java:579) 2019-10-05 21:52:23.494 14821-14821/com.prodege.err:androidx.core.content.FileProvider.a(FileProvider.java:579) 2019-10-05 21:52:23.494 14821-14821/com.prodege.应答W/androidx.core.content.FileProvider.a(FileProvider.java:417) 2019-10-05 21:52:23.494 14821-14821/com.prodege.应答W/System.err: com.prodege.answer.ui.surveyWebView.SurveysWebViewActivity.openCamera(SurveysWebViewActivity.kt:379) 2019-10-05 21:52:23.494 -14821/com.prodege.应答W/System.err: at com.prodege.answer.ui.surveyWebView.SurveysWebViewActivity.access$openCamera(SurveysWebViewActivity2019-10-05 21:52:23.494 14821-14821/com.prodege.应答W/System.err: com.prodege.answer.ui.surveyWebView.SurveysWebViewActivity$loadWebView$2.onShowFileChooser(SurveysWebViewActivity.kt:175) 2019-10-05 21:52:23.494 14821-14821/com.prodege.应答W/System.err: at xl.a(PG:537) 2019-10-05 21:52:23.494 14821-14821/com.prodege.答案W/Systemandroid.os.MessageQueue.next(MessageQueue.java:326) .err: agE.runFileChooser(PG:72) 2019-10-05 21:52:23.494 14821-14821/com.prodege.应答W/System.err: at android.os.MessageQueue.nativePollOnce(本地方法) 2019-10-05 21:52:23.495 14821-14821/com.prodege.应答W/System.err: at agE.runFileChooser 2019-10-05 21:52:23.495 14821-14821/com。android.app.ActivityThread.main(ActivityThread.java:6669) W/System.err: at android.os.Looper.loop(Looper.java:160) 2019-10-05 21:52:23.495 14821-14821/com.prodege.应答W/System.err: at java.lang.reflect.Method.invoke 2019-10-05 21:52:23.495 14821-14821/com.prodege.应答W/System.err: at java.lang.reflect.Method.invoke(原生方法) 2019-10-05 21:52:23.495 14821-14821/com.prodege.应答W/System.err: com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 2019-10-05 21:52:23.495 14821-14821/com.prodege.应答W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
这是我的清单文件,我还扩展了multiDexApp
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.prodege.answer.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
这是我的buil.gradle文件
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.prodege.answer"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "2.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// buildConfigField "boolean", "URBAN_AIRSHIP_DEBUG_MODE", "false"
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
// buildConfigField "boolean", "URBAN_AIRSHIP_DEBUG_MODE", "true"
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
kapt {
javacOptions {
// Increase the max count of errors from annotation processors.
// Default is 100.
option("-Xmaxerrs", 1000)
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
依赖性{实现fileTree(包括:‘*..jar’,dir:'libs')
//Kotlin support dependencies
implementation kotlinDependencies.core
implementation kotlinDependencies.coroutinesCore
implementation kotlinDependencies.coroutinesAndroid
// Kotlin Extension for Simplified coding
implementation androidxDependencies.ktx
//Android x design and backward compatibility support dependencies
implementation androidxDependencies.appCompat
implementation androidxDependencies.constraintlayout
implementation androidxDependencies.lifecycleExtention
implementation androidxDependencies.recyclerView
implementation androidxDependencies.multiDex
implementation androidxDependencies.roomRuntime
kapt androidxDependencies.roomCompiler
//Google dependencies
implementation googleDependencies.material
implementation googleDependencies.gson
// Network Library Retrofit dependencies
implementation networkDependencies.retrofit
implementation networkDependencies.retrofitGsonConveter
implementation networkDependencies.scalarConveter
implementation networkDependencies.okHttpLogs
implementation networkDependencies.kotlinCoroutineAdapterFactory
/* UI Related Dependencies */
implementation uiDependencies.glide
implementation 'com.facebook.stetho:stetho:1.5.1'
/* Koin DI */
implementation kotlinDI.core
implementation kotlinDI.scope
implementation kotlinDI.viewModel
implementation analyticsSdk.adjust
implementation(name: 'fraudforce-lib-release-3.1.0', ext: 'aar')
implementation project(path: ':library')
implementation 'com.daimajia.androidanimations:library:2.3@aar'
// Testing Dependencies
androidTestImplementation androidxTestingDependencies.archCore
androidTestImplementation androidxTestingDependencies.core
androidTestImplementation androidxTestingDependencies.contrib
androidTestImplementation androidxTestingDependencies.intents
androidTestImplementation androidxTestingDependencies.uiAutoMator
//UA Dependencies
implementation uaFirebase.core
implementation uaFirebase.firebaseDynamicLink
implementation uaFirebase.firebaseMsg
implementation uaFirebase.urbanairship
implementation(uaFirebase.crashlytics)
{
transitive = true
}
testImplementation "junit:junit:$junitVersion"
//sense360
implementation sense360Dep.sense360
//Cuebiq
/*implementation(cuebiqDep.cuebiq) {
exclude module: 'okhttp'
exclude module: 'okio'
exclude module: 'play-services-location'
exclude module: 'gson'
}*/
//gimbal
implementation gimbalDep.gimbalSdk
implementation gimbalDep.gimbalImpl
implementation(gmsPlayServices.location) {
force = true
}
implementation gmsPlayServices.gmsServicesAds
implementation gmsPlayServices.goodleMap
implementation gmsPlayServices.goodleMapUtil
implementation(gmsPlayServices.gmsServices) {
force = true
}
implementation 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
/* BlinkReceipt dependencies*/
implementation project(':LibBlinkReceipt')
implementation "com.jaredrummler:android-device-names:1.0.9"
implementation blinkReceiptDependencies.retrofitscalers
implementation blinkReceiptDependencies.okio
implementation blinkReceiptDependencies.easyPermission
}
发布于 2020-11-05 11:16:44
import androidx.multidex.BuildConfig // NOT DO THIS!!!
val uri = FileProvider.getUriForFile(this,
BuildConfig.APPLICATION_ID+ ".provider", _tempFile)
不使用androidx.multidex.BuildConfig,因为这些值不是应用程序的值:
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package androidx.multidex;
public final class BuildConfig {
public static final boolean DEBUG = false;
public static final String APPLICATION_ID = "androidx.multidex";
public static final String BUILD_TYPE = "release";
public static final String FLAVOR = "";
public static final int VERSION_CODE = -1;
public static final String VERSION_NAME = "";
public BuildConfig() {
}
}
https://stackoverflow.com/questions/58251265
复制相似问题