Error ionic cordova run android --device --prod

When I do this ionic cordova run android --device --prod . The app works fine but some things in the app are not working and I get these errors

vendor.js:1 ERROR TypeError: t.concat is not a function
    at Object.o.getSymbolsInEquation (build/0.js:1)
    at e.exports (build/0.js:1)
    at Object.e.exports [as solveEquation] (build/0.js:1)
    at e._next (build/0.js:1)
    at e.__tryOrUnsub (vendor.js:1)
    at e.next (vendor.js:1)
    at e._next (vendor.js:1)
    at e.next (vendor.js:1)
    at e._next (vendor.js:1)
    at e.next (vendor.js:1)

But when I only run : ionic cordova run android --device

I get no errors

cli packages: (/home/ani/lab/node_modules)

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.6.0

System:

    Android SDK Tools : 26.0.2
    Node              : v7.10.0
    npm               : 4.2.0 
    OS                : Linux 4.10

Please post the whole output of ionic cordova run android --device --prod --verbose

A post was split to a new topic: Error: ./src/pages/amor/amor.ngfactory.js

ai@aim:~/lab$ ionic cordova run android --device --prod --verbose
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/home/ai/lab', local: true, binPath: 
        '/usr/lib/node_modules/ionic/bin/ionic', libPath: 
        '/home/ai/lab/node_modules/ionic/dist/index.js' }
[DEBUG] Loading local plugin @ionic/cli-plugin-proxy
[DEBUG] Latest plugin version of @ionic/cli-plugin-proxy is 1.4.6, according to 
        daemon file.
[DEBUG] Daemon found (pid: 2708)
[INFO] Running app-scripts build: --prod --platform android --target cordova
       
[10:01:34]  build prod started ... 
[10:01:34]  clean started ... 
[10:01:34]  clean finished in 1 ms 
[10:01:34]  copy started ... 
[10:01:34]  ngc started ... 
[10:01:40]  ngc finished in 5.65 s 
[10:01:40]  preprocess started ... 
[10:01:40]  deeplinks started ... 
[10:01:40]  deeplinks finished in 265 ms 
[10:01:40]  optimization started ... 
[10:01:40]  copy finished in 6.03 s 
[10:01:50]  optimization finished in 9.48 s 
[10:01:50]  preprocess finished in 9.75 s 
[10:01:50]  webpack started ... 
[10:02:12]  webpack finished in 22.15 s 
[10:02:12]  sass started ... 
[10:02:12]  uglifyjs started ... 
[10:02:13]  sass finished in 1.21 s 
[10:02:13]  cleancss started ... 
[10:02:14]  cleancss finished in 1.20 s 
[10:02:51]  uglifyjs finished in 39.22 s 
[10:02:51]  postprocess started ... 
[10:02:51]  removed unused font files 
[10:02:51]  postprocess finished in 32 ms 
[10:02:51]  lint started ... 
[10:02:51]  build prod finished in 76.85 s 
> ionic cordova prepare
> cordova prepare
âś” Running command - done!

> cordova run android --device
[10:02:53]  lint finished in 2.20 s 
ANDROID_HOME=/home/ai/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Subproject Path: CordovaLib
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_a87f6dkrfzx0o08dawk4077hs.run(/home/ai/lab/platforms/android/build.gradle:137)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.

Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild
 UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest

:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies

:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets
 UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript
 UP-TO-DATE
:CordovaLib:generateDebugResValues
 UP-TO-DATE
:CordovaLib:generateDebugResources
 UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest
 UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
:CordovaLib:mergeDebugJniLibFolders
 UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib623DebugLibrary UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac UP-TO-DATE
:compileDebugNdk UP-TO-DATE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:transformClassesWithDexForDebug UP-TO-DATE
:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:validateSigningDebug
:packageDebug UP-TO-DATE
:assembleDebug UP-TO-DATE
:cdvBuildDebug UP-TO-DATE

BUILD SUCCESSFUL

Total time: 1.005 secs
Built the following apk(s): 
	/home/ai/lab/platforms/android/build/outputs/apk/android-debug.apk

ANDROID_HOME=/home/ai/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Skipping build...

Built the following apk(s): 
	/home/ai/lab/platforms/android/build/outputs/apk/android-debug.apk

Using apk: /home/ai/lab/platforms/android/build/outputs/apk/android-debug.apk
Package name: se.lab.v
LAUNCH SUCCESS


[OK] Your app has been deployed.
     Did you know you can live-reload changes from your app with --livereload?

It works also when you do this:

ionic cordova build android --release

when I do this :

ionic cordova build android --prod --release

Something is wrong with the --prod flag
I know that it worked in July before all these updates

Ok, build seems fine.

What are you testing? Device and OS version?

TLDR:
–prod basicly is a shortcut for
–aot --minifyjs --minifycss --optimizejs

When I run this it works

ionic cordova run android --device --aot --minifycss --optimizejs --verbose

When I run only this :

ai@aim:~/lab$ ionic cordova run android --device --minifyjs --verbose
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/home/ai/lab', local: true, binPath: 
        '/usr/lib/node_modules/ionic/bin/ionic', libPath: 
        '/home/ai/lab/node_modules/ionic/dist/index.js' }
[DEBUG] Loading local plugin @ionic/cli-plugin-proxy
[DEBUG] Latest plugin version of @ionic/cli-plugin-proxy is 1.4.6, according to 
        daemon file.
[DEBUG] Daemon found (pid: 2708)
[INFO] Running app-scripts build: --minifyjs --platform android --target cordova
       
[16:28:33]  build dev started ... 
[16:28:33]  clean started ... 
[16:28:33]  clean finished in 4 ms 
[16:28:33]  copy started ... 
[16:28:33]  transpile started ... 
[16:28:35]  transpile finished in 2.58 s 
[16:28:35]  preprocess started ... 
[16:28:35]  deeplinks started ... 
[16:28:36]  deeplinks finished in 79 ms 
[16:28:36]  preprocess finished in 80 ms 
[16:28:36]  webpack started ... 
[16:28:36]  copy finished in 2.78 s 
[16:28:47]  webpack finished in 11.40 s 
[16:28:47]  sass started ... 
[16:28:47]  uglifyjs started ... 
Error: Uglify failed: Unexpected token: keyword (const) in undefined at line undefined, col undefined, pos undefined
[DEBUG] Error: Uglify failed: Unexpected token: keyword (const) in undefined at 
        line undefined, col undefined, pos undefined
            at new BuildError 
        (/home/ai/lab/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
            at taskReject 
        (/home/ai/lab/node_modules/@ionic/app-scripts/dist/worker-process.js:36:22)
            at 
        /home/ai/lab/node_modules/@ionic/app-scripts/dist/worker-process.js:14:13

I test on device android

–minifyjs is causing the error

Are you using concat in your code somewhere? Anything special/strange about that code?

I am not using concat in my code.

Search your project for this function. Whereever it is seems to be improperly relying on class names.

1 Like

I use mathsteps library and that function is in the library
It works if I skip --minifyjs
It works when ionic serve

I think your best course of action would be filing an issue on that library referencing this conversation.

Hello! I’m the maintainer of mathsteps

This seems to be the function in question:

I’m confused why it’s fine if not minified, but causes problems if it is minified.

“improperly relying on class names.” was said, but this is purely backend code so there are no class names (unless I’m misinterpreting what you mean)

Would love to help fix if I can! Any ideas?

1 Like

Thanks for chiming in. I looked for a bit and was unable to connect the dots between that function and any of the concat usages, although I guess there’s a chance mathjs gets involved at that point. Maybe you can see some connection that I can’t.

What I meant by that is idioms like obj.constructor.name directly or indirectly. My initial thought was the node Type stuff, but again that seems to be relying on mathjs to set that name property and I didn’t see any relevant bugs on that library involving minification, nor could I figure out how to link it to concat.

What is going on is that the project code is being passed through uglifyjs, which changes class names to arbitrarily short identifiers. Somehow that seems to be breaking something. Perhaps I could say something more given access to an entire cloneable repo that reproduces the issue.

Hmm yeah I am not sure! It’s hard how when minifying it, the helpful variable names go away heh. I’m not super familiar with mathjs codebase so hard to know.

do you think new Set([...leftSymbols, ...rightSymbols]); gets minified into concatenating two lists? I don’t know much about how minifying works so just a random guess

hopefully @physedo can put their code up and we can try to reproduce from there