【发布时间】:2022-11-24 00:21:53
【问题描述】:
我想使用Firebase,就像在任何原生Android应用程序中一样,不使用Qt(即使用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
【问题讨论】:
标签: android firebase qt gradle