如何修复"Could not find core-1.1.0.jar (androidx.core:core:1.1.0)"错误。扑动



每个开发人员都遇到过这种错误,尤其是在这个特定的文件core-1.1.0.jar.中

问题是,谷歌出于某种原因从服务器上删除了该文件,我想,因为整个错误都是说它在网上找不到该文件。

不幸的是,网上有很多解决方案都不起作用,这些解决方案包括:

  • 将您的项目迁移到AndroidX
  • 降级gradle插件版本
  • 使用AndroidManifest.xml文件中的一些权限
  • 降低颤振版本
  • 使用JCenter((和谷歌((存储库

等等…,你明白了。

下面我将分享我如何修复这个错误的经验。

你必须明白问题不在于你的代码或项目这个问题只是在你的项目使用的插件中,这正是为什么当我试图将我的项目迁移到AndroidX时,我收到了一条消息,上面写着:

未找到AndroidX用法。

下面是解决此错误的步骤。

首先:您需要将此代码添加到应用程序的gradle.build文件中,它位于以下路径android/app/gradle.build:中

dependencies {
def core_version = "1.3.2"
// Java language implementation
implementation "androidx.core:core:$core_version"
// Kotlin
implementation "androidx.core:core-ktx:$core_version"
// To use RoleManagerCompat
implementation "androidx.core:core-role:1.0.0"
// To use the Animator APIs
implementation "androidx.core:core-animation:1.0.0-alpha02"
// To test the Animator APIs
androidTestImplementation "androidx.core:core-animation-testing:1.0.0-alpha02"
}

上面的代码只是简单地更改您将要使用的core.jar版本。

第二:您需要转到导致此错误的插件文件夹,只需读取错误即可轻松知道是哪个插件导致了错误,下面是一个示例:

任务":image_picker:compileDebugJavaWithJavac"的执行失败>无法解析所有要配置的文件":file_picker:debugCompileClasspath">找不到core-1.1.0.jar(androidx.core:核心:1.1.0(.

现在,正如您所看到的,image_picker插件导致了错误。所以我们需要转到这个插件的文件夹。

所有插件的文件夹都可以在以下路径中找到:%FLUTTER_SDK_PATH%flutter.pub-cachehostedpub.dartlang.org

只需将%FLUTTER_SDK_PATH%替换为flutter SDK的实际路径。

现在,在这个文件夹中,我们可以找到image_picker文件夹。

第三:进入插件的文件夹后,您需要更改该插件正在使用的core.jar文件的版本,方法如下:

您导航到插件文件夹中的android文件夹并打开gradle.build文件,在我的情况下,这是路径:%FLUTTER_SDK_PATH%.pub-cachehostedpub.dartlang.orgimage_picker-0.7.4android

现在向下滚动,你会发现这个代码:

dependencies {
implementation 'androidx.core:core:1.1.0'
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.0'
}

implementation 'androidx.core:core:1.1.0'更改为implementation 'androidx.core:core:1.3.2':

dependencies {
implementation 'androidx.core:core:1.3.2'
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.0'
}

你完了。

请注意:

  • 我第一次尝试了上面提到的所有解决方案,最后一次尝试是编辑插件的文件。

  • 我所做的编辑没有以任何方式影响插件。

  • 我在上一步中使用的core.jar文件版本必须等于第一步中指定的core.jar版本。

谢谢,我希望你们编码无误。

相关内容

最新更新