Skip to content

Add conditional namespace to support gradle 8#65

Open
egonm12 wants to merge 2 commits intoByneappLLC:masterfrom
egonm12:master
Open

Add conditional namespace to support gradle 8#65
egonm12 wants to merge 2 commits intoByneappLLC:masterfrom
egonm12:master

Conversation

@egonm12
Copy link

@egonm12 egonm12 commented Jan 25, 2024

A breaking change was introduced in gradle 8. You must set the namespace in the module-level build.gradle.kts file, rather than the manifest file. More info: https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes#namespace-dsl

Setting it conditionally for backwards compatibility: flutter/flutter#125621

@kevtechi
Copy link

kevtechi commented Feb 9, 2024

Thanks for the PR, this saved me a lot of time. Hopefully the repo maintainer can merge this.

In the mean time, install like this in your pubspec:

flutter_config:
    git:
      url: https://github.com/egonm12/flutter_config.git
      ref: 90bbf3c

@kevinetore
Copy link

@edTheGuy00 Could we merge this?

@egonm12
Copy link
Author

egonm12 commented Apr 4, 2024

@kev-techi @kevinetore I recommend changing to --dart-define or --dart-define-from-file. The owner of this package doesn't provide any updates.

Be aware of the problems with --dart-define-from-file in native code from Flutter 3.19+. See this workaround if you decide to take this path.

@kevtechi
Copy link

kevtechi commented Apr 4, 2024

I would actually recommend not using this approach at all actually and just going with the standard way of defining env variables for each platform:

  • .plist for iOS
  • .whatever for Android

This is the type of dependency which can stop you from being able to build your app if you open up the project 6 months later after an XCode or iOS update.

@egonm12
Copy link
Author

egonm12 commented Apr 4, 2024

@kev-techi The downside is that you don't have a single source of truth for your environment variable value (in case Android and iOS variable values are the same). With the provided workaround this still works, you have to point your .plist key to the variable generated by Flutter. The same works for Android.

SomeGeneratedFile.xcconfig

FOO=BAR

Info.plist

<key>SomeKey</key>
<string>$(FOO)</string>

@kevtechi
Copy link

kevtechi commented Apr 4, 2024

I would say that the amount of time wasted with extra packages like this one is not worth it. Especially when they introduce bugs and random dependencies that have nothing to do with the core of your project.

Easier to just use native configuration files where needed. Locally you do it once and in your CI/CD, it's easy to set up.

But it's just a personal preferences. 🤷 , do whatever works best for your scenario.

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

Successfully merging this pull request may close these issues.

3 participants