java - 无法解决符号标注设计ActivityCompat v7
问题描述
我正在使用谷歌 API 开发人脸识别应用程序。但是 android studio 说找不到符号。
这是我的活动。这四个都不行。
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
我的 build.gradle(module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "ece.course.myapplication"
minSdkVersion 19
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion "28.0.3"
productFlavors{
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.android.support:design:28.0.0'
//implementation 'com.android.support:support-annotations:28.0.0'
//compile 'com.android.support:support-v4:24.2.0'
//compile 'com.android.support:design:24.2.0'
//compile 'com.google.android.gms:play-services-vision:9.4.0+'
}
我的 build.gradle(项目)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
//classpath 'com.android.tools.build:gradle:2.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我是android新手,很困惑。我清理了项目并重建了几次。使缓存无效并重新启动几次。
解决方案
您需要将您的项目迁移到 androidx
Refactor > Migrate to Androidx
要记住的另一件事是检查你所有的包在 gradle 中是否正确。用于 androidx 的 Snackbar 包是:
com.google.android.material.snackbar.Snackbar
在这里回答: AndroidX 中的 Snackbar 包
用于 Androidx 工件映射。在此处查看 Android 开发人员 API: https ://developer.android.com/jetpack/androidx/migrate/artifact-mappings
示例: 工件映射示例
推荐阅读
- javascript - JavaScript - FOR 循环内的 IF 语句正在输出两个选项
- javascript - 包含数组的对象 - 是否有更简单的方法来编写这种常见模式
- javascript - 如何隐藏视差溢出?
- python-3.x - 无法使用漂亮的汤刮掉所有数据
- typescript - 在自定义声明的变量上使用 @types
- excel - CSV 到 Excel 与数据透视表
- java - 在编写 mapreduce 类时
- c# - 如何将属性或描述符(例如字符串和 int/doubles)分配给对象或项?
- spring - Spring和Hibernate依赖不兼容
- sql - Postgres:查找数据丢失的时间范围