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.07k stars 427 forks source link

Coudn't create APK file #2516

Closed bambier closed 1 month ago

bambier commented 8 months ago

Description

I tried to create apk file as it described in docs. I created this tool for p4a to simplify bash command execution, which reads data from this yaml file.

So I run these commands in terminal

And Ka-Boom! It runs in to error

Code example to reproduce the issue: https://github.com/bambier/ffdroid

Describe the results you received: APK didn't created after running flet build apk

(env) ➜  ffdroid git:(main) flet build apk src 
Creating 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...
  ffi 2.1.0 (2.1.2 available)
  fl_chart 0.65.0 (0.66.1 available)
  flutter_lints 2.0.3 (3.0.1 available)
  flutter_native_splash 2.3.7 (2.3.10 available)
  js 0.6.7 (0.7.0 available)
  lints 2.1.1 (3.0.0 available)
  matcher 0.12.16 (0.12.16+1 available)
  material_color_utilities 0.5.0 (0.8.0 available)
  meta 1.10.0 (1.11.0 available)
  package_info_plus 4.2.0 (5.0.1 available)
  path 1.8.3 (1.9.0 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)
  web 0.3.0 (0.4.2 available)
  web_socket_channel 2.4.0 (2.4.3 available)
  xml 6.3.0 (6.5.0 available)
Got dependencies!
17 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

Running Gradle task 'assembleRelease'...                        
Copying P4A libraries from /home/nima/.local/share/python-for-android/dists/mydist
Bundling arm64-v8a
Bundling armeabi-v7a
Bundling armeabi-v7a
Copying all .so files to /home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/android/src/main/jniLibs
Running Gradle task 'assembleRelease'...                            4.6s

bundle.sh: 17: pushd: not found
mv: cannot move 'libpythonbundle.so' to '../../libs/arm64-v8a': No such file or directory
bundle.sh: 20: popd: not found
bundle.sh: 23: pushd: not found
mv: cannot move 'libpythonbundle.so' to '../../libs/armeabi-v7a': No such file or directory
bundle.sh: 26: popd: not found
bundle.sh: 29: pushd: not found
mv: cannot move 'libpythonbundle.so' to '../../libs/x86_64': No such file or directory
bundle.sh: 32: popd: not found

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':serious_python_android:configureCMakeRelWithDebInfo'.
> [CXX1429] error when building with cmake using /home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/src/CMakeLists.txt: -- android-16 is not supported for 
arm64-v8a. Using minimum supported LP64 version 21.
  -- Android: Targeting API '21' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
  -- Android: Selected unified Clang toolchain
  -- The C compiler identification is Clang 12.0.8
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /home/nima/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
  -- Check for working C compiler: /home/nima/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - broken
  -- Configuring incomplete, errors occurred!
  See also "/home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/android/.cxx/RelWithDebInfo/2e73n5z2/arm64-v8a/CMakeFiles/CMakeOutput.log".
  See also "/home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/android/.cxx/RelWithDebInfo/2e73n5z2/arm64-v8a/CMakeFiles/CMakeError.log".

  C++ build system  failed while executing:
      /usr/bin/cmake \
        -H/home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/src \
        -DCMAKE_SYSTEM_NAME=Android \
        -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
        -DCMAKE_SYSTEM_VERSION=16 \
        -DANDROID_PLATFORM=android-16 \
        -DANDROID_ABI=arm64-v8a \
        -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
        -DANDROID_NDK=/home/nima/Android/Sdk/ndk/23.1.7779620 \
        -DCMAKE_ANDROID_NDK=/home/nima/Android/Sdk/ndk/23.1.7779620 \
        -DCMAKE_TOOLCHAIN_FILE=/home/nima/Android/Sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake \
        -DCMAKE_MAKE_PROGRAM=/home/nima/Android/Sdk/cmake/3.22.1/bin/ninja \
        -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/flet_flutter_build_vtNSZwAPHU/build/serious_python_android/intermediates/cxx/RelWithDebInfo/2e73n5z2/obj/arm64-v8a \
        -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/tmp/flet_flutter_build_vtNSZwAPHU/build/serious_python_android/intermediates/cxx/RelWithDebInfo/2e73n5z2/obj/arm64-v8a \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -B/home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/android/.cxx/RelWithDebInfo/2e73n5z2/arm64-v8a \
        -GNinja
    from /home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/android
  CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
    The C compiler

      "/home/nima/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: /home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/android/.cxx/RelWithDebInfo/2e73n5z2/arm64-v8a/CMakeFiles/CMakeTmp

      Run Build Command(s):/home/nima/Android/Sdk/cmake/3.22.1/bin/ninja cmTC_1808b && [1/2] Building C object CMakeFiles/cmTC_1808b.dir/testCCompiler.c.o
      [2/2] Linking C executable cmTC_1808b
      FAILED: cmTC_1808b 
      : && /home/nima/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android21 
--sysroot=/home/nima/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DANDROID -fdata-sections -ffunction-sections -funwind-tables 
-fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions  -O2 -g -DNDEBUG -Wl,--build-id=sha1 -Wl,--no-rosegment 
-Wl,--fatal-warnings -Qunused-arguments -Wl,--no-undefined  -Wl,--gc-sections -B/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/9 
-B/snap/flutter/current/usr/lib/x86_64-linux-gnu -B/snap/flutter/current/lib/x86_64-linux-gnu -B/snap/flutter/current/usr/lib/ 
-L/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/9 -L/snap/flutter/current/usr/lib/x86_64-linux-gnu -L/snap/flutter/current/lib/x86_64-linux-gnu 
-L/snap/flutter/current/usr/lib/ -lblkid -lgcrypt -llzma -llz4 -lgpg-error -luuid -lpthread -ldl -lepoxy -lfontconfig -B/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/9 
-B/snap/flutter/current/usr/lib/x86_64-linux-gnu -B/snap/flutter/current/lib/x86_64-linux-gnu -B/snap/flutter/current/usr/lib/ 
-L/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/9 -L/snap/flutter/current/usr/lib/x86_64-linux-gnu -L/snap/flutter/current/lib/x86_64-linux-gnu 
-L/snap/flutter/current/usr/lib/ -lblkid -lgcrypt -llzma -llz4 -lgpg-error -luuid -lpthread -ldl -lepoxy -lfontconfig CMakeFiles/cmTC_1808b.dir/testCCompiler.c.o -o cmTC_1808b 
-latomic -lm && :
      ld: error: --fix-cortex-a53-843419 is only supported on AArch64 targets
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      ninja: build stopped: subcommand failed.

    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:6 (project)

* 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 4s
Gradle task assembleRelease failed with exit code 1

Error building Flet app - see the log of failed command above.
(env) ➜  ffdroid git:(main) 

Describe the results you expected: Creating APK file

Additional information you deem important (e.g. issue happens only occasionally): Due to that I live in Islamic dictatorship of Iran, lots of sites has been banned by government and I have to use VPN so perhaps some packages didn't downloaded completely.

Flet version (pip show flet):

Name: flet
Version: 0.19.0
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: /home/nima/Desktop/python-projects/ffdroid/env/lib/python3.10/site-packages
Requires: cookiecutter, flet-runtime, packaging, qrcode, watchdog, websocket-client, websockets
Required-by: 

Give your requirements.txt file (don't pip freeze, instead give direct packages):

flet
plyer

Operating system:

Additional environment details:

Ambassador-of-programming commented 8 months ago

I had problems with the apk too. The problem I had was that I needed to install all the necessary libraries and dependencies from Flutter and Android Studio. It took me about 1.5 days to solve all the problems. But now another problem is that when adding several routers the created apk application shows white screen, but if you leave only one route, there is no problem. This error appears only when creating apk file. Otherwise there are no errors. I also have Linux Parrot OS

bambier commented 8 months ago

Update

I had run code with --vv to get more logs

Copying P4A libraries from /home/nima/.local/share/python-for-android/dists/mydist Bundling arm64-v8a Bundling armeabi-v7a Bundling armeabi-v7a Copying all .so files to /home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/android/src/main/jniLibs bundle.sh: 17: pushd: not found mv: cannot move 'libpythonbundle.so' to '../../libs/arm64-v8a': No such file or directory bundle.sh: 20: popd: not found bundle.sh: 23: pushd: not found mv: cannot move 'libpythonbundle.so' to '../../libs/armeabi-v7a': No such file or directory bundle.sh: 26: popd: not found bundle.sh: 29: pushd: not found mv: cannot move 'libpythonbundle.so' to '../../libs/x86_64': No such file or directory bundle.sh: 32: popd: not found

FAILURE: Build failed with an exception.

BUILD FAILED in 4s Running Gradle task 'assembleRelease'... 5.1s Gradle task assembleRelease failed with exit code 1 Deleting Flutter bootstrap directory /tmp/flet_flutter_build_MrpRpSLUQq Error building Flet app - see the log of failed command above.

lekshmanmj commented 8 months ago

which OS? 32 or 64 bit architecture ?

taaaf11 commented 8 months ago

which OS? 32 or 64 bit architecture ?

The os and arch is mentioned in the first comment (the issue comment).

taaaf11 commented 8 months ago

Copying all .so files to /home/nima/.pub-cache/hosted/pub.dev/serious_python_android-0.7.0/android/src/main/jniLibs bundle.sh: 17: pushd: not found mv: cannot move 'libpythonbundle.so' to '../../libs/arm64-v8a': No such file or directory

@FeodorFitsner I think this issue is related to the scripts used in building. Can you see the pushd and popd commands not found? Here is the stackoverflow answer for reference:

https://stackoverflow.com/a/5193087/19619895

ndonkoHenri commented 1 month ago

Please retry packaging with the latest Flet version. If anyone still faces issues, please report using the bug issue-template.