Ionic build --prod stuck at "copy finished in"


#1

Hello guys,

I’m trying to build an apk file from my project.

I used ionic cordova build android --release --prod to build but it always get stuck at “copy finished in”

I’m using cordova 7.0.0 so I downgraded it to 6.3.0. The result was the same.
I created a brand new ionic project and migrated src folder and re-installed all npm packages. It still gets the same error.

What should I do? I find it to be strange becauseionic lab, ionic cordova run android both work fine. It can build debug apk file and I see no problem with this app on android emulator.

Thanks,


#2

1_ so in your log it’s written “copy finished in…” and then it doesn’t release right?

2_ have you check if all permissions (chown / chmod) are correct for folder .platforms/android/app/build/outputs/apk/release? did you find something there?

3_ don’t ask me why, have you try

 ionic cordova build android --prod --release

instead of

 ionic cordova build android --release --prod

?

4_ have you try cordova-android@7.1.0 (latest)? when you do saw, do you update or remove/add your platform? I suggest remove/add

5_ which cordova cli version are you using? Are you using the last one v8.0.0?


#3

I edited project.properties and it started working!

target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.google.android.gms:play-services-auth:11.+
cordova.system.library.3=com.google.android.gms:play-services-identity:11.+
cordova.system.library.4=com.google.android.gms:play-services-location:11.+

All version numbers were 12… I changed it to 11 and everything works.

I guess there’s some version issue going on with cordova and google play services.


#4

Cool to hear you found the solution :slight_smile:

Yep these versions often lead to incompatibility depending of locale settings and dependencies between plugins, therefore more and more plugins (like push or facebook) allows their users to specify them with a variable at install time


#5

Yes… I can’t believe I spent over three hours with this problem.
I thought there was problem in my coding.
project.properties is in android folder. version 12 seems to be unstable yet. 11.+ will work fine.


#6

If it fails at cordova build time, there is most than probably no error in your coding respectively no compilation errors in your bundle typescript code if you used the flag --prod

three hours, not bad, I could even say that’s quick, I remember having lost all days for such things :wink:


#7

Try this

ionic cordova build android --prod --release

If the problem still exsits try removing the platform and adding it again

ionic cordova platform rm android

ionic cordova platform add android


#8

Here’s my new project.properties file:

target=android-26
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.gradle.include.1=cordova-plugin-googlemaps/projectname-tbxml-android.gradle
cordova.system.library.1=com.google.android.gms:play-services-maps:11.+
cordova.system.library.2=com.google.android.gms:play-services-location:11.+
cordova.system.library.3=com.android.support:support-core-utils:24.1.1+
cordova.system.library.4=com.squareup.okhttp3:okhttp:3+

this problem is happening again… I’m unable to build apk with any command. --release, --prod --release, --aot --minifyjs --minifycss --release all don’t work. They all hang at “copy finished in” …
How can I fix this issue?


#9

found any solution ? I am too facing the same issue and this is so frustrating…


#10

Try to omit --minifyjs

--aot --minifycss --release

will still build a fairly useful build although it’s going to be a little slower on Android.

on iOS, you don’t need --prod build. --release build will still build a fast app.
on Android, you’ll need to minify at least css if --prod doesn’t work. --release build will be take 10 seconds to load.

I think cordova is more unstable on android. on iOS, it works well without this kind of issues although Apple app store is a headache to deal with.

if nothing works, start a brand new project, transplant your src and re-install all plugins and build again.


#11

I started a brand new project, it was building fine, but now i am facing this error Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

I am so tired, i feel like leaving ionic forever.


#12

Do you use firebase? That might be the problem:


#13

I use firebase but angular fire is not included in this project.
firebase provide json urls for my app … and any other server can do the same.

I think the issue is related to android library versions in project.properties file.
No one knows a solution yet


#14

cordova clean android should do the trick.


#15

If you are using angularfire2 for firebase, it seems that you will have to downgrade both angularfire2 and firebase to a “Known working version”

This did the trick for me:

npm i --save firebase@4.12.1
npm i --save angularfire2@5.0.0-rc4

More info at https://github.com/ionic-team/ionic-app-scripts/issues/1422

In your case, this seems to be happening because of a dependency for latest versions of the firebase package, try to use a version prior to 4.13 to get your app working fine.


#16

I solved this by downgrading only my firebase database module

npm uninstall @firebase/database
npm install @firebase/database@0.2.1

now my project build.

Regards


#17

This solves my problem! Thank you!


#18

This solved my issue. Thanks for saving my time.


#19

This solved my problem. Thank you very much!!!


#20

This was related to the firebase library. Thank you !