Adding multiple flutter library modules fails build with duplicate class - flutter

Fail log
gw assembleDebug --scan
> Task :app:checkDebugDuplicateClasses FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class io.flutter.plugins.GeneratedPluginRegistrant found in modules flutter_debug-1.0-runtime (com.example.a.library_a:flutter_debug:1.0) and flutter_debug-2.0-runtime (com.example.b.library_b:flutter_debug:2.0)
Go to the documentation to learn how to Fix dependency resolution errors.
Steps to reproduce;
flutter create -t module --org com.example.a library_a
cd library_a
flutter pub add android_intent_plus
flutter build aar
cd ..
flutter create -t module --org com.example.b library_b
cd library_a
flutter pub add android_intent_plus
// Open pubspec.yaml and change android_intent_plus to 1.0.1
flutter build aar --build-number=2.0
Add both library_a and library_b to an android project. (I tested with a new project)
Build fails with duplicate class.
flutter doctor;
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.10, on macOS 12.5.1 21G83 darwin-arm, locale en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[!] Android Studio
✗ Unable to find bundled Java version.
[!] Android Studio
✗ Unable to find bundled Java version.
[!] Android Studio
✗ Unable to find bundled Java version.
[✓] Android Studio (version 2021.3)
[!] Android Studio
✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.3)
[✓] VS Code (version 1.74.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

Related

Gitlab Runner : The current Flutter SDK version is 0.0.0-unknown. - CI/CD

I am trying to execute a .gitlabci.yml file with Gitlab Runner.
But I am getting this error message.
No dependencies changed.
1 package is discontinued.
57 packages have newer versions incompatible with dependency constraints.
Try `dart pub outdated` for more information.
Running "flutter pub get" in tardis...
The current Flutter SDK version is 0.0.0-unknown.
Because newApp depends on workmanager >=0.2.3 which requires Flutter SDK version >=1.10.0, version solving failed.
In short gitlab runner cannot detect my flutter version.
My flutter doctor screen:
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19044.1766], locale tr-TR)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.1)
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.68.1)
[√] Connected device (3 available)
[√] HTTP Host Availability
• No issues found!
How can i fix this?
Solved this problem. Perhaps, the GitLab runner cannot detect my flutter version because of the flutter SDK location. I moved the SDK from drive D to drive C and specified the new environment variable path. It works fine now.

Flutter launcher icons fails because --sound-null-safety missing

I am trying to create icons for my app using flutter_launcher_icons, with options defined in pubspec.yaml. When I run flutter pub run flutter_launcher_icons:main, I get the following error:
Unable to spawn isolate: error: Library 'file:///Users/cameron/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.9.0/bin/main.dart' was compiled with sound null safety (in strong mode) and it requires --sound-null-safety option at runtime
pub finished with exit code 1
Even if I pass in --sound-null-safety, the error persists (I also tried '--no-sound-null-safety' which also did nothing).
To check it wasn't a configuration error, I ran flutter create <name>, added flutter_launcher_icons: to dev dependencies (and flutter pub get), ran the same command and got the same error.
I am on Flutter 2.2, and I depend on integration_test, so I can't downgrade to a pre-null-safety version of flutter_launcher_icons, because those versions have transitive dependencies that conflict with integration_test from sdk.
Flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.4)
[✓] VS Code (version 1.57.1)
[✓] Connected device (2 available)
• No issues found!

Exception: Profile mode is not supported for iPhone 11 Pro when profile flutter app

When I run app in profile mode in Android Studio 4.1.2:
show this error:
Exception: Profile mode is not supported for iPhone 11 Pro.
why would this happen and what should I do to fix it? This is my env:
~/source/dabai/microservice/soa-illidan-hub on  feature/cardrobot ⌚ 22:29:08
$ ~/apps/flutter/bin/flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[!] Android Studio (version 4.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Community Edition (version 2020.3.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.53.2)
[✓] Connected device (1 available)
! Error: xiaoqiang 的 iPhone is not connected. Xcode will continue when xiaoqiang 的 iPhone is connected. (code -13)
! Doctor found issues in 3 categories.
using command also failed:
~/Documents/GitHub/cruise-open on  feature/channel ⌚ 22:42:08
$ ~/apps/flutter/bin/flutter run --profile
Profile mode is not supported by sdk gphone x86 arm.
If this issue occurs both on Simulator and physical device, it's possible that timeouts in the Observatory port as mentioned on this thread. Try upgrading the Flutter version that you're using and see if it solves the issue. If it persists, run flutter run --profile --verbose to see more details on what's causing the issue.

Flutter Android build failed for task ':auto_orientation:verifyReleaseResources'

When I run the command flutter build apk --release then i face the following issue with auto_orientation.
In my pubspec.yaml file I have the latest version included auto_orientation: ^1.0.5.
Btw. when I run the project with flutter run everything works fine.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':auto_orientation:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/johannes/flutter_projects/udare/app/build/auto_orientation/intermediates/res/merged/release/values/values.xml:236: error: resource android:attr/fontVariationSettings not found.
/Users/johannes/flutter_projects/udare/app/build/auto_orientation/intermediates/res/merged/release/values/values.xml:237: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Flutter doctor:
[✓] Flutter (Channel master, v1.12.15-pre.29, on Mac OS X 10.14.6 18G95, locale
en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.40.2)
[✓] Connected device (1 available)
• No issues found!
#GreenTigerEye, this could be due to AndroidX incompatibility. You could try directly using the source code of auto_orientation package or try few options mentioned here for a similar issue.

Flutter Hello world app can't start on Android Emulator x86_64

I am currently working on Xamarin Forms and want to try Flutter.
I created a Flutter project with Android Studio. But I can't run it.
I get this error on Android Emulator
Error launching the application on Android SDK built for x86 64.
flutter doctor looks fine.
some example app like Flutter Gallery can work but some can't.
The platform is Windows 10 64 bit.
Android Studio 3.2.1
Error Message is:
Launching lib\main.dart on Android SDK built for x86 64 in debug
mode... Initializing gradle... Resolving dependencies...
Gradle task 'assembleDebug'... Built
build\app\outputs\apk\debug\app-debug.apk. Installing
build\app\outputs\apk\app.apk... Error: ADB exited with exit code
1 adb: failed to install
C:\Users\xxx\source\flutter\flutter_app\build\app\outputs\apk\app.apk:
Error launching application on Android SDK built for x86 64.
C:\flutter>flutter doctor Doctor summary (to see all details, run
flutter doctor -v): [√] Flutter (Channel stable, v1.0.0, on
Microsoft Windows [Version 10.0.17134.472], locale zh-TW) [√]
Android toolchain - develop for Android devices (Android SDK
28.0.3) [√] Android Studio (version 3.2) [√] IntelliJ IDEA Community Edition (version 2018.3) [!] VS Code, 64-bit edition
(version 1.30.1) [!] Connected device
! No devices available
! Doctor found issues in 2 categories.
As you can see from those lines:
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
You are missing the plugin for flutter and dart.
Go to:
File -> Settings -> Plugins
and install Flutter
And check to see if dart was installed as well