flet build apk --include-packages flet_audio_recorder is FAILED #2846
-
QuestionI used flet build apk --include-packages flet_audio_recorder to package the apk, but it failed. My environment is as follows: Code sampleimport flet as ft
async def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.appbar = ft.AppBar(title=ft.Text("Audio Recorder test"), center_title=True)
path = "test-audio-file.wav"
#path="./"
async def handle_start_recording(e):
await audio_rec.start_recording_async(path)
async def handle_stop_recording(e):
output_path = await audio_rec.stop_recording_async()
if page.web and output_path is not None:
await page.launch_url_async(output_path)
audio_rec = ft.AudioRecorder(
audio_encoder=ft.AudioEncoder.WAV,
)
page.overlay.append(audio_rec)
await page.update_async()
await page.add_async(
ft.ElevatedButton("Start Audio Recorder", on_click=handle_start_recording),
ft.ElevatedButton("Stop Audio Recorder", on_click=handle_stop_recording),
)
ft.app(target=main) Error messageCreating Flutter bootstrap project...OK
Customizing app icons and splash images...OK
Generating app icons...OK
Generating splash screens...OK
Packaging Python app...OK
Building .apk for Android...Resolving dependencies...
fl_chart 0.65.0 (0.66.2 available)
flutter_lints 2.0.3 (3.0.1 available)
flutter_native_splash 2.3.7 (2.3.13 available)
js 0.6.7 (0.7.1 available)
leak_tracker 10.0.0 (10.0.4 available)
leak_tracker_flutter_testing 2.0.1 (3.0.3 available)
leak_tracker_testing 2.0.1 (3.0.1 available)
lints 2.1.1 (3.0.0 available)
meta 1.11.0 (1.12.0 available)
package_info_plus 4.2.0 (5.0.1 available)
petitparser 5.4.0 (6.0.2 available)
test_api 0.6.1 (0.7.0 available)
toml 0.14.0 (0.15.0 available)
vm_service 13.0.0 (14.1.0 available)
xml 6.3.0 (6.5.0 available)
Got dependencies!
15 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Running Gradle task 'assembleRelease'...
Font asset "CupertinoIcons.ttf" was tree-shaken, reducing it from 283452 to 212680 bytes (25.0% reduction). Tree-shaking
can be disabled by providing the --no-tree-shake-icons flag when building your app.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1261080 bytes (23.3% reduction).
Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Running Gradle task 'assembleRelease'... 91.1s
┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────┐
│ The plugin record_android requires a higher Android SDK version. │
│ Fix this issue by adding the following to the file │
│ C:\Users\jkloi\AppData\Local\Temp\flet_flutter_build_WQzWPfgfkz\android\app\build.gradle: │
│ android { │
│ defaultConfig { │
│ minSdkVersion 21 │
│ } │
│ } │
│ │
│ Following this change, your app will not be available to users running Android SDKs below 21. │
│ Consider searching for a version of this plugin that supports these lower versions of the │
│ Android SDK instead. │
│ For more information, see: │
│ https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration │
└───────────────────────────────────────────────────────────────────────────────────────────────┘
C:\Users\jkloi\AppData\Local\Android\sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe:
error:
'C:\Users\jkloi\AppData\Local\Temp\flet_flutter_build_WQzWPfgfkz\build\serious_python_android\intermediates\merged_nativ
e_libs\release\out\lib\armeabi-v7a\libpythonbundle.so': The file was not recognized as a valid object file
C:\Users\jkloi\AppData\Local\Android\sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe:
error:
'C:\Users\jkloi\AppData\Local\Temp\flet_flutter_build_WQzWPfgfkz\build\serious_python_android\intermediates\merged_nativ
e_libs\release\out\lib\arm64-v8a\libpythonbundle.so': The file was not recognized as a valid object file
C:\Users\jkloi\AppData\Local\Android\sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-strip.exe:
error:
'C:\Users\jkloi\AppData\Local\Temp\flet_flutter_build_WQzWPfgfkz\build\serious_python_android\intermediates\merged_nativ
e_libs\release\out\lib\x86_64\libpythonbundle.so': The file was not recognized as a valid object file
C:\Users\jkloi\AppData\Local\Temp\flet_flutter_build_WQzWPfgfkz\android\app\src\main\AndroidManifest.xml Error:
uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [:record_android]
C:\Users\jkloi\AppData\Local\Temp\flet_flutter_build_WQzWPfgfkz\build\record_android\intermediates\merged_manifest\relea
se\AndroidManifest.xml as the library might be using APIs not available in 19
Suggestion: use a compatible library with a minSdk of at most 19,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.llfbandit.record" to force usage (may lead to runtime failures)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library
[:record_android]
C:\Users\jkloi\AppData\Local\Temp\flet_flutter_build_WQzWPfgfkz\build\record_android\intermediates\merged_manifest\relea
se\AndroidManifest.xml as the library might be using APIs not available in 19
Suggestion: use a compatible library with a minSdk of at most 19,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.llfbandit.record" to force usage (may lead to runtime failures)
* 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 1m 30s
Gradle task assembleRelease failed with exit code 1
Error building Flet app - see the log of failed command above. ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
already written line by line what you need to do. The solution to the problem is already in front of you. |
Beta Was this translation helpful? Give feedback.
-
Sorry for the issue. ┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────┐
│ The plugin record_android requires a higher Android SDK version. │
│ Fix this issue by adding the following to the file │
│ C:\Users\jkloi\AppData\Local\Temp\flet_flutter_build_WQzWPfgfkz\android\app\build.gradle: │
│ android { │
│ defaultConfig { │
│ minSdkVersion 21 │
│ } │
│ }
Try this: find the gradle file mentioned here, then modify the value of You feedback on this will be helpful... |
Beta Was this translation helpful? Give feedback.
-
This issue has been fixed. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answers. After testing, the program can be successfully packaged in apk format. After being installed on Android, recording and playback can be performed. Thanks again for your assistance. |
Beta Was this translation helpful? Give feedback.
This issue has been fixed.