I have been working on android from some time. Since starting i have searching ways of make the grade efficient and fast. i went through many post and i find many solution. which i am listing here.
After building first time switch to offline mode.
make parallel exception check in grade compiler option.
use Dexoption to increase the heap size.
I am looking for if is any other thing which can help reducing the gradle time.
A. what are the other option which can be used in gradle to make is efficient and fast. ( i am looking for both gradle normal and experimental plugin - as dexoption are not available in experimental plugin)?
B. Is there any drawback of the instant run on the build time introduced in studio 2.0?
C. Which is the gradle plugin version best for android 2.0?
D. Any other thing which we can implement in code or in script to decrease the build time and run time?
If you have:
Android Studio 2.0+
Gradle 2.0+
minSDK API 15 (Android 4.0) declaration in your app
your device is API21+
then you should be able to use Android Instant Run feature.
As described here app are building almost instantly in most cases. There are 3 running modes available: hot swap, warm swap and cold swap.
Building speed depends of code change scope.
Related
I want to add new plugin to my android project, but I want to know its build speed impact.
How to test this impact correctly?
For example: I should disable caches or may be there is some instruments available for such operations
I ran build with --no-build-cache --rerun-tasks flags, but always get different durations. Around 2 minutes +- 20 seconds. I should probable disable incremental compilation too, but I don't know how to do it.
To test build speed impact you can use gradle-profiler by gradle.
It is a tool to automate the gathering of profiling and benchmarking information for Gradle builds.
It can doo all fancy statistics and other interesting things regarding profiling. You can simply launch it for any task, and it will run multiple builds and calculate avarages.
Do this without plugin in question and with it. After that, just compare the numbers.
Or you can use simpler alternative. gradlew --profile --offline --rerun-tasks assembleFlavorDebug then in build/reports/profile/ you will find the report
I'm currently working on a project and it take up to 1 min for Android Studio to build it. Yesterday I was working without Internet connection and it turned out that it needed only 30s for AS to buid the project.
What is the reason? Does it mean that the building process check something online each time it builds? Is there any way to change that?
My project has 2 submodules and I would avoid them to be built each time I build the project as nothing as changed. Is there a way to do that?
Best way to speed up ,is to use instant run feature and make sure you have Android Studio 2.3 and higher to support this feature.
Follow this link to you instant run
https://developer.android.com/studio/run/index.html
When I am compiling with Kotlin's puglin, I always have to run the project twice if I make a change, Android Studio does not recognize the change until it runs the project twice, Insnat Run its off and this continues happening
If you use kotlin and retrolambda this might fix it:
me.tatarka:gradle-retrolambda:3.4.0
https://stackoverflow.com/a/41076056/7861527
If you're not using the latest Kotlin plug-in version (1.1.2-5 as of now) and/or Android Studio's latest stable version (2.3.3 as of now), then disabling Android Studio's Instant Run feature may not be able to fix this problem even though it's one of the most common solutions (based on blogs, SO posts here, and etc.) for properly running configuration changes to an app. Android Studio, particularly its alpha/beta versions (Alpha 4 as of now), are obviously bound to have buggy features, and the configuration-change bug could be one of them.
I have an Android app source code which uses
1 Android SDK (Obviously)
2 Robolectric (for unit tests)
3 Gradle (for build process)
The problem encounter while trying to use the other build process is that I'm required go into my repo and fetch the Android SDK every time and extract it. Then, clean and run my tests and jacocoTestReport. This takes time not due to the number of tests but, due to the amount of time spent fetching Android SDK and extracting. On my local machine, I can use Jenkins with Android plugin.
My question:
Am I doing it right?
Is there an easier way around this to reduce the build time so that I can put a POST hook over my repo for it to run better (Only take up time required to run tests and reports).
Codeship doesn't support Android in this moment. But I think they are working on it
With CodeShip Pro you can utilize an Android Docker image to do builds, but this is not officially supported.
https://documentation.codeship.com/general/about/mobile-support/
When we first started developing for android, we had 2 projects:
One for the 'core' functionality, other for the 'business' functionality.
So far so good, we went through bad times waiting so much time for compilation of XML changes, but life was still quite bearable.
After some time, we evolved (or not) to come with 9 projects. For some projects, we have a 'test' project.
We also have some library projects, for instance, we have two different projects for different versions of android, and we have a 'shared' project for shared configs or controllers.
The reason for that is because our application is quite big.
When we make some changes on the core project, we usually have to recompile, and 'clean' the workspace with eclipse. Also, we usually have to use the 'Build Project' option a few times for the projects to update their references, the first build hardly compiles everything, we call this in our team 'COMBO', which is the combination of 'F5' and 'CTRL+B' to compile the projects.
All this setup is killing a lot of time and making developers sad, like, a team of 6 developers :(
I know that by this time we should pretty much know all the issues and the best options, but I can't believe the way it is. And after so many time searching and trying to improve, we can't seem to find other solutions to improve development time with android.
Our set of tools is:
Eclipse 4.2.1
ADT 21.1.0
Eclipse Colour Themes (for a cute code)
SDK always updated
Hardware:
Windows 7 Professional 64 bits
8 GB RAM
Intel Core i5-3470 3.20GHz
I would love answers about:
Compilation time improvement: Did you found any IDE that for YOU it was faster than eclipse? Why? How was the setup? What are the drawbacks of using ADT and how can I improve performance with it, while using multiple projects?
Project references management, is there any suggestion on how
to speed up build? Should I put the whole source code in a single project?
Any way to speed up development when you have the device and need to deploy it while testing the application?
Try Intellij.
In the latest version, 12, they made project build improvements that make it much faster than 11 and Eclipse.
Parallelization
Note also the third column, called Parallelized. This
is a new compiler option which allows you to use more than one core
for building a project. In this case the compiler runs for multiple
independent project modules in parallel. Since each compiler thread
uses file system, the benefit of parallelizing highly depends on how
fast you hard drive is. Still the average gain in performance is
spread between 10 and 20 percent for large projects.
Automatic Make
One more exciting compiler option added in IntelliJ
IDEA 12 is automatic make. This is another time-saver, which triggers
project make automatically on every change. Since the compiler runs in
a separate process, it is able to compile modified files in the
background, while you are doing something else. This means your
project is in compiled state all the time, so you don’t need to wait
any time you want to run it.
http://blogs.jetbrains.com/idea/tag/brand-new-compiler/
Also if you are using git for version control I have noticed Intellij is much better at updating after I switch branches. It integrates well with git and notices that you switched branches and refreshes and cleans out the project in the background automatically, while on Eclipse you might have to refresh and clean manually.