【问题标题】:Could not find com.androidx.multidex:multidex:2.0.1找不到 com.androidx.multidex:multidex:2.0.1
【发布时间】:2021-09-27 07:36:58
【问题描述】:
> Could not resolve all files for configuration ':app:debugCompileClasspath'.
   > Could not find com.androidx.multidex:multidex:2.0.1.
     Required by:
         project :app

在我的项目中添加 multidex 后出现此错误

【问题讨论】:

  • 你是否在build.gradle文件中添加了com.androidx.multidex:multidex:2.0.1
  • 是实现 'com.androidx.multidex:multidex:2.0.1'
  • implementation"org.jetbrains.kotlin:kotlinstdlib:$kotlin_version"implementation'androidx.core:corektx:1.6.0'implementation'androidx.appcompat:appcompat:1.3.1'implementation'com.google .android.material:material:1.4.0'implementation'androidx.constraintlayot:constraintlayout:2.1.0'implementation 'androidx.legacy:legacy-supportv4:1.0.0'testImplementation 'junit:junit:4.13.2'androidTestImplementation'androidx .test.ext:junit:1.1.3'androidTestImplementation'androidx.test.espresso:espressocore:3.4.0'implementation'com.androidx.multidex:multidex:2.0.1'
  • 必须确保 multiDexEnabled true 已启用。更多请查看this
  • defaultConfig { applicationId "com.example.android.mapplication" minSdkVersion 16 targetSdkVersion 30 versionCode 1 versionName "1.0" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } 是的,我已经添加了,但仍然如此是错误

标签: android kotlin fragment android-multidex android-viewpager2


【解决方案1】:

试试

implementation "androidx.multidex:multidex:2.0.1"

【讨论】:

    【解决方案2】:

    build.gradle (Module)-> 这定义了特定于模块的构建配置。

    build.gradle (Project)-> 这定义了适用于所有模块的构建配置。该文件是项目的组成部分,因此您应该在所有其他源代码的修订控制中维护它们。

    您应该在 Module Level build.gradle (android/app/build.gradle) 部分下方添加。

    dependencies {
    
        implementation 'androidx.multidex:multidex:2.0.1'
    }
    

    仅供参考

    请从项目级 build.gradle 部分中删除 multiDexEnabled = true

    修改模块级 build.gradle 文件以启用 multidex 并将 multidex 库添加为依赖项,如下所示:

    android {
        defaultConfig {
        applicationId "com.app"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        }
    }
    

    【讨论】:

    • 在我只添加了这些 multidex 行之后,我得到了这样的错误
    【解决方案3】:

    实现 'androidx.multidex:multidex:2.0.1' 不是实现 'com.androidx.multidex:multidex:2.0.1'

    【讨论】:

      猜你喜欢
      • 2022-11-03
      • 1970-01-01
      • 2019-11-18
      • 2011-09-25
      • 1970-01-01
      • 2021-08-10
      • 1970-01-01
      • 2021-05-16
      • 2018-10-19
      相关资源
      最近更新 更多