wang-bin / fvp

Flutter video player plugin for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp
BSD 3-Clause "New" or "Revised" License
197 stars 31 forks source link

Default flutter application can't run on Android with the fvp plugin #81

Closed Keetz closed 7 months ago

Keetz commented 7 months ago

Describe the bug Ran flutter create to create the counter app. Added the fvp plugin in the yaml fvp: ^0.17.0. And now I can't run it on android.

Expected behavior I expect it to work without any further alterations.

Log

Launching lib/main.dart on Pixel 7 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fvp:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/android/.cxx/Debug/5p3r5f4u/arm64-v8a'
  [1/3] Building CXX object CMakeFiles/fvp_plugin.dir/fvp_plugin.cpp.o
  FAILED: CMakeFiles/fvp_plugin.dir/fvp_plugin.cpp.o
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DDART_SHARED_LIB -DFLUTTER_PLUGIN_IMPL -Dfvp_plugin_EXPORTS -isystem ../../../../mdk-sdk/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -fno-limit-debug-info  -fPIC -fvisibility=hidden -std=gnu++20 -MD -MT CMakeFiles/fvp_plugin.dir/fvp_plugin.cpp.o -MF CMakeFiles/fvp_plugin.dir/fvp_plugin.cpp.o.d -o CMakeFiles/fvp_plugin.dir/fvp_plugin.cpp.o -c ../../../../fvp_plugin.cpp
  In file included from ../../../../fvp_plugin.cpp:7:
  In file included from /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window_jni.h:31:
  In file included from /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window.h:41:
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:362:78: error: expected function body after function declarator
                               AHardwareBuffer* _Nullable* _Nonnull outBuffer) __INTRODUCED_IN(26);
                                                                               ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:371:64: error: expected function body after function declarator
  void AHardwareBuffer_acquire(AHardwareBuffer* _Nonnull buffer) __INTRODUCED_IN(26);
                                                                 ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:379:64: error: expected function body after function declarator
  void AHardwareBuffer_release(AHardwareBuffer* _Nonnull buffer) __INTRODUCED_IN(26);
                                                                 ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:388:71: error: expected function body after function declarator
                                AHardwareBuffer_Desc* _Nonnull outDesc) __INTRODUCED_IN(26);
                                                                        ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:444:9: error: expected function body after function declarator
          __INTRODUCED_IN(26);
          ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:465:9: error: expected function body after function declarator
          __INTRODUCED_IN(26);
          ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:476:9: error: expected function body after function declarator
          __INTRODUCED_IN(26);
          ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:488:9: error: expected function body after function declarator
          __INTRODUCED_IN(26);
          ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:519:76: error: expected function body after function declarator
                                 AHardwareBuffer_Planes* _Nonnull outPlanes) __INTRODUCED_IN(29);
                                                                             ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:540:76: error: expected function body after function declarator
  int AHardwareBuffer_isSupported(const AHardwareBuffer_Desc* _Nonnull desc) __INTRODUCED_IN(29);
                                                                             ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:557:73: error: expected function body after function declarator
                                     int32_t* _Nonnull outBytesPerStride) __INTRODUCED_IN(29);
                                                                          ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:568:9: error: expected function body after function declarator
          __INTRODUCED_IN(31);
          ^
  In file included from ../../../../fvp_plugin.cpp:7:
  In file included from /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window_jni.h:31:
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window.h:199:85: error: expected function body after function declarator
  int32_t ANativeWindow_setBuffersTransform(ANativeWindow* window, int32_t transform) __INTRODUCED_IN(26);
                                                                                      ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window.h:218:85: error: expected function body after function declarator
  int32_t ANativeWindow_setBuffersDataSpace(ANativeWindow* window, int32_t dataSpace) __INTRODUCED_IN(28);
                                                                                      ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window.h:228:66: error: expected function body after function declarator
  int32_t ANativeWindow_getBuffersDataSpace(ANativeWindow* window) __INTRODUCED_IN(28);
                                                                   ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window.h:261:9: error: expected function body after function declarator
          __INTRODUCED_IN(30);
          ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window.h:272:62: error: expected function body after function declarator
  void ANativeWindow_tryAllocateBuffers(ANativeWindow* window) __INTRODUCED_IN(30);
                                                               ^
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window.h:285:3: error: cannot initialize a variable of type 'enum ANativeWindow_ChangeFrameRateStrategy' with an rvalue of type 'int'
  } __INTRODUCED_IN(31);
    ^               ~~
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window.h:333:9: error: expected function body after function declarator
          __INTRODUCED_IN(31);
          ^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  [2/3] Building CXX object CMakeFiles/fvp_plugin.dir/home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/lib/src/callbacks.cpp.o
  FAILED: CMakeFiles/fvp_plugin.dir/home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/lib/src/callbacks.cpp.o
  /home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/username/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DDART_SHARED_LIB -DFLUTTER_PLUGIN_IMPL -Dfvp_plugin_EXPORTS -isystem ../../../../mdk-sdk/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -fno-limit-debug-info  -fPIC -fvisibility=hidden -std=gnu++20 -MD -MT CMakeFiles/fvp_plugin.dir/home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/lib/src/callbacks.cpp.o -MF CMakeFiles/fvp_plugin.dir/home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/lib/src/callbacks.cpp.o.d -o CMakeFiles/fvp_plugin.dir/home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/lib/src/callbacks.cpp.o -c /home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/lib/src/callbacks.cpp
  In file included from /home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/lib/src/callbacks.cpp:5:
  In file included from ../../../../mdk-sdk/include/mdk/Player.h:11:
  In file included from ../../../../mdk-sdk/include/mdk/global.h:15:
  /snap/flutter/current/usr/include/c++/9/memory:121:25: error: cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information
    const auto __intptr = reinterpret_cast<uintptr_t>(__ptr);
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.

  C++ build system [build] failed while executing:
      /home/username/Android/Sdk/cmake/3.18.1/bin/ninja \
        -C \
        /home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/android/.cxx/Debug/5p3r5f4u/arm64-v8a \
        fvp_plugin
    from /home/username/.pub-cache/hosted/pub.dev/fvp-0.17.0/android

* 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 1s
Error: Gradle task assembleDebug failed with exit code 1

Exited (1).
wang-bin commented 7 months ago

show me flutter doctor --verbose result. There are something wrong in your environment

  1. #include <native_window.h> results in errors. So your environment can't build android native apps. I don't know the reason.
  2. clang version in ndk 23 is 12, but the compiler searches libc++-9 dir, your environment can't build a simple c++ file

My suggestion is DON'T use flutter from snap, snap has it's own build environment which may conflict with android ndk's.

Keetz commented 7 months ago

Everything works fine without the plugin, I can run it on my Android phone or an Android emulator without any issues. The NDK, SDK, cmake and whatever is all installed through the SDK Manager in Android Studio, and again, it works fine until I add the fvp plugin.

username@username-desktop:~/Documents/test$ flutter doctor --verbose
[✓] Flutter (Channel stable, 3.19.5, on Ubuntu 22.04.4 LTS 6.5.0-28-generic, locale en_US.UTF-8)
    • Flutter version 3.19.5 on channel stable at /home/username/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (4 weeks ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/username/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /home/username/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2022.2)
    • Android Studio at /home/username/android-studio
    • Flutter plugin version 76.3.1
    • Dart plugin version 222.4582
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.88.1)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.86.0

[✓] Connected device (3 available)
    • Pixel 7 (mobile) • 29021FDH200D4B • android-arm64  • Android 14 (API 34)
    • Linux (desktop)  • linux          • linux-x64      • Ubuntu 22.04.4 LTS 6.5.0-28-generic
    • Chrome (web)     • chrome         • web-javascript • Google Chrome 124.0.6367.60

[✓] Network resources
    • All expected network resources are available.

• No issues found!
wang-bin commented 7 months ago

your environment can't build a simplest c++ file. You can build other flutter projects because no c++ code in those projects. Nothing wrong in my code. DO NOT use snap because it's c++ environment may conflicts with host and flutter environment. I can build without error without snap https://github.com/wang-bin/mdk-examples/actions/runs/8787920383/job/24144012772

Keetz commented 7 months ago

Okay, thanks. I will try and remove the snap and download Flutter manually instead.

Keetz commented 7 months ago

@wang-bin thanks again, I can confirm that removing everything related to the Flutter snap and manually downloading Flutter instead works.