【问题标题】:Error : package android.support.annotation. does not exist错误:包 android.support.annotation。不存在
【发布时间】:2020-11-24 15:23:28
【问题描述】:

我会运行程序,但是出现如下所示的错误

[![在此处输入图片描述][3]][3]

我尝试: 实现 'androidx.annotation:annotation:1.0.2'

实现“com.android.support:support-annotations:28.0.0”

但不工作 请给我一个解决方案,谢谢????

[3]:https://i.stack.imgur.com/6nQA5.jpg![enter此处的图片描述](https://i.stack.imgur.com/Z6NvH.jpg)

【问题讨论】:

  • 您是否在顶级 Gradle 文件中添加了 google()? allprojects { repositories { google() } }
  • 谷歌()?在哪里?,我已经编辑并添加了顶级 gradle 图像
  • 我已经添加了 google()
  • 现在可以了吗?
  • 不一样

标签: java android android-studio android-support-library androidx


【解决方案1】:

Android 支持库可从 Google 的 Maven 存储库获得。 根据documentation,要将这些库之一添加到您的构建中,请将 Google 的 Maven 存储库包含在您的顶级 build.gradle 文件中:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        // add related repo
    }
    dependencies {
        // add classpath files here
    }
}

allprojects {
    repositories {
        // add it here ...
        google()
    }
}

【讨论】:

  • 我已经像上面的照片链接一样添加了它。但仍然是一个错误。同时使用Android和Androidx会报错吗?
猜你喜欢
  • 2020-03-13
  • 2016-08-22
  • 1970-01-01
  • 2020-05-05
  • 1970-01-01
  • 2019-03-24
  • 1970-01-01
  • 2019-12-12
  • 1970-01-01
相关资源
最近更新 更多