1、Qt Creator 4.11.2
官方下载:https://download.qt.io/archive/qtcreator/4.11/4.11.2/
镜像下载:https://mirrors.cloud.tencent.com/qt/archive/qtcreator/4.11/4.11.2/
2、Qt 5.15.2 Android
官方更新器内部下载
参考:https://blog.csdn.net/weixin_41013202/article/details/129957693
3、JDK 8
https://adoptium.net/zh-CN/temurin/releases/
4、以下都在Android Studio内部下载:
(1)Android SDK Platform 最新版(现在是33)
(2)Android SDK Build-Tools 最新版(现在是33.0.2)、30.0.3
(3)NDK 21.4
(4)Android SDK Command-line Tools (latest)
(5)Android SDK Platform-Tools
(6)Google USB Driver(用真机调试就下这个,用虚拟机调试就下Emulator)
5、.pro文件
(1)使用编译器支持的最新的C++标准(201707)
CONFIG += c++latest
(2)设置SDK
ANDROID_MIN_SDK_VERSION = 24 # Android 7.0
ANDROID_TARGET_SDK_VERSION = 33 # Android 13
其他SDK版本号参考:https://developer.android.google.cn/studio/releases/platforms?hl=zh-cn
6、AndroidManifest.xml文件
(1)Version name:“1.0”这种版本号格式
(2)Version code:随便写
(3)Application name和Activity name:应用名称
7、Gradle设置
(1)C:/Users/你的用户名/.gradle/gradle.properties:
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Fri May 26 17:03:24 CST 2023
systemProp.http.proxyHost=
systemProp.http.proxyPort=80
systemProp.https.proxyHost=
systemProp.https.proxyPort=80
(2)C:/Users/你的用户名/.gradle/init.gradle:
allprojects {
buildscript {
repositories {
mavenLocal()
maven { url 'https://mirrors.cloud.tencent.com/maven/' }
maven { url 'https://maven.aliyun.com/repository/central/' }
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
maven { url 'https://maven.aliyun.com/repository/spring/' }
maven { url 'https://maven.aliyun.com/repository/spring-plugin/' }
maven { url 'https://maven.aliyun.com/repository/grails-core/' }
maven { url 'https://maven.aliyun.com/repository/apache-snapshots/' }
mavenCentral()
}
}
repositories {
mavenLocal()
maven { url 'https://mirrors.cloud.tencent.com/maven/' }
maven { url 'https://maven.aliyun.com/repository/central/' }
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
maven { url 'https://maven.aliyun.com/repository/spring/' }
maven { url 'https://maven.aliyun.com/repository/spring-plugin/' }
maven { url 'https://maven.aliyun.com/repository/grails-core/' }
maven { url 'https://maven.aliyun.com/repository/apache-snapshots/' }
mavenCentral()
}
}
(3)项目目录/android/build.gradle:
buildscript {
repositories {
mavenLocal()
maven { url 'https://mirrors.cloud.tencent.com/maven/' }
maven { url 'https://maven.aliyun.com/repository/central/' }
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
maven { url 'https://maven.aliyun.com/repository/spring/' }
maven { url 'https://maven.aliyun.com/repository/spring-plugin/' }
maven { url 'https://maven.aliyun.com/repository/grails-core/' }
maven { url 'https://maven.aliyun.com/repository/apache-snapshots/' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
}
}
repositories {
mavenLocal()
maven { url 'https://mirrors.cloud.tencent.com/maven/' }
maven { url 'https://maven.aliyun.com/repository/central/' }
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
maven { url 'https://maven.aliyun.com/repository/spring/' }
maven { url 'https://maven.aliyun.com/repository/spring-plugin/' }
maven { url 'https://maven.aliyun.com/repository/grails-core/' }
maven { url 'https://maven.aliyun.com/repository/apache-snapshots/' }
mavenCentral()
}
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion '30.0.3'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
tasks.withType(JavaCompile) {
options.incremental = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}
defaultConfig {
resConfig "en"
minSdkVersion = qtMinSdkVersion
targetSdkVersion = qtTargetSdkVersion
}
}
(4)项目目录/android/gradle/wrapper/gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8、构建目录
(1)建议把构建目录的名称改短一点,因为文件夹名字太长会编译不了。
9、代码测试
(1)输出编译器使用的C++标准(201707)
qDebug() << __cplusplus;
10、报错解决
(1)如果在编译过程中报错“android:exported......”,就要在AndroidManifest.xml文件的<activity>处添加android:exported="true":文章来源:https://www.toymoban.com/news/detail-621506.html
<activity android:exported="true" ............文章来源地址https://www.toymoban.com/news/detail-621506.html
到了这里,关于Qt5.15.2安卓Android项目开发环境配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!