flutter_native_timezone icon indicating copy to clipboard operation
flutter_native_timezone copied to clipboard

Build Failure: Namespace Not Specified in flutter_native_timezone Module

Open essare opened this issue 1 year ago • 2 comments

Description

I'm encountering a build failure when attempting to build my Flutter Android project. The error message indicates that the flutter_native_timezone module is missing a namespace declaration in its build file. This issue seems to be related to recent updates to the Android Gradle Plugin (AGP) and the requirement for explicit namespace declarations. Error Log: FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong: A problem occurred configuring project ':flutter_native_timezone'.

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.
  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org. ==============================================================================

BUILD FAILED in 1s

Steps to Reproduce

Attempt to build the Android project. The build fails with the error messages shown above.

Expected Behavior The Android project should build successfully without any namespace-related errors.

Actual Behavior

The build fails with the following errors:

Namespace not specified. Specify a namespace in the module's build file. Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl. Failed to query the value of property 'buildFlowServiceProperty'.

Environment Flutter version: Flutter 3.27.4 • channel stable Dart version: Dart 3.6.2 Android Gradle Plugin version: 8.2.2 Gradle version: 8.5

Additional Information

The error specifically points to the :flutter_native_timezone module. The error message suggests using the AGP Upgrade Assistant to migrate the package attribute in AndroidManifest.xml to the namespace value in the build file.

Possible Solutions

Add a namespace declaration to the build.gradle file of the flutter_native_timezone module. Update the flutter_native_timezone plugin to a version that supports the latest AGP requirements.

essare avatar Feb 07 '25 17:02 essare

Hey @essare, this plugin hasn't seen any updates in over three years. Consider switching to flutter_timezone, which is my fork of this repo.

tjarvstrand avatar Mar 09 '25 12:03 tjarvstrand

Sadly lots of old and outdated packages will need an update in order to work properly. Adding namespace to build.gradle file fixes this issue, but old packages aren't maintained, and if an alternative is not created, it is on us to fork the package like @tjarvstrand did and maintain it ourselves. Thanks for sticking up to it and creating a fork @tjarvstrand , my project now builds after switching to flutter_timezone

berkaykurkcu avatar Mar 17 '25 13:03 berkaykurkcu