Ionic cordova run/build android fails after first build

I made some changes on controllers and providers and from ionic serve it is working great! but now when i do ionic cordova run/build android the apk did not start. it compile and build the apk and installs it but it crashes at first try to open…

This is the crash report…

java.lang.RuntimeException: Unable to start activity ComponentInfo{ionicionic.app/ionicionic.app.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:360)
at android.content.res.MiuiResources.getText(MiuiResources.java:97)
at android.content.res.Resources.getString(Resources.java:453)
at android.content.Context.getString(Context.java:587)
at com.ionicframework.deploy.IonicDeploy.getStringResourceByName(IonicDeploy.java:141)
at com.ionicframework.deploy.IonicDeploy.initialize(IonicDeploy.java:170)
at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:57)
at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171)
at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:97)
at org.apache.cordova.PluginManager.init(PluginManager.java:86)
at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:117)
at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:149)
at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:224)
at mentorme.app.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:7224)
at android.app.Activity.performCreate(Activity.java:7213)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
… 11 more

The super wierd thing is that if I remove the android platform ionic cordova platform rm android and then build the app again. It works but only the fist build, if I run a second ionic cordova run/build android no code changes It crashes

Can you try with reinstalling the platform?

ionic cordova platform rm android
ionic cordova platform add android

I think I explain that in the issue.

I need to remove the android platform in order to build and only the first build works.
If I run ionic cordova run android or ionic cordova build android for the second time it breaks the apk.

So my only workaround right now is to reinstall the platform every time I need to build the apk

Ok then, could you able to get from which cordova plugin it is breaking the apk build?

I remove all the non-essential plugins but still breaks…

ionic cordova plugin list  
> cordova plugin ls
cordova-plugin-camera 3.0.0 "Camera"
cordova-plugin-device 1.1.7 "Device"
cordova-plugin-ionic 3.1.2 "IonicCordova"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Tomorrow will remove the camera.

Nope removed the camera and still have crash app when build without reinstalling the android platform before.

ionic cordova plugin list

cordova plugin ls
cordova-plugin-device 1.1.7 “Device”
cordova-plugin-ionic 3.1.2 “IonicCordova”
cordova-plugin-splashscreen 5.0.2 “Splashscreen”
cordova-plugin-statusbar 2.4.2 “StatusBar”
cordova-plugin-whitelist 1.3.3 “Whitelist”
ionic-plugin-keyboard 2.2.1 “Keyboard”

BTW this is my ionic info

Ionic:

ionic (Ionic CLI) : 4.12.0
Ionic Framework : ionic-angular 3.5.0
@ionic/app-scripts : 3.2.1

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic 3.1.2, (and 5 other plugins)

System:

Android SDK Tools : 26.1.1
NodeJS : v11.6.0
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.1 Build version 10B61

You can also try: cordova clean android

I solve my problem creating a new ionic v3 blank

ionic start Ionic3Project blank --type=ionic-angular

Then move all the project folders except plugins (css, www, img, src, resources), also use my old config.xml (the one who had all the plugins info).

Then add the platforms.

All the plugings works good, I have had to upgrade some plugins versions since the angular core is newer in the latest ionic v3 template but then it works at any build/run.

Thank you all who watch and reply!
This forum Rocks!

Hi @Dsousa. Just googled your post when I ran into the same behaviour. It occured to me that my app wasn’t just running on my phone, but actually installed. And as it turns out, Android won’t let you install another app with the same name (sideloaded as we do).

The proper solution is to go into settings -> Apps & Software and uninstall your App. You may have to check your config.xml to remind yourself of what the name is. Since I was in the middle of development, mine was still called MyApp! So, I went in and found (2 as it happens) apps of that and similar names and zapped them. Subsequent run worked fine! Might save a few hours next time this happens!