A bug appear in prod-apk only


#1

Hi,

I am new to Ionic and learning best practices.

my solution works well by installing the debug-apk version to real android device with ionic cordova run android , but a bug appears in release-apk version after steps of ionic cordova build android --prod --release, upload to google play store, then download to run in the same device.

questions

  1. why does such difference appear?
  2. is it possible, in developing phase, to install the release-apk version to a real android device via adb instead of going through google play store? The reason is question 1 above.
  3. what is the best way to debug release-apk installed through google play store?

br. D


#2

Is --prod or --release causing the problems?
Normally it is --prod that can break and change app behaviour. And that can be tested in development mode without problem…


#3

I simply followed an ionic book to use this command to build release apk, without knowing exactly what they do.
Do you mean --prod or --release can be ignored in the release building action? I will check the meaning of these two argument and see if the issue can be sorted out accordingly.


#4

No, I mean they can be used independently - you can build for dev with --prod to see what happens and if the minimzation etc causes issues. Only then you add --release to build for the store.


#5

good hint!

I can reproduce the error by using ionic cordova build android --prod to create apk and adb install to push the apk to the android device. The error message is:

main.js:1 ERROR Error: Uncaught (in promise): Error: No provider for t!
Error: No provider for t!
    at Error (native)
    at O (file:///android_asset/www/build/main.js:1:6087)
    at T (file:///android_asset/www/build/main.js:1:6346)
    at t._throwOrNull (file:///android_asset/www/build/main.js:3:5428)
    at t._getByKeyDefault (file:///android_asset/www/build/main.js:3:5761)
    at t._getByKey (file:///android_asset/www/build/main.js:3:5146)
    at t.get (file:///android_asset/www/build/main.js:3:3554)
    at e.get [as _Logger_81] (file:///android_asset/www/build/main.js:25:21486)

It looks indeed a minimization issue


#6

Great, now you know what to look for.

I would look at the main.js lines and character positions referenced in the error message to see if I recognize anything. What ever t stands for in your unminified code probably is somehow broken, not imported correctly or something.


#7

Are you on the most recent version of everything? Post your ionic info output.


#9

Eventually the issue is located.
I have had two logging tools, logentries added in index.html and angular2-logger from npm.
Somehow these two conflicts if code is built with --prod.

It’d be nice to know why the issue takes place only in --prod build, but I went with the quick&dirty solution: removing angular2-logger and everything works now.


#10

The build process of --prod does lots of things to the code a normal build does not. Minimizing, optimizing. AOT etc. For that it has to understand it, and it seems the stuff you did it couldn’t understand.

Can you maybe add how you were using these two libraries exactly?


#11

I will try create a narrow test case soonest.


#12

It turns out that the error was caused by using angular2-logger package alone. logentries is irrelevant. I created the narrow case in this repo:

Steps:

  1. ionic start logger-bug blank
  2. npm install --save angular2-logger
  3. add angular2-logger package in app.module.ts provider
  4. add angular2-logger package in home.ts and log a debug message
  5. using ionic cordova run android, the app opens in android device without error
  6. using ionic cordova run android --prod, the app shows promise t error