Ionic cordova run with --prod stuck at splash


#1

When I run ionic cordova run android it works without problems. But when I add --prod the app stucks in the splash screen and the inspector gives an error:

image

I tried deleting the node_modules folder and npm install again, but nothing happended.

The log when I try the run with --prod flag:

ionic cordova run android --prod
> ionic-app-scripts build --prod --target cordova --platform android
[16:25:43]  ionic-app-scripts 3.2.1
[16:25:43]  build prod started ...
[16:25:43]  clean started ...
[16:25:43]  clean finished in 9 ms
[16:25:43]  copy started ...
[16:25:43]  deeplinks started ...
[16:25:43]  deeplinks finished in 145 ms
[16:25:43]  ngc started ...
[16:25:53]  ngc finished in 10.29 s
[16:25:53]  preprocess started ...
[16:25:53]  preprocess finished in 1 ms
[16:25:53]  webpack started ...
[16:25:54]  copy finished in 11.14 s
[16:26:12]  webpack finished in 19.15 s
[16:26:12]  uglify started ...
[16:26:13]  sass started ...
[16:26:15]  sass finished in 2.09 s
[16:26:15]  cleancss started ...
[16:26:16]  cleancss finished in 1.49 s
[16:26:36]  uglify finished in 23.23 s
[16:26:36]  postprocess started ...
[16:26:36]  postprocess finished in 29 ms
[16:26:36]  lint started ...
[16:26:36]  build prod finished in 53.25 s
no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.
[16:26:40]  lint finished in 4.33 s
> cordova run android
Android Studio project detected
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '26.+' to C:\-confidential-\platforms\android\app\build.gradle
cordova-android-support-gradle-release: Wrote custom version '26.+' to C:\-confidential-\platforms\android\cordova-android-support-gradle-release\misegurarse-cordova-android-support-gradle-release.gradle
ANDROID_HOME=C:\Users\-confidential-\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio
:wrapper

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
+-----------------------------------------------------------------
| cordova-android-support-gradle-release: 26.+
+-----------------------------------------------------------------
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_e5m7qse9qotv4n8h0fkeevnhq.run(C:\-confidential-\platforms\android\app\build.gradle:149)
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugAidl
:CordovaLib:compileDebugRenderscript
:CordovaLib:checkDebugManifest
:CordovaLib:generateDebugBuildConfig
:CordovaLib:prepareLintJar
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:platformAttrExtractor
:CordovaLib:processDebugManifest
:CordovaLib:javaPreCompileDebug
:CordovaLib:processDebugJavaRes NO-SOURCE
:app:preBuild UP-TO-DATE
:app:preDebugBuild
:app:compileDebugAidl
:CordovaLib:packageDebugRenderscript NO-SOURCE
:app:compileDebugRenderscript
:app:checkDebugManifest
:app:generateDebugBuildConfig
:app:prepareLintJar
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:createDebugCompatibleScreenManifests
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug
:app:compileDebugNdk NO-SOURCE
:CordovaLib:mergeDebugShaders
:CordovaLib:compileDebugShaders
:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:mergeDebugJniLibFolders
:CordovaLib:transformNativeLibsWithMergeJniLibsForDebug
:CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug
:app:mergeDebugJniLibFolders
:app:processDebugJavaRes NO-SOURCE
:app:validateSigningDebug
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:compileDebugJavaWithJavac
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
:app:processDebugResources
:app:generateDebugSources
:app:javaPreCompileDebug
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\-confidential-\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:compileDebugJavaWithJavac
:app:compileDebugSources
:app:transformClassesWithStackFramesFixerForDebug
:app:transformClassesWithDesugarForDebug
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
:app:transformDexArchiveWithDexMergerForDebug
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:transformResourcesWithMergeJavaResForDebug
:app:packageDebug
:app:assembleDebug
:app:cdvBuildDebug

BUILD SUCCESSFUL in 41s
46 actionable tasks: 46 executed
Built the following apk(s):
        C:\-confidential-\platforms\android\app\build\outputs\apk\debug\app-debug.apk
ANDROID_HOME=C:\Users\-confidential-\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
No target specified, deploying to device '85ZL458H9HROYTSG'.
none
Skipping build...
Built the following apk(s):
        C:\-confidential-\platforms\android\app\build\outputs\apk\debug\app-debug.apk
Using apk: C:\-confidential-\platforms\android\app\build\outputs\apk\debug\app-debug.apk
Package name: -confidential-
LAUNCH SUCCESS

The ionic info:

Ionic:

   ionic (Ionic CLI)  : 4.5.0 (C:\Users\-confidential-\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 11 other plugins)

System:

   Android SDK Tools : 26.1.1 (C:\Users\-confidential-\AppData\Local\Android\Sdk)
   NodeJS            : v10.13.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.4.1
   OS                : Windows 10

package.json

{
  "name": "-confidential-",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/animations": "7.1.0",
    "@angular/common": "^7.0.4",
    "@angular/compiler": "7.1.0",
    "@angular/compiler-cli": "7.1.0",
    "@angular/core": "^7.1.0",
    "@angular/forms": "7.1.0",
    "@angular/http": "7.1.0",
    "@angular/platform-browser": "7.1.0",
    "@angular/platform-browser-dynamic": "7.1.0",
    "@ionic-native/camera": "4.17.0",
    "@ionic-native/core": "4.17.0",
    "@ionic-native/file": "4.17.0",
    "@ionic-native/file-opener": "4.17.0",
    "@ionic-native/http": "4.17.0",
    "@ionic-native/mobile-accessibility": "4.17.0",
    "@ionic-native/network": "4.17.0",
    "@ionic-native/splash-screen": "~4.17.0",
    "@ionic-native/status-bar": "~4.17.0",
    "@ionic-native/toast": "4.17.0",
    "@ionic/pro": "2.0.3",
    "@ionic/storage": "2.2.0",
    "cordova-android": "7.1.4",
    "cordova-android-support-gradle-release": "2.0.1",
    "cordova-plugin-advanced-http": "~2.0.1",
    "cordova-plugin-camera": "~4.0.3",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "6.0.1",
    "cordova-plugin-file-opener2": "2.0.19",
    "cordova-plugin-ionic": "^5.2.7",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^2.2.0",
    "cordova-plugin-network-information": "2.0.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-toast": "2.7.2",
    "ionic-angular": "3.9.2",
    "ionic-native": "^2.9.0",
    "ionicons": "4.4.8",
    "phonegap-plugin-mobile-accessibility": "1.0.5",
    "rxjs": "^6.3.3",
    "rxjs-compat": "^6.3.3",
    "sw-toolbox": "3.6.0",
    "ts-md5": "^1.2.4",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.2.1",
    "typescript": "3.1.6"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-network-information": {},
      "cordova-plugin-file-opener2": {},
      "cordova-plugin-x-toast": {},
      "cordova-plugin-file": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "26.+"
      },
      "cordova-plugin-advanced-http": {},
      "cordova-plugin-camera": {},
      "cordova-android-support-gradle-release": {
        "ANDROID_SUPPORT_VERSION": "26.+"
      },
      "phonegap-plugin-mobile-accessibility": {}
    },
    "platforms": [
      "android"
    ]
  }
}

#2

Disclaimer: I have zero experience with Ionic Pro, and don’t even have the slightest clue what it does, so apologies if this is somehow its responsibility. That being said,

I can’t believe that even built, period. You can’t randomly dump versions of dependencies together into a stew like this. First, decide which version of the Ionic framework you want to use. Ordinarily one would use the ionic start command to generate a skeleton project. That will put a bunch of stuff into a package.json.

DO NOT BUMP ANY DEPENDENCIES THAT IT PUTS IN THERE.

That means no trying to run ionic 3 with Angular 7 (or rxjs 6), like you have here.


#3

I’m such an idiot. That was it, I fixed the dependencies and it worked! Thank you so much!