Andriod Studio - Building times are over 8 minutes compared to XCode's ~1-2m


#1

Hello people,

I am trying to setup a TravisCI script to compile the Android version of my app given that a git tag is pushed.

The problem is that in its current settings it takes around 10 minutes to compile something that takes less than 2 minutes in XCode (this includes the compilation of Cocos2D-x itself).

I have tried to find any settings that changes the threading when compiling but I am clueless on how Gradle and Android Studio works.

How do I debug if there’s a flag that isn’t set properly? I could see a line that supposedly appends the flag -jN to the compiler arguments in app/build.gradle, and I know that flag should tell clang/gcc how many threads to run on. Or is compiling for Android just that much slower? It is the JNI/NDK parts that take forever, of course. The C++.

Thanks for reading!


#2

Ussualy it takes time to first time compile android, if u keeping source code of project in same place and not changing android.mk application.mk and not changing branches then second compile should be much faster on android, same goes to ios


#3

No, it isn’t the same on iOS. Me cleaning the project in XCode, which means recompling Cocos2D-x and my own code, still lands at around ~2 minutes. Doing the same on Android takes much, much longer (10m 20s last night, for just one ABI), and won’t be feasible for testing or building unless I explicitly only build Android on releases. If I configure TravisCI to keep a cache I might run into other issues too. They’re supposed to be clean builds.

I did Google and search for a solution but didn’t find one, but I did find that other people also have the same experience when it comes to the Android NDK.

I’m going to use fastlane to build, package and deploy whenever a git tag is deployed, but I’d still want to build the latest master branch and run tests, whenever possible. And it’s this stage that might become infeasible.


#4

are u compiling thru: cocos compile -p android -j 4 --android-studio -m release command? regarding ios version it’s really fast, actually I’m not sure if cache is bad or not - we didnt had issue with it, but we using teamcity.


#5

With the release of Android 3.0.0 and when cocos 3.17 comes out, you should be able to compile from android studio, which in my opinion is the best way to do it right now.

the cocos console isn’t really supported that well and has a lot of deprecated code. it still uses ant to compile some things. When android and since moved to gradle

You can do this now if you clone cocos2d-x from github


#6

@mozartalouis is correct. In v3.17 command-line development will be deprecated. No more command-line, Eclipse or Visual Studio projects. Android Studio will be the preferred way to build apps.


#7

I’m not compiling through the CLI since when I tried the last time it said it was deprecated (I ran cocos run ..., though).

iOS is fast, that is not the problem. The problem is the Android version.

And by saying Android-Studio you actually mean Gradle, because you CAN compile without Android Studio. I really can’t stand Android Studio, so I do the coding in XCode and then I will simply use gradle to build the Android versions (or in this fast, fastlane on TravisCI)


#8

sure, sure. To be clear gradle without Android Studio required or for those that prefer an IDE Android Studio, itself, of course.


#9

True, It’s using gradle so you technically don’t need Android Studio, But you’ll probably need to install it anyways to get all build tools easily at least.

The main reason to use Android Studio is to debug on Android Devices and It’s the most cross platform IDE among Mac, Linux, and Windows & depending on if your trying to support multiple abi’s or not, Android Studio 3.0 will build in context of the device. This means that if I’m using my Google Pixel 2 to debug, It will only build arm64-v8a and not armeabi-v7a | x86 along with it.

While I do know the struggle of Android Studio (Or any IDE from Jetbrains because they all use the slow a** JVM), It’s not to bad if you have a Good system :wink:


#10

Ten minutes is pretty good for Android Studio/Gradle.
My project can take half-an-hour or more for a full, clean build.


#11

I have 2 flavors, 4 ABIs, debug and release -> 45-50 minutes with clean build


#12

I just prefer Emacs whenever I can stick to it. The problem is that developing in Emacs on OSX is a pain because I’d have to adjust all my hotkeys and bindings I already learned, which by now is in my bone marrow as one says in Sweden haha. So I use XCode, as I use that for my main employment anyway. But if I could get a nice debugging workflow going through Emacs and Gradle alone, I’d love that. But since Google deprecated the adb CLI (because they did, right?) I’m stuck on XCode for now. Even rebuilds are a bit too slow in Gradle I think.

But okay, I guess I’ll just have to stick to XCode.

Which four ABIs are these? I know armeabi is deprecated, but which ones should one build to allow all devices?


#13

Oh, I see I made a mistake. My JNI build was

APP_ABI := armeabi armeabi-v7a arm64-v8a x86

but my build.gradle has the setup

abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'

So I can remove armeabi from the JNI build, which will increase my build time :wink:


#14

Don’t you mean decrease? Haha


#15

Sorry, it was 7:30pm in Germany and the working day was hard. You’re right.