首页 > 解决方案 > 无法解析 R [无 admob]

问题描述

我搜索了其他答案并试图找到解决方案,我知道这个问题已经被问到了。

突然我的 Android Studio 找不到 R 类(R.raw.blabla)。找不到任何 R 文件

在其他课程中,它正在工作。

我尝试了什么:

只有 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>

标签: androidandroid-studioandroid-gradle-pluginandroid-build

解决方案


其实我找到了一个奇怪的解决方案:

我尝试从 Canary(2018 年 9 月 5 日 3.11 日)在稳定/测试版 Android Studio(3.2)上导入项目在稳定/测试版通道上,R 类正在成功构建,我可以导入它。最后出于好奇,我在 Canary 版本中重新加载了项目。一切正常。但最后我决定留在稳定频道,等待 RC 版本。


推荐阅读