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

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

提交回复
热议问题