cordova emulate android

47 views
Skip to first unread message

Adam Fellon

unread,
Sep 14, 2016, 5:59:42 PM9/14/16
to phonegap
I inherited an old ionic/cordova application.  It is running and...@3.7.1

After bootstrapping and getting the build ios and emulate ios working I moved to android.

When I prepare, build then emulate android I don't see my changes to the app's JS that I made.  I went in and checked the platforms/android/assets/www/js folder and could see my changes there so the part of the build that copies them over there must have worked, but when I run the emulator and use chrome inspector looking at the resource files I don't see my changes.

I've gone down roads of , cordova platform remove andriod  and then added it back in and didn't see a change.

Also the inspector shows 'android_assets/www' as the resource folder when i try and go in and add breakpoints in the JS etc.  That folder doesn't exist as far as I know...is it a temporary folder or something.

Thanks!

Kerri Shotts

unread,
Sep 15, 2016, 8:43:49 AM9/15/16
to phonegap
Thoughts:

1. Upgrade to the most recent version of cordova-android. IIRC you'll have to be at least 4.x to submit to the play market, but I'd suggest being as recent as possible.

2. In what folder are you making changes before running prepare?

3. What version of the PhoneGap/Cordova CLI do you have installed?

Adam Fellon

unread,
Sep 15, 2016, 10:37:08 AM9/15/16
to phonegap
Thanks for the reply.

1.  In the process of updating to >4.1.1 (and this is part of the reason I was asked to look at it).  When I made the upgrade to 5.0.0 I actually saw a JS change (once!).  I was excited because I had read that others had success with cordova platform rm android && cordova platform add android. (think this has something to do with it creating a new project?).  After that first build those all subsequent builds didn't show updated JS changes :(

2. changes for this are being done @ projectroot/www/js/controllers/AppCtrl.js, does it matter where i run the prepare?  I'm running that in the project root.

3. cordova -v, results w/ 6.3.1, phonegap -v 6.3.0

Kerri Shotts

unread,
Sep 16, 2016, 12:02:18 PM9/16/16
to phonegap
See inline.

On Thursday, September 15, 2016 at 9:37:08 AM UTC-5, Adam Fellon wrote:
> Thanks for the reply.
>
> 1.  In the process of updating to >4.1.1 (and this is part of the reason I was asked to look at it).  When I made the upgrade to 5.0.0 I actually saw a JS change (once!).  I was excited because I had read that others had success with cordova platform rm android && cordova platform add android. (think this has something to do with it creating a new project?).  After that first build those all subsequent builds didn't show updated JS changes :(
>

After you build, check the contents of the generated APK. Does the APK show your changes? (I'm guessing not, but I want to be certain.)

Sometimes the platform configurations get mucked up. An rm & add just nukes the platform and reinstalls it, which can help in that situation.

>
> 2. changes for this are being done @ projectroot/www/js/controllers/AppCtrl.js, does it matter where i run the prepare?  I'm running that in the project root.
>

Cordova CLI commands are smart enough to figure out where the project root is, so it doesn't matter where you run the command from (as long as you're within the project structure).

I'm curious -- does this app have a build step? For example, my apps that use modern JavaScript need to be transformed using Babel during a build step. Usually my original source lives in project-root/src and then the build step transforms it into project-root/www.


>
> 3. cordova -v, results w/ 6.3.1, phonegap -v 6.3.0

What OS are you running on your dev machine?

Also, what version of Node & NPM do you have installed?

Finally, what commands, exactly, are you using to run the app on your emulator after you've made changes to your code?


Adam Fellon

unread,
Sep 16, 2016, 3:21:06 PM9/16/16
to phonegap
Not 100% sure how to verify the apks are being built/used correctly too be honest:

APK output from my build/emulate commands:

build output
Built the following apk(s): 
build/outputs/apk/android-debug.apk

emulate output
Built the following apk(s): 
/Users/afellon/repos/pre_nearby_removal_working/platforms/android/ant-build/MainActivity-debug.apk
/Users/afellon/repos/pre_nearby_removal_working/platforms/android/build/outputs/apk/android-debug.apk
Using apk: /Users/afellon/repos/pre_nearby_removal_working/platforms/android/ant-build/MainActivity-debug.apk

I'm using Ionic as well, think that's what why this ant-build is being used...I went in and rm'd the MainActivity.apk and then the next emulate used android-debug.apk.. that would have been great but MainActivity wasn't re-built so I'm not sure 100% what's going on and every other subsequent builds continued to not update.

I don't think there is a build step (there isn't for the currently updating IOS builds).

node -v == v5.10.1, npm == 3.8.3

After code changes I run:

cordova build android, then cordova emulate android.

I have thrown in cordova prepare android prior to both of those at times mostly as a sanity check...no luck on any combination of them.

Thanks again for the help!

Kerri Shotts

unread,
Sep 18, 2016, 5:16:35 PM9/18/16
to phonegap
APKs are just zip files. You can rename them to .zip and decompress them to see what's in them.

I'd check in each APK to see what is getting put inside them. I'm not sure why you'd be getting multiple APKs out of the build step, though... unless you had Crosswalk installed (which will generate an x86 and ARM APK).

It might help to see your config.xml minus identifying/secret information.

On Friday, September 16, 2016 at 2:21:06 PM UTC-5, Adam Fellon wrote:
...

Adam Fellon

unread,
Sep 22, 2016, 3:56:07 PM9/22/16
to phonegap
Sorry for the delayed response.  I was able to rename and open my android-debug.apk file and when viewing it I saw updated assets.  

Maybe it's something with my sdk setup or something that isn't refreshing?

Kerri Shotts

unread,
Sep 26, 2016, 11:03:09 AM9/26/16
to phonegap
If you delete the the app on your device and install the newly built app, do you see the updated content?
Reply all
Reply to author
Forward
0 new messages