我正在使用google开发一个人脸识别应用程序。但是安卓工作室说没有找到符号。
这是我的活动。他们四个都不管用。
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(模块: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很陌生,也很困惑。我把这个项目打扫了好几次,并进行了几次重建。使缓存失效并多次重新启动。
发布于 2019-11-22 08:13:08
谢谢大家的回答。
事实证明,在项目设置期间,我使用“基本活动”作为快速安装的模板。但后来我意识到,在较新版本的AndroidX中的“基本活动”中,使用的是AndroidX而不是AndroidX库。我所有的代码都是基于遗留的android库。
在文件gradle.properties文件(位于项目的基本目录中,与gradlew相同)中,更改
android.useAndroidX=true
android.enableJetifier=true至
android.useAndroidX=false
android.enableJetifier=false如果您拥有所有依赖项,并多次重新构建和清除缓存,那么android支持库仍然无法工作。如果你有一个新版本的安卓工作室。gradle.properties可能是错的。
发布于 2019-11-21 07:41:47
是的,因为你必须将你的项目迁移到androidx中。
您正在使用compileSdkVersion 28
迁移步骤
gradle.properties
android.useAndroidX=true
android.enableJetifier=true1. From the menu bar: `Refactor > Migrate to AndroidX…`
这里是整个过程的参考。
发布于 2019-11-21 08:30:42
您需要将项目迁移到androidx。
Refactor > Migrate to Androidx另一件要记住的事情是检查所有的包在gradle中是正确的。用于androidx的Snackbar包是:
com.google.android.material.snackbar.Snackbar用于仙女座伪影的测绘。下面看一下Android:https://developer.android.com/jetpack/androidx/migrate/artifact-mappings
样本:伪影映射样本
https://stackoverflow.com/questions/58969585
复制相似问题