@echo off
set path_script=%~dp0
cd /D %path_script%
rd /s/q "%path_script%\build"
rd /s/q "%path_script%\android"
md "%path_script%\build"
cd /D "%path_script%\build"
set ANDROID_NDK_HOST=windows-x86_64
set ANDROID_SDK_ROOT=E:/android/AndroidSdk
set ANDROID_NDK_ROOT=%ANDROID_SDK_ROOT%/ndk/21.3.6528147
set QT_ROOT=C:\Qt\Qt5.12.12
set PATH=%PATH%;%QT_ROOT%\Tools\QtCreator\bin\jom\;%QT_ROOT%\Tools\QtCreator\bin
if not exist "%ANDROID_SDK_ROOT%" (
echo "not exist path:%ANDROID_SDK_ROOT%"
pause
)
if not exist "%ANDROID_NDK_ROOT%" (
echo "not exist path:%ANDROID_NDK_ROOT%"
pause
)
setlocal enabledelayedexpansion
for %%i in ("x86","armeabi-v7a","arm64-v8a") do (
cd %path_script%
rd /s/q "%path_script%\build"
md "%path_script%\build"
if %%i=="x86" (
echo "abi type:x86"
set arch=x86
set abi=x86
)
if %%i=="armeabi-v7a" (
echo "abi type: armeabi-v7a"
set arch=armv7
set abi=armeabi-v7a
)
if %%i=="arm64-v8a" (
echo "abi type: arm64-v8a"
set arch=arm64_v8a
set abi=arm64-v8a
)
set QTDIR=%QT_ROOT%\5.12.12\android_!arch!
if not exist "!QTDIR!" (
echo "not exist path:!QTDIR!"
pause
)
set ANDROID_DEFINITION="-GNMake Makefiles JOM"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=!QT_ROOT!/Tools/QtCreator/share/qtcreator/package-manager/auto-setup.cmake"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DQT_QMAKE_EXECUTABLE:STRING=!QTDIR!/bin/qmake.exe"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DCMAKE_PREFIX_PATH:STRING=!QTDIR!"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DCMAKE_C_COMPILER:STRING=!ANDROID_NDK_ROOT!/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DCMAKE_CXX_COMPILER:STRING=!ANDROID_NDK_ROOT!/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DANDROID_NDK:PATH=!ANDROID_NDK_ROOT!"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DCMAKE_TOOLCHAIN_FILE:PATH=!ANDROID_NDK_ROOT!/build/cmake/android.toolchain.cmake"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DANDROID_STL:STRING=c++_shared"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DCMAKE_FIND_ROOT_PATH:PATH=!QTDIR!"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DANDROID_SDK:PATH=!ANDROID_SDK_ROOT!"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DANDROID_NATIVE_API_LEVEL:STRING=16"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DANDROID_ABI:STRING=!abi!"
set ANDROID_DEFINITION=!ANDROID_DEFINITION! "-DBUILD_SHARED_LIBS:STRING=OFF"
cd %path_script%/build && cmake.exe ../zlib-1.2.11 !ANDROID_DEFINITION! -DCMAKE_INSTALL_PREFIX="%path_script%/android/!abi!"
cmake --build . --config Release && cmake --build ./ --config Release --target install
)
endlocal
cd %path_script%
The following packages have unmet dependencies:
build-essential : Depends: libc6-dev but it is not going to be installed or
libc-dev
Depends: gcc (>= 4:7.2) but it is not going to be installed
Depends: g++ (>= 4:7.2) but it is not going to be installed
Depends: dpkg-dev (>= 1.17.11) but it is not going to be inst
1.报Failed to find Build Tools revision 28.0.3的错误,如下所示:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android-build'.
> Failed to find Build Tools revision 28.0.3