Android Studio can't find library classes after Gradle build

前端 未结 5 1656
野性不改
野性不改 2021-01-03 19:30

I\'m trying to add a .jar library to my project into the /libs folder. Here is my grade.build:

    buildscript {
              


        
5条回答
  •  感动是毒
    2021-01-03 20:21

    I had a similar situation where Android Studio couldn't find a library that definitely existed. Even though I was able to compile my project in Android Studio, run it from Android Studio in the emulator or on a physical device, and build it from the command line using gradlew, the Android Studio IDE complained Cannot resolve symbol 'ConstraintLayout'. I believe I had imported the library correctly because I followed Google's instructions: https://developer.android.com/training/constraint-layout/#add-constraintlayout-to-your-project.

    Anyway, I ended up solving the problem as follows:

    1. Close Android Studio
    2. Delete the .idea folder in the project's directory
    3. Open Android Studio
    4. Re-import the project so Android Studio can regenerate the .idea folder

    This in-fact solved the problem. I believe Android Studio somehow corrupted the .idea folder when I had done "Android Studio" > "Check for Updates" earlier in the day.

提交回复
热议问题