twilio_voice icon indicating copy to clipboard operation
twilio_voice copied to clipboard

not compatible with latest android gradle plugin (>= 8.x.x)

Open jd-bus opened this issue 1 year ago • 4 comments

Issue Summary

1: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':twilio_voice'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
   > Namespace not specified. Specify a namespace in the module's build file: /Users/jd-bus/.pub-cache/hosted/pub.dev/twilio_voice-0.1.3/android/build.gradle. 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.

Steps to Reproduce

  1. Use gradle-8.8-all.zip or any gradle above 8.x.x In android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
  1. ./gradlew build

jd-bus avatar Jun 09 '24 19:06 jd-bus

After extensive configuration, I have successfully resolved the issue. Here are the steps taken:

1- Open the Android module in Android Studio. 2- Run the flutter clean command at the root level of your Flutter project. 3- Sync the Android project in Android Studio. 4- Modification in your project files: in-app level build.gradle

  • update compileSdk to 35

  • set targetSdkVersion to 35

  • set minSdkVersion to 26

  • set JavaVersion to 17 example: sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17

You can do these modifications directly in you app level build.gradle file and in flutter.groovy file as well.

5- Go to setting.gradle set following versions for gradle and kotlin

  • id "dev.flutter.flutter-plugin-loader" version "1.0.0"
  • id "com.android.application" version '8.5.1' apply false
  • id("org.jetbrains.kotlin.android") version "1.9.23" apply false

6- Got to gradle-wrapper.properties and update distributionUrl with distributionUrl=https://services.gradle.org/distributions/gradle-8.7-bin.zip

7- In module level build.gradle of twilio_voice

  • update compileSdk to 35 and add namespace = "com.twilio.twilio_voice"

  • update JavaVersion to 17 Example: compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 }

    kotlinOptions { jvmTarget = '17' }

  • update minSdkVersion to 26

  • Update kotlin version to example kotlin_version = '1.9.23'

  • update build tools to classpath 'com.android.tools.build:gradle:8.5.1'

8- Sync the project again. 9- Clean the project once more and run the build. Happy debugging! If you have any questions, feel free to ask.

Summary:

  • Add the namespace in the Gradle file of the library.
  • Upgrade the Gradle version and SDK level to the latest for both the library and your project.
  • Ensure the Gradle version, SDK levels, and Kotlin version are the same for both your project and the library.
  • Use Java 17 instead of Java 11 or 1.8.

asshyy-ktz avatar Jul 23 '24 07:07 asshyy-ktz

@jd-bus did you resolve this issue?

nitinrgadhiya avatar Aug 27 '24 17:08 nitinrgadhiya

Hi everyone,

I apologize for the delayed response.

I'll be upgrading this package this week to support AGP 8.

Many thanks to @asshyy-ktz for the assistance.

cybex-dev avatar Sep 03 '24 12:09 cybex-dev

Any update on this ?

chiragpatel92 avatar Nov 15 '24 09:11 chiragpatel92

Hi everyone,

Please see latest release on pub.dev 0.2.2 - Support for Flutter <4.0.0 with Gradle 8 support.

cybex-dev avatar Mar 26 '25 07:03 cybex-dev