Search code examples
androidandroid-studioandroid-gradle-pluginandroid-build

Cannot Resolve R [No admob]


I searched other answers and I tried to find a solution, I know that This questions has been asked.

Suddenly my Android Studio cannot find R class (R.raw.blabla). Cannot find any R file

In other classes it's working.

What i tried :

  • Clean Project
  • Import manually R
  • Check Correct Package name in Manifest/Gradle applicationId
  • Clean from Gradle ( gradlew clean)
  • Rebuild (Gradle and from Tool window)
  • Invalidate Caches and Restart
  • Restart OS
  • Delete .gradle directory
  • Resync Gradle files with AS
  • Run Code Analysis and fix Any warnings/Errors
  • Go through whole xml files and search for bugs/typos
  • Re-import project
  • Update SDK tools/re-download
  • Update Build Tools
  • Update Dependencies
  • Delete .idea folder
  • Make Project, Make Module
  • Re install Android Studio
  • Download Latest Android Studio (Canary 3.3 Canary 11 Sept 15 2018)
  • Fix lint errors with Gradle (gradlew lintFix)
  • update Gradle wrapper
  • disable D8
  • enable D8
  • assemble
  • cleanBuildCache
  • Update Kotlin Version
  • Revert Kotlin Version from Dev (1.3-20M) to (to 1.2.70)
  • Partially remove every dependency and re add them one by one
  • Delete all sub project build folder, clean and re build
  • Revert From targetSDK/CompileSDK/BuildTools 28 to 27

Just 2 xml files still got error

-No other xml files modified i mean default values

<?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>

Solution

  • Actually i found a weird solution:

    I tried to import project on a stable/beta Android Studio (3.2) from Canary (3.11 Sept 05 2018) On the stable/beta channel the R class is building successfully and i could import it. Finally as curiosity i reloaded the project in the Canary version. And all was working. But in the end i decided to remain on stable channel, and wait for RC releases.