1

I migrated to AndroidX via Refactor - Migrate to AndroidX

Now Android Studio highlights most attributes in the layouts files as Unknown

I abbreviated the code below to show only some of the unknown attributes

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:fitsSystemWindows="true" (Unknown)
    android:clipToPadding="true" (Unknown)
    android:scrollbars="none" (Unknown)

<LinearLayout
    android:paddingTop="20dp" (Unknown)
    android:paddingBottom="20dp" (Unknown)

    <TextView
        android:layout_marginTop="20dp" (Unknown)
        android:paddingStart="20dp" (Unknown)
        android:paddingEnd="20dp" (Unknown)
        android:text="Some Text" (Unknown)

In gradle.properties I have

android.enableJetifier=true
android.useAndroidX=true

In build.gradle

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'
    defaultConfig {

        minSdkVersion 21
        targetSdkVersion 29

I tried

  • Sync Project with Gradle files
  • I synced build.gradle
  • Invalidate Cach / Restart
  • Clean Project followed by Rebuild Project
  • I deleted .idea folder followed by Clean & Rebuild project

Nothing worked

Ashraf Alshahawy
  • 1,073
  • 1
  • 13
  • 36
  • sometimes it can be bug of android studio; does your app compile and run ? – Zain Jan 29 '20 at 23:19
  • Yes! It compiles and runs normally in debug mode and it generated an apk. – Ashraf Alshahawy Jan 29 '20 at 23:25
  • @Zain The main issue for me that it doesn't provide intellisense when I'm creating a tag. If I write android: it doesn't offer the attributes. – Ashraf Alshahawy Jan 29 '20 at 23:28
  • Try to close and then reimport the project rather than just invalidate and restart, instead of reopening it from the `File -> Open Recent`, click `File -> Open` and then import the project again. A lot of times that works for me. – omz1990 Jan 29 '20 at 23:38

2 Answers2

1

Please try to clean below cache folders to give a change to re-download libraries

c:\Users\<user>\.gradle\caches\
c:\Users\<user>\.AndroidStudio3.x\system\caches\

Sources: 1, 2

Zain
  • 13,030
  • 5
  • 26
  • 49
0

Had the same problem some days back; Cleaning the C:\Users.AndroidStudio3.2\system\caches also did not worke for me. Fixed it with completly reinstalling Android Studio.

AnonRocketman
  • 126
  • 1
  • 14