Strange behavior with "ionic run android"


#1

While trying to run my ionic app on android device, “ionic run android” and “ionic run android -l”, commands show completely different behavior.

ionic run android -l

This runs as expected, splashscreen works just fine and images are displayed where they should. Other cordova plugins like “$cordovaNetwork” work just fine as well.

However, if I run

ionic run android

(notice the missing ‘-l’ argument) on the same app, splashscreen gets stuck at .hide(). Even the images are not rendered and instead image-not-found(that broken screen icon) shows up. So the generated apk is useless.

I know I’m doing something stupid, but can’t figure out what. I’m pulling my hair over this issue, because it doesn’t make any sense. Any help will be greatly appreciated.


Is there a specific way to manage resource for Ionic app?
#2

This is probably a bug.

-l is just a livereload:

The live reload functionality is similar to ionic serve, but instead of developing and debugging an app using a standard browser, the compiled hybrid app itself is watching for any changes to its files and reloading the app when needed. This reduces the requirement to constantly rebuild the app for small changes.

Have you received any error?


#3

Well, I’m pretty sure I’m missing something at my end and its not a bug.

I tried another experiment.

$ ionic build android
$ adb install -r /home/cheema/experiments/flipneeds-android/platforms/android/build/outputs/apk/android-debug.apk

Same result. No images displayed, most plugins like splashscreen, cordovanetwork don’t work as expected.

But without recompiling if I try

$ ionic run android -l

all images come back.

This can’t be a bug, otherwise nobody would be able to generate working apks :smile:


#4

Maybe the solution is
$ ionic run android --target=<device_id>
which device_id from

$ adb devices -l

#5

I would say it’s a bug but one with livereload.

I never had a problem with:

ionic run android

You should also consider that livereload is still in beta. Maybe it caused a problem with a classic building process.
Of course, this is just a wild guess.

From my experience, you’re not the first person asking about this problem. Try looking at previous posts, maybe you stumble on a working solution.


#6

@junaidy - As I mentioned, installing debug apk leads to same result. So definitely, not an issue with target device id.

@Gajotres - There are a whole lot of older threads which point to same issue, but none of them have been solved.



Oh and btw, I’m using ionic-boilerplate. I hope that is not the reason why things are getting messed up.


#7

I think:
Execute this command on terminal " adb kill-server"
Now connect device to system wait, 10-20 seconds.
Execute this command on terminal " adb start-server",
Check device status with "adb devices " command.


#8

If it looks like a duck, if it walks like a duck, if it talks like a duck then it is a fuc**** duck :wink:

I still think it’s a bug hehe. Unfortunately, I don’t know how to help you anymore. This is a question for developers.


#9

So I just tested this using a starter template from out cli

ionic start tmp blank && cd tmp

Added a few images tags

ionic platform add android
ionic run android --device

Everything worked fine for me. @amitoj you mentioned you were using ionic-boilerplate? That’s not the starter templates that come with the ionic cli is it?


#10

@mhartington - I’m using ionic-ng-boilerplate


#11

Not familiar with that, but do you have an issue using the official starter project from our cli?


#12

I’ll restructure my app and let you know if boilerplate was the actual culprit.


#13

I am also having a similar problem did any body figure out a solution?