第一步 安装jdk,最好安装 jdk11,因为他是与qt5.15.2这个能匹配上的
右击电脑,选择属性,选择高级系统设置,选择环境变量。
点击新建,变量名为JAVA_HOME,变量值为java安装的路径。我的如下图
JAVA_HOME
D:\Program Files\Java\jdk-11
CLASSPATH
.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar //变量值
然后在path中将java 的bin目录及lib目录配置进去
双击path 配置java路径和jre路径
%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin
第二步下载androidsdk,网站点击这里,
选择windows r24.4.1的zip进行下载。
解压Android sdk到指定目录
双击sdk manager.exe。如果配置正常的话应该是可以打开的,如果出现黑屏一闪而过,然后程序没有任何反应,则说明sdk没有找到java路径,需要手动的进行更改。如果已经打开则进行下一步点击toools->lib 文件夹下面找到find_java.bat这个文件,选择用记事本打开它,将第43行的设置java路径改为 你自己的路径,我的如下
然后就能正常打开sdk manager,选择安装第一个,其他都不进行安装
安装完成之后关闭。在tools->bin 目录下会生成一份sdkmanager.bat文件,若没有,则新建一个名称为sdkmanager.txt的文件,将下面的代码拷贝进去
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem sdkmanager startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%..
@rem Add default JVM options here. You can also use JAVA_OPTS and SDKMANAGER_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Dcom.android.sdklib.toolsdir=%~dp0\.."
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\lib\sdklib-25.3.0-dev.jar;%APP_HOME%\lib\layoutlib-api-25.3.0-dev.jar;%APP_HOME%\lib\dvlib-25.3.0-dev.jar;%APP_HOME%\lib\repository-25.3.0-dev.jar;%APP_HOME%\lib\gson-2.2.4.jar;%APP_HOME%\lib\commons-compress-1.8.1.jar;%APP_HOME%\lib\httpclient-4.1.1.jar;%APP_HOME%\lib\httpmime-4.1.jar;%APP_HOME%\lib\common-25.3.0-dev.jar;%APP_HOME%\lib\kxml2-2.3.0.jar;%APP_HOME%\lib\annotations-25.3.0-dev.jar;%APP_HOME%\lib\annotations-12.0.jar;%APP_HOME%\lib\jimfs-1.1.jar;%APP_HOME%\lib\httpcore-4.1.jar;%APP_HOME%\lib\commons-logging-1.1.1.jar;%APP_HOME%\lib\commons-codec-1.4.jar;%APP_HOME%\lib\guava-18.0.jar
@rem Execute sdkmanager
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS% -classpath "%CLASSPATH%" com.android.sdklib.tool.SdkManagerCli %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable SDKMANAGER_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%SDKMANAGER_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
最后将后缀名改为.bat
然后在当前位置打开cmd命令框
依次输入如下命令
sdkmanager "build-tools;30.0.2" --sdk_root="D:\Android_sdk\android-sdk-windows"
sdkmanager "ndk;21.3.6528147" --sdk_root="D:\Android_sdk\android-sdk-windows"
sdkmanager "platform-tools" --sdk_root="D:\Android_sdk\android-sdk-windows"
sdkmanager "platforms;android-30" --sdk_root="D:\Android_sdk\android-sdk-windows"
sdkmanager "cmdline-tools;latest" --sdk_root="D:\Android_sdk\android-sdk-windows"
sdkmanager "extras;google;usb_driver" --sdk_root="D:\Android_sdk\android-sdk-windows"
第三步 下载Qt,jdk,sdk
Index of /official_releases/online_installers
qt Creator内配置
打开qt Creator 选择工具,选项。打开之后如下
点击设备,选择android
把jdk以及ndk的路径选择下即可。关于openssl的话可以选择下载openssl就可以了,时间有点长,等下载完成就ok了