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

Support for Gradle 8.3.0: Define namespace #100

Open
kay4ik opened this issue Mar 12, 2024 · 2 comments
Open

Support for Gradle 8.3.0: Define namespace #100

kay4ik opened this issue Mar 12, 2024 · 2 comments

Comments

@kay4ik
Copy link

kay4ik commented Mar 12, 2024

Hey,
when running an android build using the latest gradle version, following error occurs:

A problem occurred configuring project ':flutter_libserialport'.
> 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. 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.

To solve this problem following line needs to be defined (probably):
In android/src/build.gradle

android {
    namespace "org.sigrok.flutter_libserialport"
    compileSdk 29

    kotlinOptions {
        jvmTarget = '1.8'
    }
...

Also the min SDK version should be increased to 19 according to this warning:

C/C++: Platform version 16 is unsupported by this NDK, using 19 instead. Please change minSdk to at least 19 to avoid this warning.

This should be everything the console is asking for :)

Recommendation


I have avoided all warnings and errors by making following changes:

  • Increasing the kotlin version to 1.9.20
  • replacing jCentral() repository with mavenCentral() because it is already deprecated
  • adding the namespace
  • increasing the compileSdkVersion to 34
  • adding the jvmTarget of 1.8
  • increasing the minSdkVersion to 19

Now there are no warnings and errors anymore and the android/src/build.gradle is looking like that:

group 'org.sigrok.flutter_libserialport'
version '1.0-SNAPSHOT'

buildscript {
    ext.kotlin_version = '1.9.20'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    namespace "org.sigrok.flutter_libserialport"
    compileSdkVersion 34

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    defaultConfig {
        minSdkVersion 19
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    externalNativeBuild {
        cmake {
            path "libserialport/CMakeLists.txt"
        }
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
@djensen47
Copy link

Any chance we can get this in a 0.5.0 or even a 1.0 release?

@kay4ik I don't supposed you forked the fix anywhere?

@kay4ik
Copy link
Author

kay4ik commented Mar 29, 2024

@djensen47 No I didn't forked the solution, but I can do that next week and create a merge request. Maybe @jpnurmi can than accept this MR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants