Fixing sign_in_with_apple-5.0.0/android/build.gradle' line: 27 > No signature of method: build_64irqtdfzeigcmyeqnd8owt8u.android() is applicable for argument types

This morning I upgraded my packages and my Android build started failing. Here's the error:

sign_in_with_apple-5.0.0/android/build.gradle' line: 27

* What went wrong:
A problem occurred evaluating project ':sign_in_with_apple'.
> No signature of method: build_64irqtdfzeigcmyeqnd8owt8u.android() is applicable for argument types: (build_64irqtdfzeigcmyeqnd8owt8u$_run_closure2) values: [build_64irqtdfzeigcmyeqnd8owt8u$_run_closure2@230b5009]

Googling it does not give any meaningful result but looking at the Issues on the GitHub project does: https://github.com/aboutyou/dart_packages/issues/378.

Apparently I have to upgrade Gradle. Here we go again. I am currently using:

  • android/build.gradle: classpath 'com.android.tools.build:gradle:4.1.0'
  • android/gradle/wrapper/gradle-wrapper.properties: distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip

The post suggests 'com.android.tools.build:gradle:7.3.0' and gradle-7.5-all.zip. Let's see what's around:

Android Gradle plugin release notes | Android Studio | Android Developers
The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android apps.
Plugin versionMinimum required Gradle version
8.38.4
8.28.2
8.18.0
8.08.0
7.47.5

Let's use the latest to be done with it for a while. Also looking at https://services.gradle.org/distributions/ I can see that the file name is gradle-8.4-bin.zip.

I used:

  • android/build.gradle: classpath 'com.android.tools.build:gradle:8.3.0'
  • android/gradle/wrapper/gradle-wrapper.properties: distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip

But I get this error:

> Could not resolve all files for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:8.3.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.3.0/gradle-8.3.0.pom
       - https://jcenter.bintray.com/com/android/tools/build/gradle/8.3.0/gradle-8.3.0.pom
     Required by:
         project :

Is 8.3.0 not available? Looking at https://mvnrepository.com/artifact/com.android.tools.build/gradle, it looks like 8.3 is only available in beta. Not sure if it's an official source but still, the error makes sense. The Android Developers page mentions version 8.2.0. So I switched to gradle:8.2.0 and now I am getting this error:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/anhtuan/git/flashcards/android/app/build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
      Your current JDK is located in /Applications/Android Studio.app/Contents/jre/Contents/Home
      You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

Looking at https://developer.android.com/build/jdks and my settings in Android Studio, I don't see a way to set it up. Let's update Android Studio and see if it ships with a newer version of JRE. Here's what the Android Studio update popup states:

After the update, I run the compilation again. It seems to have fixed it and now I am getting the next error:

Building and deploying Android build


FAILURE: Build failed with an exception.

* Where:
Build file '/Users/anhtuan/git/flashcards/android/build.gradle' line: 27

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not create an instance of type com.android.build.api.variant.impl.ApplicationVariantImpl.
      > Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

        If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

Looks like there are two ways to do it. Set the namespace manually. Seems like an easy fix. Or use a tool to automatically upgrade things for me. The latter seems like a better way in the long-term.

But it's getting late. I'll continue later.