- bounty明天到期**。回答此问题可获得+100声望奖励。Alexander Dyagilev希望吸引更多人关注此问题。
我希望使用Firebase
的方式与任何不使用Qt
的原生Android
应用程序相同(即使用Java
)。我已经有一个(一切正常)。
现在,我尝试将Firebase
添加到我现有的Qt
项目中。现在,我尝试将所有必需的依赖项添加到build.gradle
中(这样我就可以在我的Qt
项目的Java
源代码部分中使用Firebase APIs
),但遇到了奇怪的错误。
我不擅长Gradle
,所以任何帮助都是感激的(如果这是可能的,因为我使用的是相当旧的Qt 5.12.12
)。
这是我拥有的build.gradle
(构建和运行良好):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.jakewharton:process-phoenix:2.1.2' // https://github.com/JakeWharton/ProcessPhoenix
implementation 'me.dm7.barcodescanner:zxing:1.9.13' // https://github.com/dm77/barcodescanner
}
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!
*******************************************************/
// Buggy thing: fails to build. Needs to be replaced with actual numbers.
// https://stackoverflow.com/a/46290586/3765267
/*compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion*/
compileSdkVersion 30
buildToolsVersion "30.0.2"
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 = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
这是build.gradle
,包含我尝试添加的所有依赖项(我已经将classpath 'com.google.gms:google-services:4.3.14'
添加到dependencies
节和apply plugin: 'com.google.gms.google-services'
行):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.3.14'
}
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.jakewharton:process-phoenix:2.1.2' // https://github.com/JakeWharton/ProcessPhoenix
implementation 'me.dm7.barcodescanner:zxing:1.9.13' // https://github.com/dm77/barcodescanner
}
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!
*******************************************************/
// Buggy thing: fails to build. Needs to be replaced with actual numbers.
// https://stackoverflow.com/a/46290586/3765267
/*compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion*/
compileSdkVersion 30
buildToolsVersion "30.0.2"
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 = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
现在,我在尝试构建项目时遇到了以下奇怪的错误:
Generating Android Package
Input file: C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/ui/android-libfdm.so-deployment-settings.json
Output directory: C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/ui/android-build/
Application binary: C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/bin/libfdm.so
Android build platform: android-33
Install to device: No
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Work\Source\build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug\ui\android-build\build.gradle' line: 18
* What went wrong:
A problem occurred evaluating root project 'android-build'.
> ASCII
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
- 第一项补充。**我可以使用Qt 6.4.1 + Firebase进行构建。问题是关于Qt 5.12.12。我怀疑原因是它使用的Gradle版本太旧(4.6)或类似的东西。
1条答案
按热度按时间gcmastyq1#
默认情况下,在android中,我们在gradle根模块中声明插件依赖关系。似乎在qt项目中,我们只有一个平面层,只有一个
build.gradle
文件。好消息是,我们也可以在settings.gradle
中声明插件依赖关系确保您已连接
settings.gradle
中的插件:现在你可以在
build.gradle
中应用插件,如下所示: