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

后端 未结 27 972
[愿得一人]
[愿得一人] 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:57

    I had a similar issue before, invalidating cache and restarting didn't resolve it. I just did a Gradle Sync and everything worked fine.

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

    All the answers above didn't work for me. My problem was that i had 3 modules, with 2 of them with the same package name.

    It was ok for android studio <= 3.2.1.

    For android studio > 3.2.1, ressouce was red.

    I solved it like this mention here (i just made differents packages name for each modules ) : Any android Studio version > 3.2.1 show red resource but still compile

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

    My hacky fix for this -

    1. Open your build.gradle file
    2. Cut out everything inside dependencies{}
    3. Paste in notepad for super safe temporary keeping
    4. Choose 'Sync Now' in the build.gradle file
    5. Wait for Sync to fail
    6. Paste your dependencies back in
    7. 'Sync Now' again

    Tried a lot of solutions and this was the only fix for me.

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

    I tried most of the fixes above and what actually worked was deleting all the .AndroidStudio config folders and then restarting Android Studio.

    • Location: C:\Users\your.username
    0 讨论(0)
  • 2020-11-29 20:00

    These solutions didn't help me with the same problem in Android Studio 0.5.8.

    I described my answer to the same question (I guess): https://stackoverflow.com/a/23891829/534698 I just deleted ~/.AndroidStudioPreview directory (in Ubuntu). I missed all my Android Studio settings but it works.

    0 讨论(0)
  • 2020-11-29 20:01

    I found easy way

    • Open app level build.gradle
    • Remove dependency which is showing error & Sync.
    • Again add dependency & Sync.

    Error Gone!

    Before

    After

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