Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jd-bus opened this issue Jun 9, 2024 · 4 comments
Open

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

jd-bus opened this issue Jun 9, 2024 · 4 comments
Assignees
Labels
Android next release Feature in development / Available in next release

Comments

@jd-bus
Copy link

jd-bus commented Jun 9, 2024

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
@asshyy-ktz
Copy link

asshyy-ktz commented Jul 23, 2024

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.

@nitinrgadhiya
Copy link

@jd-bus did you resolve this issue?

@cybex-dev
Copy link
Owner

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 cybex-dev self-assigned this Sep 3, 2024
@cybex-dev cybex-dev added next release Feature in development / Available in next release Android labels Sep 3, 2024
@chiragpatel92
Copy link

Any update on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android next release Feature in development / Available in next release
Projects
None yet
Development

No branches or pull requests

5 participants