首页 > 解决方案 > 错误:包 android.support.annotation。不存在

问题描述

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

在此处输入图像描述

在此处输入图像描述

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

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

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

但是不行,请给我一个解决方案,谢谢

[3]: https://i.stack.imgur.com/6nQA5.jpg ![在此输入图片描述]( https://i.stack.imgur.com/Z6NvH.jpg )

标签: javaandroidandroid-studioandroid-support-libraryandroidx

解决方案


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

// 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()
    }
}

推荐阅读