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
126 stars 20 forks source link

[android] Cannot specify link libraries for target "mdk" which is not built by this #10

Closed abdelaziz-mahdy closed 10 months ago

abdelaziz-mahdy commented 10 months ago
* What went wrong:
Execution failed for task ':fvp:configureCMakeDebug'.
> C/C++: /Users/AbdelazizMahdy/.pub-cache/hosted/pub.dev/fvp-0.1.0/android/CMakeLists.txt debug|armeabi-v7a : CMake Error at /Users/AbdelazizMahdy/.pub-cache/hosted/pub.dev/fvp-0.1.0/android/mdk-sdk/lib/cmake/FindMDK.cmake:260 (target_link_libraries):
    Cannot specify link libraries for target "mdk" which is not built by this
    project.
  Call Stack (most recent call first):
    CMakeLists.txt:67 (include)
wang-bin commented 10 months ago

what's your cmake version?

abdelaziz-mahdy commented 10 months ago

what's your cmake version?

i dont know how to check it, can you let me know.

in terminal its cmake version 3.27.1

but i dont know if that what flutter uses

abdelaziz-mahdy commented 10 months ago

You are running version 3.10.2 this is the cmake version flutter is using when building

also this is the line causing the problem target_link_libraries(mdk INTERFACE mdk-ffmpeg) # ensure libffmpeg.so will be copied by gradle

in the findMDK.cmake

also i tried to play with the configs abit

like setting in find mdk

cmake_minimum_required(VERSION 3.10)

# Project-level configuration.
set(PROJECT_NAME "mdk")
project(${PROJECT_NAME} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

but i made more errors appear i think

  -- Build files have been written to: /Users/AbdelazizMahdy/flutter_projects/fvp/android/.cxx/Debug/1x3s5o22/armeabi-v7a
  [1/3] Building CXX object CMakeFiles/fvp_plugin.dir/fvp_plugin.cpp.o
  FAILED: CMakeFiles/fvp_plugin.dir/fvp_plugin.cpp.o 
  /Users/AbdelazizMahdy/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi16 --gcc-toolchain=/Users/AbdelazizMahdy/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/AbdelazizMahdy/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -DDART_SHARED_LIB -DFLUTTER_PLUGIN_IMPL -Dfvp_plugin_EXPORTS  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security   -O0 -fno-limit-debug-info  -fPIC -fvisibility=hidden   -std=gnu++1z -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
  ../../../../fvp_plugin.cpp:10:10: fatal error: 'mdk/Player.h' file not found
  #include <mdk/Player.h>
           ^~~~~~~~~~~~~~
  1 error generated.
  [2/3] Building CXX object CMakeFiles/fvp_plugin.dir/Users/AbdelazizMahdy/flutter_projects/fvp/lib/src/callbacks.cpp.o
  FAILED: CMakeFiles/fvp_plugin.dir/Users/AbdelazizMahdy/flutter_projects/fvp/lib/src/callbacks.cpp.o 
  /Users/AbdelazizMahdy/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi16 --gcc-toolchain=/Users/AbdelazizMahdy/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/AbdelazizMahdy/Library/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -DDART_SHARED_LIB -DFLUTTER_PLUGIN_IMPL -Dfvp_plugin_EXPORTS  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security   -O0 -fno-limit-debug-info  -fPIC -fvisibility=hidden   -std=gnu++1z -MD -MT CMakeFiles/fvp_plugin.dir/Users/AbdelazizMahdy/flutter_projects/fvp/lib/src/callbacks.cpp.o -MF CMakeFiles/fvp_plugin.dir/Users/AbdelazizMahdy/flutter_projects/fvp/lib/src/callbacks.cpp.o.d -o CMakeFiles/fvp_plugin.dir/Users/AbdelazizMahdy/flutter_projects/fvp/lib/src/callbacks.cpp.o -c /Users/AbdelazizMahdy/flutter_projects/fvp/lib/src/callbacks.cpp
  /Users/AbdelazizMahdy/flutter_projects/fvp/lib/src/callbacks.cpp:5:10: fatal error: 'mdk/Player.h' file not found
  #include "mdk/Player.h"
           ^~~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.
abdelaziz-mahdy commented 10 months ago

i just cloned the repo and it works on your example, which is weird,

since using i am using the package locally on both cases while trying.

the only reason i think it maybe failing is gradle versions or cmake versions, since your was using cmake 3.22 mine was 3.10

wang-bin commented 10 months ago

What about upgrading your cmake?

abdelaziz-mahdy commented 10 months ago

i dont know how to do it in flutter, does setting the ndk version does that?

wang-bin commented 10 months ago

btw, you have to upgrade ndk too. I use ndk 25, but ndk 23 breaks abi, you must use ndk 23 or later

abdelaziz-mahdy commented 10 months ago

i did set the ndk version for ndkVersion "25.2.9519653" but the cmake is still version 3.10.2

abdelaziz-mahdy commented 10 months ago

setting version "3.22.1" in your package

   externalNativeBuild {
        cmake {
            // version "Your.CMake.Version"

            path "CMakeLists.txt"
            // The default CMake version for the Android Gradle Plugin is 3.10.2.
            // https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
            //
            // The Flutter tooling requires that developers have CMake 3.10 or later
            // installed. You should not increase this version, as doing so will cause
            // the plugin to fail to compile for some customers of the plugin.
            // version "3.10.2"
            version "3.22.1"
        }
    }

made it compile without errors finally i think thats not a valid fix since it just has to be higher than 3.20 correct?

but at least now we know what is the problem

wang-bin commented 10 months ago

i need to know how cmake version is selected. If use ndk 23 or later is installed, then higher version of ndk and cmake will be used.

abdelaziz-mahdy commented 10 months ago

when i did use ndkVersion "25.2.9519653" alone it was still using cmake 3.10.2

setting the cmake like mentioned was the only fix that worked for my case

i updated the pr to allow anything after 3.22.0, do you think we should set the ndk version in the package to make sure all people has the cmake version updated?

abdelaziz-mahdy commented 10 months ago

maybe this is the cause https://developer.android.com/studio/projects/install-ndk#vanilla_cmake

image

your example uses classpath 'com.android.tools.build:gradle:8.0.2'

and mine uses classpath 'com.android.tools.build:gradle:7.0.4'

so from the image by default i use the 21.4.7075529 this is the main problem i think

AnonymHK commented 10 months ago

Okay, I'll give it a try !

abdelaziz-mahdy commented 10 months ago

updating from classpath 'com.android.tools.build:gradle:7.0.4' to classpath 'com.android.tools.build:gradle:7.4.2' fixed the error also i updated to version 0.2.0

AnonymHK commented 10 months ago

This solution is not valid for me. I will try again after your new version is released!

abdelaziz-mahdy commented 10 months ago

This solution is not valid for me. I will try again after your new version is released!

your issue is related to this https://github.com/wang-bin/fvp/pull/13 so its okay