构建cordova时出错
离子信息 ✔收集环境信息-完成!
离子:
ionic(Ionic CLI):4.2.1(/ usr / lib / node_modules / ionic) 离子框架:离子角3.9.2 @ ionic / app-scripts:3.2.1
科尔多瓦:
cordova(Cordova CLI):8.1.2(cordova-lib@8.1.1) Cordova平台:Android 7.1.2,浏览器5.0.4 Cordova插件:cordova-plugin-ionic-keyboard 2.1.3,cordova-plugin-ionic-webview 2.2.5(和其他23个插件)
系统:
Android SDK工具:26.1.1(/ home / hitesh / Android / Sdk) NodeJS:v8.11.3(/ usr / bin / node) npm:6.4.1 操作系统:Linux 4.13
cordova插件列表
cordova-open-native-settings 1.5.1 "Native settings"
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-advanced-http 2.0.1 "Advanced HTTP plugin"
cordova-plugin-bg-location-sender 2.1.2 "BGLocationSender"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-email-composer 0.8.15 "EmailComposer"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googlemaps 2.4.6 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.2.5 "cordova-plugin-ionic-webview"
cordova-plugin-nativeaudio 3.0.9 "Cordova Native Audio"
cordova-plugin-nativegeocoder 3.1.3 "NativeGeocoder"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-request-location-accuracy 2.2.3 "Request Location Accuracy"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.3 "SocialSharing"
cordova-support-google-services 1.1.0 "cordova-support-google-services"
es6-promise-plugin 4.2.2 "Promise"
mx.ferreyra.callnumber 0.0.2 "Cordova Call Number Plugin"
paywitheasebuzz-cordova-plugin 0.0.1 "easebuzz-cordova-kit"
phonegap-plugin-multidex 1.0.0 "Multidex"
phonegap-plugin-push 2.2.3 "PushPlugin"
uk.co.workingedge.phonegap.plugin.launchnavigator 4.2.2 "Launch Navigator"
:app:processDebugGoogleServices
Parsing json file: /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/google-services.json
:app:mergeDebugResources
[string/google_app_id] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/src/main/res/values/strings.xml [string/google_app_id] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/build/generated/res/google-services/debug/values/values.xml: Error: Duplicate resources
[string/google_api_key] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/src/main/res/values/strings.xml [string/google_api_key] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/build/generated/res/google-services/debug/values/values.xml: Error: Duplicate resources
:app:mergeDebugResources FAILED
失败:构建失败,并出现异常。
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
[string/google_app_id] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/src/main/res/values/strings.xml [string/google_app_id] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/build/generated/res/google-services/debug/values/values.xml: Error: Duplicate resources
[string/google_api_key] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/src/main/res/values/strings.xml [string/google_api_key] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/build/generated/res/google-services/debug/values/values.xml: Error: Duplicate resources
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
23秒内失败 22个可执行任务:已执行16个,最新6个 / home / hitesh / Documents / IONIC / APPLICATIONS / Taxiwala / IN_taxiwala / platforms / android / gradlew:命令失败,退出代码为1错误输出: 注意:某些输入文件使用或覆盖不推荐使用的API。 注意:有关详细信息,请使用-Xlint:deprecation重新编译。
失败:构建失败,并出现异常。
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
[string/google_app_id] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/src/main/res/values/strings.xml [string/google_app_id] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/build/generated/res/google-services/debug/values/values.xml: Error: Duplicate resources
[string/google_api_key] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/src/main/res/values/strings.xml [string/google_api_key] /home/hitesh/Documents/IONIC/APPLICATIONS/Taxiwala/IN_taxiwala/platforms/android/app/build/generated/res/google-services/debug/values/values.xml: Error: Duplicate resources
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
23秒内失败
答案 0 :(得分:0)
我找到了解决问题的方法:
此处提供了与我遵循的(以及引起问题的)类似的指令,尽管相关性的版本有些过时:
https://firebase.google.com/docs/android/setup
造成我这种情况的原因是,按照Firebase中“应用程序创建”页面上的这些说明进行操作,并将依赖项添加到项目和模块的build.gradle文件中,如下所示:
添加项目build.gradle /project/platforms/android/build.gradle:
buildscript {
repositories {
jcenter ()
maven {
url "https://maven.google.com"
}
Google()
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.1.3'
// Firebase
classpath 'com.google.gms: google-services: 4.0.0'
}
}
并添加模块build.gradle /project/platforms/android/app/build.gradle:
buildscript {
repositories {
mavenCentral ()
jcenter ()
maven {
url "https://maven.google.com"
}
Google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// Firebase
classpath 'com.google.gms: google-services: 4.0.0'
classpath 'com.google.firebase: firebase-core: 16.0.0'
}
}
// Firebase, add at the end of the same file
apply plugin: 'com.google.gms.google-services'
解决方案:
我找到的解决方案是注释注释// Firebase之前的行:
文件:/project/platforms/android/build.gradle:
buildscript {
repositories {
jcenter ()
maven {
url "https://maven.google.com"
}
Google()
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.1.3'
// Firebase
// classpath 'com.google.gms: google-services: 4.0.0'
}
}
文件:/project/platforms/android/app/build.gradle:
buildscript {
repositories {
mavenCentral ()
jcenter ()
maven {
url "https://maven.google.com"
}
Google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// Firebase
//classpath 'com.google.gms: google-services: 4.0.0'
//classpath 'com.google.firebase: firebase-core: 16.0.0'
}
}
// Firebase, add at the end of the same file
//apply plugin: 'com.google.gms.google-services'
完成这些步骤后,一切正常,我能够毫无问题地运行$ cordova build android
。
建议:如果发生任何其他错误,请尝试删除插件和平台,然后重新创建它们:
$ ionic cordova plugin rm cordova-plugin-bg-location-sender --save
$ ionic cordova platform rm android
$ ionic cordova plugin add cordova-plugin-bg-location-sender --save
$ ionic cordova platform add android
答案 1 :(得分:0)
在您的项目目录中,运行:
./gradlew clean build
或从Android Studio中选择:
构建>清理项目