Android Studio inline compiler showing red errors, but compilation with gradle works fine

后端 未结 27 973
[愿得一人]
[愿得一人] 2020-11-29 19:22

I\'ve set up my project in Android Studio to use the Square Wire library, as per this question.

Build -> Compile Project works fine.

<
相关标签:
27条回答
  • 2020-11-29 19:46

    I was still having the same problem with Android Studio v3.2.1 constantly, and sorted out the problem just removing these two sub-folders of the .idea folder (no need to delete the whole .idea folder) while a gradle sync didn't work:

    • ./idea/caches
    • ./idea/libraries
    0 讨论(0)
  • 2020-11-29 19:46

    if File -> Invalidate caches/Restart -> Invalidate and Restart is Not Working then follow few step.

    1.) Close Your Android Studio

    2.) Then Delete Manual on C:\Users\Balbir\ .AndroidStudio4.0\system\caches Folder.

    3.) Start Android Studio

    It is Work For Me.

    0 讨论(0)
  • 2020-11-29 19:48

    If all above answers don't work for you. Just try update your dependencies to latest version. It worked for me.

    0 讨论(0)
  • 2020-11-29 19:48

    I got the same issue cleared using the following steps:

    1. update the library version in gradle to any random number, eg: lib_1.0.0 -> lib_1.0.0.0

    2. gradle sync

    3. sync shows error

    4. revert the version change lib_1.0.0.0 -> lib_1.0.0

    5. gradle sync

    Open the java file with imports to see the error cleared.

    0 讨论(0)
  • 2020-11-29 19:51

    I had this problem after upgrading to Android Studio 3.1. I solved the issue by upgrading all the components I use. So I changed the following entries in my build.gradle (app):

    1. Upgrade SDK (from "compileSdkVersion 25" to "compileSdkVersion 26" or maybe higher when you read this note):

      //compileSdkVersion 25

      compileSdkVersion 26

      Comment: This change forced program to download/install new sdk during next sync.

    2. Upgrade appcompat-v7:

      //implementation 'com.android.support:appcompat-v7:25.4.0'

      implementation 'com.android.support:appcompat-v7:26.1.0'

    3. Upgrade firebase:

      //implementation 'com.google.firebase:firebase-ads:11.4.2'

      implementation 'com.google.firebase:firebase-core:12.0.1'

      implementation 'com.google.firebase:firebase-ads:12.0.1'

    4. In PROJECT build.gradle, upgrade google-services:

      //classpath 'com.google.gms:google-services:3.1.0'

      classpath 'com.google.gms:google-services:3.2.0'

    5. Upgrade gradle (from 4.4 to 4.6). From gradle-wrapper.properties: distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip

    After these changes, clean project, invalidate cache/restart, remove .idea/libraries content and resync (not sure about the order but ALL these activities solved the issue for me).

    0 讨论(0)
  • 2020-11-29 19:53

    Deleting libraries folder in .idea solved the issue for me. It is located in project's root/.idea/libraries.

    I'm using Android Studio 3.1.4

    0 讨论(0)
提交回复
热议问题