android - 无法解析 Android 3.6.1 中的符号内容
问题描述
我在这里搜索了许多与此问题相关的帖子,但没有找到任何解决我的问题的方法。这就是我在这里的原因。
我最近更新到 Android Studio 3.6.1 并提出了“无法解析符号内容”的问题
我的导入库如下:
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
以上导入库在 Android 3.6.1 中不起作用。如何解决这个问题?请建议
注意:-我已经尝试了与这篇文章相关的几个答案,但仍未解决。
我已经删除了 Build/ .Gradle 和 .idea 并重建了项目,但无法正常工作。我还尝试了这个问题的另一种解决方案,如下所示。
- 关闭当前项目
- 通过 X 符号删除所有项目
- 关闭Andoid工作室
- 通过打开现有项目再次重新启动项目
但所有的努力都失败了。为我提供正确的解决方案。
我的 build.gradle 文件如下。
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.maheshwaghela.mahesh.rukhivivah"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.browser:browser:1.0.0'
}
解决方案
由于您已迁移到 androidx 并且这些导入是针对旧支持库的,因此您应该改用较新的支持库。删除这些:
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
试试这些是否能解决您的问题。
有关从旧支持库包到新 androidx 包的当前映射的更完整列表,您可以参考官方文档。
推荐阅读
- python - 如何向输入搜索引擎添加容差
- c# - Razor,而不是 MVC:如何在按钮单击时调用页面模型方法来更新数据库
- reactjs - TypeError:无法读取反应错误中未定义的属性“拆分”
- python - plotly express 情节已经褪色
- xml - 在 intellij 中的 maven 目标之后,Testng 文件同步回以前的版本问题
- python - 获取关键输入的最佳方法是什么?
- date - 如何使用 Chrono crate 在 Rust 中获取当前工作日?
- docker - Katacode Traefik 教程错误 - 未创建容器
- python - 如何在 Python FastAPI 中运行并发请求?
- node.js - 如何编写大小未知的 tar 流条目?