androidfluttergradleandroid-gradle-plugingoogle-signin

Incompatible magic value 0 in class file when using google_sign_in 7.1.1 in Flutter project


I’m encountering a build error in my Flutter project when adding the google_sign_in package. Here are my environment details:

Flutter version: 3.32.8 Google Sign-In version: 7.1.1 JDK: 17.0.12 Android Gradle Plugin (AGP): 8.7.3 Gradle version: 8.12

I added the package in pubspec.yaml like this:

dependencies:
  google_sign_in: 7.1.1

And when I run flutter build apk, I get the following error:

Incompatible magic value 0 in class file build_87igo6xplmrbk3t4oofxxduai

What I have tried so far:

  1. flutter clean and flutter pub get

  2. Ensuring JAVA_HOME points to JDK 17


Solution

  • If cleaning the Flutter's cache didn't solve the problem, try clearing the cache for .gradle, if that doesn't work as well, I suggest re-downloading dependencies as well.

    cd android
    ./gradlew clean
    

    Also wipe Gradle’s global cache:

    rm -rf ~/.gradle/caches/
    

    To re-download Gradle:

    ./gradlew --refresh-dependencies