ably / ably-flutter

A wrapper around our Cocoa and Java client library SDKs, providing iOS and Android support for those using Flutter and Dart.
https://ably.com/download
Apache License 2.0
60 stars 16 forks source link

Android build fails with a fresh flutter app on both MacOS and Windows #547

Closed aliajami92 closed 1 month ago

aliajami92 commented 1 month ago

I created a new flutter app that was working well, as soon as I added ably_flutter: ^1.2.34 to my dependencies and tried to build again, I was getting this error.

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':ably_flutter'.
> com.android.builder.errors.EvalIssueException: defaultConfig contains custom BuildConfig fields, but the feature is disabled.
  To enable the feature, add the following to your module-level build.gradle:
  android.buildFeatures.buildConfig true

I tried to solve it as suggested in the error message in my project's app/build.gradle but that didn't work, I needed to add the buildConfig true to the build.gradle file of the library itself from Pub cache. Then I was getting another error for missing namespace in the build.gradle file.

BuildScriptTransformer.
[        ] Using default execution profile
[        ] Could not execute [class org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatHandler.buildFinished]    
[   +1 ms] FAILURE: Build failed with an exception.
[   +1 ms] * What went wrong:
[        ] A problem occurred configuring project ':ably_flutter'.
[        ] > 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.

Which I fixed by adding namespace 'io.ably.flutter.plugin'.

Now my build is working fine, but I tried with different projects on both Windows and Mac and was getting the same issues.

┆Issue is synchronized with this Jira Task by Unito

sacOO7 commented 1 month ago

@aliajami92 Correct me if I am wrong, from last statement, I take that your build is working fine and you are not facing any issues right?

aliajami92 commented 1 month ago

@aliajami92 Correct me if I am wrong, from last statement, I take that your build is working fine and you are not facing any issues right?

It is yes working fine now but after I edited the library files, I'm not sure if this is something that need to be addressed or am I missing a configuration somewhere.

sacOO7 commented 1 month ago

Yeah, we will check and get back to you on this 👍

Rajesh0078 commented 1 month ago

Still i am facing the same issue, can anyone solve this?

sacOO7 commented 1 month ago

@Rajesh0078 can you try the solution mentioned by user @aliajami92 in first comment

Rajesh0078 commented 1 month ago

not working

ttypic commented 1 month ago

Hey @aliajami92, @aliajami92,

Sorry for the delay. We released 1.2.35 with the fix for Flutter 3.24+