NoClassDefFoundError: Failed resolution of: Landroid/support/v7/appcompat/R$styleable

前端 未结 5 748
谎友^
谎友^ 2020-12-03 16:57

Newbie trying to finish the My first App tutorial provided by Google. On the way to this fatal exception I did import a lot of random packages to get rid of \"cannot be reso

5条回答
  •  攒了一身酷
    2020-12-03 17:50

    In my case the issue occurred in Android Studio 4.0. I suppose there was something wrong with Gradle cache.

    Unfortunately, neither Invalidate Сaches / Restart, nor Build -> Clean Project & Build -> Rebuild Project didn't help me, so I had to take drastic measures.

    1. Close Android Studio.

    2. Open Terminal and navigate to your project's root directory.

    3. Delete all Gradle modules' build directories, so all modules will be recompiled soon.

      find . -wholename "*/build" -exec rm -rf {} \;
      

      But if you have a single module, then just:

      rm -rf app/build
      
    4. Purge Gradle cache. By default, it's located in your home directory.

      rm -rf ~/.gradle
      
    5. Open Android Studio again. It will start to build the project. It will take a long time, since we have just deleted the cache, but the issue should be resolved.

提交回复
热议问题