web-dev-qa-db-fra.com

Erreur lors de l'exécution de cordova build –release android

J'essaie de publier mon application Android en suivant les instructions ci-dessous:

http://ionicframework.com/docs/guide/publishing.html

Cependant, lorsque je lance cordova build --release Android, l'erreur suivante apparaît:

:lintVitalArmv7Release
/Users/xxx/Documents/xxx/xxx/platforms/Android/res/values/arrays.xml:3: Error: "country_codes" is not translated in "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan), "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "es" (Spanish), "eu" (Basque), "fi" (Finnish), "fr" (French), "he" (Hebrew), "hi" (Hindi), "hu" (Hungarian), "id" (Indonesian), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ko" (Korean), "nl" (Dutch), "pl" (Polish), "pt" (Portuguese), "ru" (Russian), "sk" (Slovak), "sl" (Slovene), "sv" (Swedish), "tr" (Turkish), "zh-rCN" (Chinese: China), "zh-rTW" (Chinese: Taiwan, Province of China) [MissingTranslation]
  <string-array name="country_codes">
                ~~~~~~~~~~~~~~~~~~~~
/Users/xxx/Documents/xxx/xxx/platforms/Android/res/values/strings.xml:3: Error: "app_name" is not translated in "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan), "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "es" (Spanish), "eu" (Basque), "fi" (Finnish), "fr" (French), "he" (Hebrew), "hi" (Hindi), "hu" (Hungarian), "id" (Indonesian), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ko" (Korean), "nl" (Dutch), "pl" (Polish), "pt" (Portuguese), "ru" (Russian), "sk" (Slovak), "sl" (Slovene), "sv" (Swedish), "tr" (Turkish), "zh-rCN" (Chinese: China), "zh-rTW" (Chinese: Taiwan, Province of China) [MissingTranslation]
    <string name="app_name">myapp</string>
            ~~~~~~~~~~~~~~~
/Users/xxx/Documents/xxx/xxx/platforms/Android/res/values/strings.xml:4: Error: "launcher_name" is not translated in "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan), "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "es" (Spanish), "eu" (Basque), "fi" (Finnish), "fr" (French), "he" (Hebrew), "hi" (Hindi), "hu" (Hungarian), "id" (Indonesian), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ko" (Korean), "nl" (Dutch), "pl" (Polish), "pt" (Portuguese), "ru" (Russian), "sk" (Slovak), "sl" (Slovene), "sv" (Swedish), "tr" (Turkish), "zh-rCN" (Chinese: China), "zh-rTW" (Chinese: Taiwan, Province of China) [MissingTranslation]
    <string name="launcher_name">@string/app_name</string>
            ~~~~~~~~~~~~~~~~~~~~
/Users/xxx/Documents/xxx/xxx/platforms/Android/res/values/strings.xml:5: Error: "activity_name" is not translated in "ar" (Arabic), "bg" (Bulgarian), "ca" (Catalan), "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "es" (Spanish), "eu" (Basque), "fi" (Finnish), "fr" (French), "he" (Hebrew), "hi" (Hindi), "hu" (Hungarian), "id" (Indonesian), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ko" (Korean), "nl" (Dutch), "pl" (Polish), "pt" (Portuguese), "ru" (Russian), "sk" (Slovak), "sl" (Slovene), "sv" (Swedish), "tr" (Turkish), "zh-rCN" (Chinese: China), "zh-rTW" (Chinese: Taiwan, Province of China) [MissingTranslation]
    <string name="activity_name">@string/launcher_name</string>
            ~~~~~~~~~~~~~~~~~~~~

   Explanation for issues of type "MissingTranslation":
   If an application has more than one locale, then all the strings declared
   in one language should also be translated in all other languages.

   If the string should not be translated, you can add the attribute
   translatable="false" on the <string> element, or you can define all your
   non-translatable strings in a resource file called donottranslate.xml. Or,
   you can ignore the issue with a tools:ignore="MissingTranslation"
   attribute.

   By default this detector allows regions of a language to just provide a
   subset of the strings and fall back to the standard language strings. You
   can require all regions to provide a full translation by setting the
   environment variable Android_LINT_COMPLETE_REGIONS.

   You can tell lint (and other tools) which language is the default language
   in your res/values/ folder by specifying tools:locale="languageCode" for
   the root <resources> element in your resource file. (The tools prefix
   refers to the namespace declaration http://schemas.Android.com/tools.)

/Users/xxx/Documents/xxx/xxx/platforms/Android/res/values-ar/strings.xml:64: Error: "menu_settings" is translated here but not found in default locale [ExtraTranslation]
  <string name="menu_settings">???????</string>
    5 errors, 0 warnings
    :lintVitalArmv7Release FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':lintVitalArmv7Release'.
    > Lint found fatal errors while assembling a release target.

      To proceed, either fix the issues identified by lint, or modify your build script as follows:
      ...
      Android {
          lintOptions {
              checkReleaseBuilds false
              // Or, if you prefer, you can continue to check for errors in release builds,
              // but continue the build even when errors are found:
              abortOnError false
          }
      }
      ...

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 4.583 secs

    /Users/xxx/Documents/xxx/xxx/platforms/Android/cordova/node_modules/q/q.js:126
                        throw e;
                              ^
    Error code 1 for command: /Users/xxx/Documents/xxx/xxx/platforms/Android/gradlew with args: cdvBuildRelease,-b,/Users/xxx/Documents/xxx/xxx/platforms/Android/build.gradle,-Dorg.gradle.daemon=true
    ERROR building one of the platforms: Error: /Users/xxx/Documents/xxx/xxx/platforms/Android/cordova/build: Command failed with exit code 8
    You may not have the required environment or OS to build this project
    Error: /Users/xxx/Documents/xxx/xxx/platforms/Android/cordova/build: Command failed with exit code 8
        at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
        at ChildProcess.emit (events.js:98:17)
        at maybeClose (child_process.js:766:16)
        at Process.ChildProcess._handle.onexit (child_process.js:833:5)

Je peux exécuter ionic build Android et déployer sur un émulateur sans problème.

J'ai essayé de rechercher lintOptions et build.gradle mais je ne les trouve nulle part dans mon projet ...

Quelqu'un peut-il aider? Merci d'avance

34
James J

Résolu cela en ajoutant

lintOptions {
    abortOnError false
}

à la section Android {} dans /platforms/Android/build.gradle

39
James J

Ajoutez l'entrée suivante au fichier /platforms/Android/build.gradle dans votre projet Ionic:

Android {
   lintOptions { disable 'MissingTranslation', 'ExtraTranslation' }
}

travaillé.

33
Brainiac

Pour ceux qui préfèrent garder le répertoire platforms hors du VCS (Git, etc.),
Pour le moment, la meilleure solution consiste à utiliser un plugin appelé ignore-lint-translation .

cordova plugin add cordova-plugin-ignore-lint-translation --save

Le résultat effectif est l'ajout d'un fichier de gradation qui désactivera de telles options (doh!).

15
gustavohenke

On peut être plus précis en ajoutant simplement 

lintOptions {
    disable MissingTranslation
}
7
demanic

Pour corriger cette erreur, vous devez ajouter 

lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
}

Dans la section Android {} de /platforms/Android/build.gradle

5
Sagar Thakkar
echo "Android { lintOptions { checkReleaseBuilds false } }" >> platforms/Android/build-extras.gradle
2
territorial

Si votre construction a échoué à cause de problèmes MissingTranslation et si la chaîne ne doit pas être traduite, vous pouvez ajouter l'attribut translatable="false" sur cet élément <string> dans le fichier /platforms/Android/app/src/main/res/values/strings.xml

Donc, si les chaînes du fichier strings.xml ressemblent à ceci:

<string name="app_name">Your App Name</string>
<string name="launcher_name">@string/app_name</string>
<string name="activity_name">@string/launcher_name</string>

Modifiez-les pour qu'ils ressemblent à ceci:

<string name="app_name" translatable="false">Your App Name</string>
<string name="launcher_name" translatable="false">@string/app_name</string>
<string name="activity_name" translatable="false">@string/launcher_name</string>

Cette solution a fonctionné pour moi.

0
Amr

Pas besoin d'utiliser un plugin cordova, utilisez un hook after_platform_add comme décrit ici , puis mettez ceci dans un fichier build-extras.gradle:

Android {
    lintOptions {
        disable 'MissingTranslation'
        disable 'ExtraTranslation'
    }
}
0
Brad Pitcher