java - 无法解析符号注释设计 ActivityCompat v7

标签 java android

我正在使用 Google API 开发面部识别应用程序。但 android studio 说找不到符号。

这是我的 Activity 。这四个都不起作用。

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(模块:应用程序)

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 中。

您正在使用compileSdkVersion 28

迁移步骤

  1. 将以下属性添加到 gradle.properties

    android.useAndroidX=true

    android.enableJetifier=true

  2. 从菜单栏:重构 > 迁移到 AndroidX...

Here是整个过程的引用。

关于java - 无法解析符号注释设计 ActivityCompat v7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58969585/

相关文章:

android - 如何将 GPS 系统服务放在本地服务中,以便关闭 GPS 时可以将其杀死

java - Feign中获取path变量

java - 如何查询 Appengine Logs API 以获取所有版本应用程序的日志?

Java 石头纸游戏循环次数过多

java - 仅当小数重复时才设置 BigDecimal 精度

android - 在 android studio 中创建新的资源目录时,什么是限定符?

Android Spinner setOnItemSelectedListener 不工作

android - Ruboto:不会检测到 Android SDK 平台工具

java - 从控制台启动的 Android 应用程序

java - JApplet Textfield/jbutton/嵌套循环程序,创建墙,在textfield中输入行数