android - 无法解析 R [无 admob]
问题描述
我搜索了其他答案并试图找到解决方案,我知道这个问题已经被问到了。
突然我的 Android Studio 找不到 R 类(R.raw.blabla
)。找不到任何 R 文件
在其他课程中,它正在工作。
我尝试了什么:
- 清洁项目
- 手动导入 R
- 检查 Manifest/Gradle applicationId 中的正确包名称
- 从 Gradle 中清除 (
gradlew clean
) - 重建(Gradle 和从工具窗口)
- 使缓存无效并重新启动
- 重启操作系统
- 删除 .gradle 目录
- 与 AS 重新同步 Gradle 文件
- 运行代码分析并修复任何警告/错误
- 浏览整个 xml 文件并搜索错误/错别字
- 重新导入项目
- 更新 SDK 工具/重新下载
- 更新构建工具
- 更新依赖
- 删除 .idea 文件夹
- 制作项目,制作模块
- 重新安装 Android Studio
- 下载最新的 Android Studio(Canary 3.3 Canary 2018 年 9 月 15 日 11 日)
- 使用 Gradle 修复 lint 错误 (gradlew lintFix)
- 更新 Gradle 包装器
- 禁用 D8
- 启用 D8
- 集合
- cleanBuildCache
- 更新 Kotlin 版本
- 将 Kotlin 版本从 Dev (1.3-20M) 恢复到(到 1.2.70)
- 部分删除每个依赖项并重新添加它们
- 删除所有子项目构建文件夹,清理并重新构建
- 从 targetSDK/CompileSDK/BuildTools 28 恢复到 27
只有 2 个 xml 文件仍然有错误
-没有修改其他xml文件我的意思是默认值
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_constraint_layout">
<TextView
android:id="@+id/month_textView"
style="@style/textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Aug" />
<TextView
android:id="@+id/dayNr_textView"
style="@style/textStyle"
app:layout_constraintEnd_toEndOf="@+id/month_textView"
app:layout_constraintStart_toStartOf="@+id/month_textView"
app:layout_constraintTop_toBottomOf="@+id/month_textView"
tools:text="05" />
<TextView
android:id="@+id/day_textView"
style="@style/textStyle"
app:layout_constraintEnd_toEndOf="@+id/dayNr_textView"
app:layout_constraintStart_toStartOf="@+id/dayNr_textView"
app:layout_constraintTop_toBottomOf="@+id/dayNr_textView"
tools:text="Sun" />
</android.support.constraint.ConstraintLayout>
解决方案
其实我找到了一个奇怪的解决方案:
我尝试从 Canary(2018 年 9 月 5 日 3.11 日)在稳定/测试版 Android Studio(3.2)上导入项目在稳定/测试版通道上,R 类正在成功构建,我可以导入它。最后出于好奇,我在 Canary 版本中重新加载了项目。一切正常。但最后我决定留在稳定频道,等待 RC 版本。
推荐阅读
- javascript - 如何用图像填充多边形?
- php - 如何在 preg_match_all 中仅打印第 2 组的值,而不使用数组和循环
- react-native - 为什么自定义函数在屏幕渲染期间在 react-native-navigation 抽屉组件中自动执行
- html - Node.js/Express.js - 如何将远程 HTML 文件呈现给客户端?
- vhdl - 如何从用户 VHDL 获取多个输入
- c - 使用宏转换结构中整数字段的字节序
- operating-system - 我们是否可以在无限或荒谬的数量下获得 0 页面错误率?
- python - pandas 调整 Excel 表的大小以匹配较大的表以进行比较
- css - 向上滚动时奇怪的消失网站(仅在 Chrome 中)
- reactjs - 在初始页面加载后,是否可以将当前组件作为 React.Suspense 的“后备”内容安装?