flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.14k stars 429 forks source link

"Unknown control: clipboard" on Android. #2900

Closed AyberkAtalay0 closed 1 month ago

AyberkAtalay0 commented 7 months ago

Description: I converted a code I copied from the website into an .apk file using the "flet build apk" command and transferred it to my phone. When I run the application, I see the error mentioned below. I can run the application on desktop.

Requirements:

flet==0.21.1

Operating systems: Process on Windows 11, test on Android 13

Code:

import flet as ft

async def main(page: ft.Page):
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.appbar = ft.AppBar(title=ft.Text("Audio Recorder"), center_title=True)

    path = "test-audio-file.wav"

    async def handle_start_recording(e):
        print(f"StartRecording: {path}")
        await audio_rec.start_recording_async(path)

    async def handle_stop_recording(e):
        output_path = await audio_rec.stop_recording_async()
        print(f"StopRecording: {output_path}")
        if page.web and output_path is not None:
            await page.launch_url_async(output_path)

    async def handle_list_devices(e):
        devices = await audio_rec.get_input_devices_async()
        print(devices)

    async def handle_has_permission(e):
        try:
            print(f"HasPermission: {await audio_rec.has_permission_async()}")
        except Exception as e:
            print(e)

    async def handle_pause(e):
        print(f"isRecording: {await audio_rec.is_recording_async()}")
        if await audio_rec.is_recording_async():
            await audio_rec.pause_recording_async()

    async def handle_resume(e):
        print(f"isPaused: {await audio_rec.is_paused_async()}")
        if await audio_rec.is_paused_async():
            await audio_rec.resume_recording_async()

    async def handle_audio_encoding_test(e):
        for i in list(ft.AudioEncoder):
            print(f"{i}: {await audio_rec.is_supported_encoder_async(i)}")

    async def handle_state_change(e):
        print(f"State Changed: {e.data}")

    audio_rec = ft.AudioRecorder(
        audio_encoder=ft.AudioEncoder.WAV,
        on_state_changed=handle_state_change,
    )
    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.ElevatedButton("List Devices", on_click=handle_list_devices),
        ft.ElevatedButton("Pause Recording", on_click=handle_pause),
        ft.ElevatedButton("Resume Recording", on_click=handle_resume),
        ft.ElevatedButton("Test AudioEncodings", on_click=handle_audio_encoding_test),
        ft.ElevatedButton("Has Permission", on_click=handle_has_permission),
    )

ft.app(target=main)

Results:

"Unknown control: clipboard"

error1

ndonkoHenri commented 7 months ago

Does this happen with a simple application too (Hello World) ? Or just with the above specific code..?

AyberkAtalay0 commented 7 months ago

Does this happen with a simple application too (Hello World) ? Or just with the above specific code..?

All applications give the same error with the "flet build apk" command.

zLEDT commented 6 months ago

Da el mismo error con un simple hello world

marwanazd commented 6 months ago

use ft.SafeArea() on page.add(ft.SafeArea(content=ft.Column(([,,,,,,]))

AyberkAtalay0 commented 6 months ago

use ft.SafeArea() on page.add(ft.SafeArea(content=ft.Column(([,,,,,,]))

Not working.

ndonkoHenri commented 6 months ago

I cannot reproduce this issue. In my video, you can see that the apk works as expected without showing that error message: https://www.youtube.com/watch?v=IcT_QrLWi10

I suggest you move to the latest Flet version and retry.

Jingyu-yummyFuture commented 4 months ago

I meet the same error when I run the command in macOS, switching the device to a linux environment fixed the issue, not sure whether this can help you!

ndonkoHenri commented 4 months ago

I marked this issue as bug, though i dont know where it might originate. Can you guys please also share the flet version with which you test?

Jingyu-yummyFuture commented 4 months ago

I was using flet version 0.19.0 and how I launch the app is by ft.app(name="", target=main, view=None, port=8509, host="0.0.0.0") I built and launched the app in a MacOS device then opened it as a web app from an Android device, and it showed the "Unknown control: clipboard" staff However it worked well under Linux

ndonkoHenri commented 1 month ago

Closing this issue in favor of https://github.com/flet-dev/flet/issues/3867

Please mention any further details in there.