I'm working on an Android app with 3+ years of Kotlin development and want to gradually migrate it to Flutter feature-by-feature. I use option B of the "add 2 app" integration where I depend on the module's source code. Features written Flutter are integrated into the native Android app with FlutterActivity
or FlutterFragment
. This worked great for the first feature however now I have an issue with migrating the second feature. The second feature requires the packages camera
and firebase_ml_vision
. Now the problem is that camera
requires a min SDK of 21 but the generated Android code in .android
sets the min SDK to 16. Additionally firebase_ml_vision
requires initialization of Firebase which also needs to be added to .android
. I'm thinking about adding .android
to VCS and add the required changes however this is generated code. It gets removed when flutter clean
is called and generated on flutter pub get
. I would have to constantly adjust the generated code when Flutter changes/removes it :( .android
only hosts the "skeleton" Android app which is started when the Flutter project is run from IDE (or command line). It is not the host app (the old, native app) where Firebase is already configured. However the .android
app is used for quick development cycles. If I cannot use this anymore because of said limitations, I would always have to start the native Android app (host) and lose many benefits of Flutter like hot reload :( Has anyone come across the same problem?
Update:
In this article they clearly state that .android
should not be modified or added to VCS. They even mention the camera
module as an example. However this does not work and can be reproduced with a few simple steps:
- Create a new module:
flutter create --template=module --project-name example
cd example
- Add
camera
plugin topubspec.yaml
flutter pub get
- Now running
flutter build apk
results in the following error:
/Users/sven/Development/example/.android/app/src/main/AndroidManifest.xml Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:camera] /Users/sven/.pub-cache/hosted/pub.dartlang.org/camera-0.5.8+11/android/build/intermediates/library_manifest/release/AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="io.flutter.plugins.camera" to force usage (may lead to runtime failures)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:camera] /Users/sven/.pub-cache/hosted/pub.dartlang.org/camera-0.5.8+11/android/build/intermediates/library_manifest/release/AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="io.flutter.plugins.camera" to force usage (may lead to runtime failures)
from Flutter "Add 2 App" Android integration with adjustments to generated .android
No comments:
Post a Comment