Solucionado (ver solução)
Solucionado
(ver solução)
5
respostas

ionic cordova build android || error

quando eu coloco o comando

ionic build android

de inicio ele funciona, mas quando chega na parte

> ionic cordova prepare --no-build
> cordova prepare

logo em seguida aparece o seguinte erro

TypeError: ts.forEachTrailingCommentRange is not a function
    at /Users/alexander/Desktop/Ionic/aluraCar/node_modules/tslint/lib/rules/noUnusedVariableRule.js:205:20
    at iterate (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/tsutils/util/util.js:345:20)
    at Array.forEach (<anonymous>)
    at iterate (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/tsutils/util/util.js:347:50)
    at Object.forEachToken (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/tsutils/util/util.js:348:7)
    at removeAll (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/tslint/lib/rules/noUnusedVariableRule.js:204:19)
    at /Users/alexander/Desktop/Ionic/aluraCar/node_modules/tslint/lib/rules/noUnusedVariableRule.js:159:13
    at /Users/alexander/Desktop/Ionic/aluraCar/node_modules/tslint/lib/rules/noUnusedVariableRule.js:287:23
    at visitEachNode (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/typescript/lib/typescript.js:8338:30)
    at Object.forEachChild (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/typescript/lib/typescript.js:8498:24)
[15:07:55]  lint finished in 40.05 s

se alguém souber se eu esqueci de instalar alguma coisa ou atualizar algo, por favor comente.

5 respostas

Boa tarde! Nunca vi essa mensagem de erro. Você esta usando o projeto do curso com a mesma versão do Ionic que uso no curso? Deve haver uma paridade ou você terá problemas.

Pesquisando na Internet parece ser um conflito de versões

https://github.com/palantir/tslint/issues/3113

Dá uma verificada, você esta usando o Ionic C incompatível com o projeto baixado no curso, essa é a maior hipótese.

no final da mensagem aparece

[ERROR] An error occurred while running cordova build android (exit code 1).

pesquisei esse error, e alguns tópicos mandavam desinstalar e instalar a plataforma android, mas mesmo fazendo esses procedimentos continua persistindo o mesmo erro

https://stackoverflow.com/questions/43900104/ionic-3-cli-ionic-cordova-run-android-command-throws-an-error

É pouca informação. Cole não apenas essa mensagem de erro, cole tudo que aparece no seu terminal. Isso não me ajudará apenas, mas ajudará todos aqueles que tentarem te ajudar no fórum.

desde a execução até o erro

windows:aluraCar alexander$ ionic cordova build android
Running app-scripts build: --platform android --target cordova
[16:05:10]  build dev started ... 
[16:05:10]  clean started ... 
[16:05:10]  clean finished in 3 ms 
[16:05:10]  copy started ... 
[16:05:11]  deeplinks started ... 
[16:05:11]  deeplinks finished in 104 ms 
[16:05:11]  transpile started ... 
[16:05:27]  transpile finished in 16.52 s 
[16:05:27]  preprocess started ... 
[16:05:27]  preprocess finished in less than 1 ms 
[16:05:27]  webpack started ... 
[16:05:28]  copy finished in 17.61 s 
[16:05:44]  webpack finished in 16.24 s 
[16:05:44]  sass started ... 
[16:05:47]  sass finished in 3.05 s 
[16:05:47]  postprocess started ... 
[16:05:47]  postprocess finished in 130 ms 
[16:05:47]  lint started ... 
[16:05:47]  build dev finished in 37.03 s 
> cordova build android
TypeError: ts.forEachTrailingCommentRange is not a function
    at /Users/alexander/Desktop/Ionic/aluraCar/node_modules/tslint/lib/rules/noUnusedVariableRule.js:205:20
    at iterate (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/tsutils/util/util.js:345:20)
    at Array.forEach (<anonymous>)
    at iterate (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/tsutils/util/util.js:347:50)
    at Object.forEachToken (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/tsutils/util/util.js:348:7)
    at removeAll (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/tslint/lib/rules/noUnusedVariableRule.js:204:19)
    at /Users/alexander/Desktop/Ionic/aluraCar/node_modules/tslint/lib/rules/noUnusedVariableRule.js:159:13
    at /Users/alexander/Desktop/Ionic/aluraCar/node_modules/tslint/lib/rules/noUnusedVariableRule.js:287:23
    at visitEachNode (/Users/alexander/Desktop/Ionic/aluraCar/node_modules/typescript/lib/typescript.js:8338:30)
ANDROID_HOME=/Users/alexander/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
c/aluraCar/node_modules/typescript/lib/typescript.js:8498:24)
Error: spawn EACCES

[ERROR] An error occurred while running cordova build android (exit code 1).

[16:06:24]  lint finished in 36.84 s 
windows:aluraCar alexander$
solução!

eu segui esse o que um forum estava dizendo e funcionou

The issue had to do with the version of gradle i was running. Thank to @rapropos for pointing me in the right direction, I was starting to lose my mind.The key was in the information i posted in the thread below:

Basically what i did was:

1 -Uninstalled Android Studio to remove gradle version was being used to build my app

2 - Reinstalled a new version of Gradle and updated my brew by running: "brew update && brew install gradle"

3 - In my project, i then forced a rebuild of my sass as the 2 were out of sync:" npm rebuild node-sass --force"

4 - Rebuilt the project, by running : "ionic cordova build android"

I hope this solution helps someone else and saves a few hairs in the process!!

link:https://forum.ionicframework.com/t/error-an-error-occurred-while-running-cordova-build-android-exit-code-1/102223/16