64 lines
3.4 KiB
Markdown
64 lines
3.4 KiB
Markdown
|
# Qt Android 开发环境搭建及问题解决
|
|||
|
|
|||
|
重点是需要按照 <Qt安装路径>\Tools\QtCreator\share\qtcreator\android\sdk_definitions.json 文件的指导来安装全部所需工具包,比如:
|
|||
|
|
|||
|
```json
|
|||
|
{
|
|||
|
"common": {
|
|||
|
"sdk_tools_url": {
|
|||
|
"linux": "https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip",
|
|||
|
"linux_sha256": "d71f75333d79c9c6ef5c39d3456c6c58c613de30e6a751ea0dbd433e8f8b9cbf",
|
|||
|
"windows": "https://dl.google.com/android/repository/commandlinetools-win-8092744_latest.zip",
|
|||
|
"windows_sha256": "5de99ed67cb2e30fe443baf8b282d1b0b6247d0c25c6d888a7e8657b3b35c281",
|
|||
|
"mac": "https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip",
|
|||
|
"mac_sha256": "1de25523d595198d29666f9976eed65d99bbc5e4a3e8e48e5d6c98bb7e9030cc"
|
|||
|
},
|
|||
|
"sdk_essential_packages": {
|
|||
|
"default": ["platform-tools", "platforms;android-31", "cmdline-tools;latest"],
|
|||
|
"linux": [],
|
|||
|
"mac": [],
|
|||
|
"windows": ["extras;google;usb_driver"]
|
|||
|
}
|
|||
|
},
|
|||
|
"specific_qt_versions": [
|
|||
|
{
|
|||
|
"versions": ["default"],
|
|||
|
"sdk_essential_packages": ["build-tools;31.0.0", "ndk;25.1.8937393"],
|
|||
|
"ndk_path": "ndk/25.1.8937393"
|
|||
|
},
|
|||
|
{
|
|||
|
"versions": ["6.4"],
|
|||
|
"sdk_essential_packages": ["build-tools;31.0.0", "ndk;23.1.7779620"],
|
|||
|
"ndk_path": "ndk/23.1.7779620"
|
|||
|
},
|
|||
|
{
|
|||
|
"versions": ["6.3", "6.2", "5.15.[9-20]"],
|
|||
|
"sdk_essential_packages": ["build-tools;31.0.0", "ndk;22.1.7171670"],
|
|||
|
"ndk_path": "ndk/22.1.7171670"
|
|||
|
},
|
|||
|
{
|
|||
|
"versions": ["5.15.[0-8]", "5.14.[0-2]", "5.13.2", "6.0", "6.1"],
|
|||
|
"sdk_essential_packages": ["build-tools;31.0.0", "ndk;21.3.6528147"],
|
|||
|
"ndk_path": "ndk/21.3.6528147"
|
|||
|
},
|
|||
|
{
|
|||
|
"versions": ["5.12.[0-5]", "5.13.[0-1]"],
|
|||
|
"sdk_essential_packages": ["build-tools;28.0.2", "ndk;19.2.5345600"],
|
|||
|
"ndk_path": "ndk/19.2.5345600"
|
|||
|
}
|
|||
|
]
|
|||
|
}
|
|||
|
```
|
|||
|
|
|||
|
1. 使用 Qt Maintenance Tool 安装 Android 包,并安装 Android Studio
|
|||
|
|
|||
|
2. 下载并安装 [OpenJDK 8](https://download.java.net/openjdk/jdk8u42/ri/openjdk-8u42-b03-windows-i586-14_jul_2022.zip), 设置 JAVA_HOME 到 OpenJDK 8 安装路径下。
|
|||
|
|
|||
|
3. 进入 Qt Creator->首选项->设备->Android,设定 JDK 路径到 OpenJDK 8 下,设置 Android SDK 路径到 Android Studio->More Actions->SDK Manager->Android SDK Location 中显示的路径(一般是:C:\Users\Administrator\AppData\Local\Android\Sdk)。
|
|||
|
|
|||
|
4. 进入 Android Studio->More Actions->SDK Manager 选中 “Show Package Details”,然后在该界面下按照 <Qt安装路径>\Tools\QtCreator\share\qtcreator\android\sdk_definitions.json 中的提示安装所有工具包。
|
|||
|
|
|||
|
如果仍然缺少工具包,则可以将 Android SDK 路径切换的其他空目录下再切换回来,Qt Creator 会提示需要哪些工具包。
|
|||
|
|
|||
|
如果提示 SDK Manager 未运行,可能是 cmdline-tools 的安装或配置不正确,请检查 <Android\Sdk>\cmdline-tools\latest\bin 下的 sdkmanager.bat 是否能正确执行,如果不能正确执行,需要检查 OpenJDK 8 是否正确安装,java 程序是否正确指向该路径(尤其是系统中有多个 java 环境的受),甚至可以采取用 sdk_definitions.json 中的 commandlinetools 进行覆盖的操作。
|