无法在终端中构建应用程序,只能使用 Android Studio。 (离子,科尔多瓦)

Posted

技术标签:

【中文标题】无法在终端中构建应用程序,只能使用 Android Studio。 (离子,科尔多瓦)【英文标题】:Cant build app in terminal, only with AndroidStudio. (Ionic, cordova) 【发布时间】:2022-01-17 10:51:42 【问题描述】:

我有一个 ionic Cordova 应用程序,它在 android Stuio 中构建文件。但我无法在终端中构建它。

ionic cordova build android --prod

导致以下错误:

> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libsqlc-native-driver.so.

> Task :app:processDebugGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':app:processDebugGoogleServices' (type 'GoogleServicesTask').
  - In plugin 'com.google.gms.google-services' type 'com.google.gms.googleservices.GoogleServicesTask' field 'intermediateDir' without corresponding getter has been annotated with @OutputDirectory.
    
    Reason: Annotations on fields are only used if there's a corresponding getter for the field.
    
    Possible solutions:
      1. Add a getter for field 'intermediateDir'.
      2. Remove the annotations on 'intermediateDir'.
    
    Please refer to https://docs.gradle.org/7.1.1/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.
  - In plugin 'com.google.gms.google-services' type 'com.google.gms.googleservices.GoogleServicesTask' field 'packageNameXOR1' without corresponding getter has been annotated with @Input.
    
    Reason: Annotations on fields are only used if there's a corresponding getter for the field.
    
    Possible solutions:
      1. Add a getter for field 'packageNameXOR1'.
      2. Remove the annotations on 'packageNameXOR1'.
    
    Please refer to https://docs.gradle.org/7.1.1/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.
  - In plugin 'com.google.gms.google-services' type 'com.google.gms.googleservices.GoogleServicesTask' field 'packageNameXOR2' without corresponding getter has been annotated with @Input.
    
    Reason: Annotations on fields are only used if there's a corresponding getter for the field.
    
    Possible solutions:
      1. Add a getter for field 'packageNameXOR2'.
      2. Remove the annotations on 'packageNameXOR2'.
    
    Please refer to https://docs.gradle.org/7.1.1/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.
  - In plugin 'com.google.gms.google-services' type 'com.google.gms.googleservices.GoogleServicesTask' field 'quickstartFile' without corresponding getter has been annotated with @InputFile, @Optional.
    
    Reason: Annotations on fields are only used if there's a corresponding getter for the field.
    
    Possible solutions:
      1. Add a getter for field 'quickstartFile'.
      2. Remove the annotations on 'quickstartFile'.
    
    Please refer to https://docs.gradle.org/7.1.1/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.
  - In plugin 'com.google.gms.google-services' type 'com.google.gms.googleservices.GoogleServicesTask' field 'searchedLocation' without corresponding getter has been annotated with @Input.
    
    Reason: Annotations on fields are only used if there's a corresponding getter for the field.
    
    Possible solutions:
      1. Add a getter for field 'searchedLocation'.
      2. Remove the annotations on 'searchedLocation'.
    
    Please refer to https://docs.gradle.org/7.1.1/userguide/validation_problems.html#ignored_annotations_on_field for more details about this problem.

* 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.

我假设某种配置问题... 我知道 Android Studio 中的 Grade 版本不同。 但我不知道这是否是问题所在,以及如何在终端构建中更改它。见:

【问题讨论】:

【参考方案1】:

发现问题了,对我来说,下面的“config.xml”条目解决了它:

GradlePluginGoogleServicesVersion 4.2.0 => 4.3.8:

<preference name="GradlePluginGoogleServicesVersion" value="4.3.8" />

【讨论】:

以上是关于无法在终端中构建应用程序,只能使用 Android Studio。 (离子,科尔多瓦)的主要内容,如果未能解决你的问题,请参考以下文章

无法在 react native expo 项目中构建 android apk

Android 根应用程序不工作:无法从终端或 Java 中删除文件

Cordova/Phonegap 构建无法找到 HTML 模板

Git Bash 构建在 VS Code 中无法从终端运行

sh Android - 安装依赖项,使用sdkmanager / android终端工具在linux / ci / other上构建android项目

sh Android - 安装依赖项,使用sdkmanager / android终端工具在linux / ci / other上构建android项目