15
votes

I've been developing an app for 6 months now. I've never tested it on a device, always in browser, but it's gotten to the point where I want to test on my android phone.

So I do ionic cordova run android --device and I get an error:

Error: Failed to transpile program at BuildError.Error (native) at new BuildError (C:\xampp\htdocs\project x\projectx\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28) at C:\xampp\htdocs\project x\projectx\node_modules\@ionic\app-scripts\dist\transpile.js:159:20 at transpileWorker (C:\xampp\htdocs\project x\projectx\node_modules\@ionic\app-scripts\dist\transpile.js:107:12) at Object.transpile (C:\xampp\htdocs\project x\projectx\node_modules\@ionic\app-scripts\dist\transpile.js:64:12) at C:\xampp\htdocs\project x\projectx\node_modules\@ionic\app-scripts\dist\build.js:109:82 [18:05:02] copy finished in 4.95 s

which I can't seem to fix.

I was curious if it was perhaps a problem with my machine, or phone, or something so I created a new ionic project by doing ionic start ionic-test and then simply running it again with ionic cordova run android --device, and this time it worked perfectly. It ran on my device.

So considering that, can I simply paste over my src files into the new project? or is there something else I can do to get this working? Any ideas/tips? Thanks!

Edit:

Here is a pastebin to the entire result of ionic cordova run android --device. https://pastebin.com/x1zX5U1e (note: there were about 200 code warnings from typescript but they were all very minor stuff)

And here is a pastebin for ionic info

https://pastebin.com/A628WpAW

Edit 2: I found the solution. I will be posting a detailed answer soon!

2
can you please post the full code of your post.ts component? - Leonardo Gabriel
Looks like the error occurs with firebase. Could you please specify which firebase services you are using? - J. Hesters
Is all good at C:/xampp/htdocs/project x/projectx/node_modules/firebase/index? Can you check post what is there. Seems like the issue is related to firebase node module in your error - Tarun Lalwani
@TarunLalwani I don't think it is. That's just a warning I'm getting.. I have a lot of warnings not related to firebase. It's stuff like: 'ViewChild' is declared but never used. do you really think it's a firebase problem? - Simon

2 Answers

7
votes

Okay, so I struggled with this for over a month, and I finally realized my issue was actually stupidly simple.

What I found was that even though my application compiled using ionic serve with the "warnings" it had, the application couldn't be built on a phone without removing those "warnings". I had something like over 40 warnings, and getting rid of them all took a few hours but afterwards ionic cordova run android --device worked perfectly.

So if you are having this problem: look at the typescript errors you have and fix them. Your problem should be fixed.

0
votes

This problem might also occur due to unintended imports. Make sure you check all your imports are right. If you remove all unused imports than the problem will automatically be solved.