I recently switched from Eclipse+ADT to Android Studio. My app is a full native C++ application. I use Android Studio 2.0 Beta 5 and Gradle Experimental 0.6.0-beta4.
The build process of Android Studio is very slow for the native code. I read all questions on Stackoverflow and Internet. I applied all suggested methods (--offline, --daemon, --parallel, -XmxSize, etc..). They mostly addresses to speed up the build of Java code. The compiling process of native C++ files (ndk-build) is still very slow. Even if I write one line C++ code, I wait 5-7 minutes each time I click Run button, where the compiling time of Eclipse was around 15-20 seconds for the same job.
Do you have any suggestion to speed up the compiling process of the native code (C/C++) on Android Studio?
If you're building on linux I've got a hack for you to speed up the NDK build:
cd <ndk-bundle-path>
mv ndk-build ndk-build2
Now create a shell script called "ndk-build" containing the following:
#!/bin/sh
$(dirname $0)/ndk-build2 -j 8 $#
Now set the execute permissions for the new script:
chmod 775 ndk-build
Now, anyone who launch ndk-build (including gradle/android studio) will be force to bang out object files on 8 cores simultaneously. 8 cores is just an example. You must set this to what ever number of cores you have available. If you set it too high compared to the number of available cores you'll usually lose performance. If the CPU have hyper threading you can double the the number of cores.
I am sure there is a equivalent way of doing it on windows with a batch script or something but I don't have a windows machine available atm.
I will give an answer to my old question to close it.
In the end of the story, we integrated cmake into the project. It works as fast as old Eclipse build performance.
Related
we've a giant library consisting of millions lines of code, it is targeted for iOS and Android.
On iOS linking is super fast, several seconds.
On Android using the latest NDK to this date, it's by a factor slower, takes about 4 minutes on the same machine.
Note: I'm on macOS Mojave
When I checked NDK's ld on activity monitor it showed that it uses a single thread.
Is there a way to get it to use multithreading? (Hoping for a meaningful speed boost)
Note that we use CMake with a ninja generator.
Hmm I found the following in the January r21 release of the NDK release notes:
LLD is now available for testing.
AOSP is in the process of switching to using LLD by default and the NDK will follow (timeline unknown).
Test LLD in your app by passing -fuse-ld=lld when linking
Source: https://developer.android.com/ndk/downloads/revision_history
I confirm that LLD used 9 threads on my MacBook Pro (2.9Ghz Core i7 CPU)
Linkage that used to take 4+ minutes takes less than a minute, awesome!
Hi titanium team / Experts,
I'm using Titanium and I look for a way to make my app build faster so it won't take so long to test it every time. Even when I run it twice without adding anything, it takes about 2 minutes to build and 15 more seconds to install on my device.
I think the key is in "Forcing rebuild: JavaScript files need to be re-encrypted". Is there a way to avoid this rebuilding?
The development is being done under mac machine
Rebuilding application can, depending on your mac specs, take 2 minutes indeed. A much faster way of developing is using LiveView or TiShadow (if you're using open source tools). Both methods don't need re-compiling but will only recompile files that need recompiling.
Be aware both methods do not fully clean the app when restarted/rebuilding, things like event listeners, collections and models can cause issues. So every now and then an actual restart is required, and sometimes bugs can appear that only appear during liveview development. But mostly, especially for UI improvements these methods greatly increase development speed.
There are a few ways to speed up your builds. Some of which is described here: https://wiki.appcelerator.org/pages/viewpage.action?pageId=29002843
However I also discuss some other methods.
TiShadow
Consider using TiShadow. It can simultaneously live deploy and test across multiple real devices using any OS for development. I've used it for some time, and it's AMAZING! Don't understand how anyone uses Titanium without it
Use ccache
The Android NDK r7, required by V8 and Titanium Mobile 1.8+, can use ccache, a tool for reusing cached C/C++ compilations. We get huge improvements in build time with it.
Install HomeBrew if you don't have it installed already
Install ccache with the following command: brew install ccache
Set an environment variable NDK_CCACHE to point to it. Installed with HomeBrew, the command would be: export NDK_CCACHE=/usr/local/bin/ccache
Parallelize Compiling
The NDK can also parallelize while compiling, which can speed up the process.
Determine how many cores your machine has. You can use this command on Mac OSX: system_profiler | grep -i "Number Of Cores"
Multiply the above number by 2. So if the above command returned Number of Cores: 2, then your value should be 4.
Set an environment variable NUM_CPUS equal to the above value. In this case: export NUM_CPUS=4
Don't Build the Docs on Every Compile
Skip building the JSCA files (the files used by Titanium Studio's code assist feature). You don't need them if you're just making a build for yourself for testing. To skip, run scons like this:
scons build_jsca=0
Live View
Live view reduces the need to recompile as is decribed here: https://wiki.appcelerator.org/display/guides2/LiveView
Speed Up Emulator
Although this doesn't really speed up your build time, speeding up your emulator helps speed up run-time a lot. Some methods are described here: https://gist.github.com/adam-lynch/7247983
GenyMotion is also a much faster emulator I have been told. Haven't tried it myself.
I have a lib that is derived from webRTC. I can build it from the command line. It takes an acceptable time.
I'm now trying to use the NDK plugin of eclipse to be able to debug it.
The problem is that it takes too long to build it. It takes about 1 min per file. If there isn't a way to make it faster it would be unusable.
I'm running Eclipse on Windows. I added Cygwin for the native code.
Is this normal? Has anyone used the NDK plugin on Eclipse running on Linux? Is it so slow on Linux too? Is there something I should do to speed up the compilation?
I tried on Ubuntu and it is faster. I used the ADT bundle for x86_64.
I need to start building an Android app that uses the JUCE libraries. I'm reading the web site and trying to figure stuff out.
I tried installing JUCE on an Ubuntu 11.04 system, and when I built the IntroJucer app, the menus don't work right (they flash open when I click with the mouse but then disappear). Can a JUCE app for Android be built on Mac OS X, or even Windows?
If you are using JUCE to build Android apps, please give me any advice you can.
Yes, a Juce app can be written for Android using either OS X (XCode 4) or Windows (Microsoft Visual Studio 2008 and higher). You also have the option of using the Eclipse IDE on either platform.
At the time you posted, Juce was undergoing a major overhaul and the IntroJucer might not have been as stable as it needed to be, especially on systems other than OS X or Windows. You should look into it again. IntroJucer is not required to build a Juce Application (although it can make things easier).
I suggest you first build the Juce Demo application for your platform. If Ubuntu is giving you trouble, try OS X or Windows first. Once you have the Juce Demo running you can move on to IntroJucer. If that works, then try compiling Juce Demo for Android. Your questions can be answered in the Android Juce Forum:
http://rawmaterialsoftware.com/viewforum.php?f=13
Here is what I have figured out now that I have been working with this stuff for a bit.
All of this is based on the most recent "stable" release of JUCE, which is about ten months old as I write this. It is quite possible that things have changed (for the better!) in more bleeding-edge releases of JUCE, and when I get a chance I will try a newer JUCE.
The best platform is Mac OS X. When I tried Linux I had some issues with Eclipse not working; I still prefer Linux so I'm going to go back and try again, but on Windows and Mac I had no Eclipse troubles.
Start by installing the Android SDK, and running the updater to grab all the updates. Also install the Android NDK, and Eclipse. In Eclipse, install the ADT plugin.
JUCE sets up an Ant build file that will build all the C++ code for you, automatically. You need to not mess with this. I had a problem where there was a task called "setup" and Ant didn't know how to resolve it; the solution was to delete the "setup" task and not touch anything else. When I was trying to figure out how to solve this issue, I found suggestions here on StackOverflow to run this command: android update project --path . DO NOT DO THIS for JUCE. This re-writes your build.xml file and the special JUCE stuff to build the C++ code disappears; then you build and you get a tiny .APK file (about 10 KB) that contains only the Java setup code and no compiled C++, and does not work. So, just to be clear, the solution to the "setup" build problem is to delete that build task and touch nothing else, and not to completely replace your build.xml file.
The JUCE build process relies on a Bash shell script to do some work. On Mac OS X this works great; on Windows, the build fails with an error from CreateProcess() because CreateProcess() doesn't understand Bash shell scripts. It should be possible to edit this and make it work, but out of the box it works perfectly on Mac OS X.
For testing your code on an Android device, you must sign your code. Eclipse makes it easy to build either signed or unsigned .APK file, but the unsigned file is nearly useless. The only thing you can do with an unsigned .APK is run it in the emulator.
Once I had all the above stuff correct, I had no problems with building the JUCE app for Android.
What are the minimal steps necessary (including retrieving the source code) to compile and run just the Dalvik virtual machine on Linux?
Actually , I got Dalvik working on my elementary OS installation.
First download the Android AOSP source tree using https://source.android.com/source/downloading.html. Wait for it to download (2 hours for me cloning only the current commits and Marshmallow branch)
After running build/envsetup.sh while in the source tree run lunch full_x86-eng. Then type make -jN (replace N with number of cores).
WAIT. This took me about 1 hour on an AMD-4500M laptop. Newer ccomputers may be as low as half and hour and older ones might take half a day.
Change directory to !!AOSP-PATH!!/out/host/linux-x86/bin/ and run export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:!!AOSP-PATH!!/out/host/linux-x86/obj/lib/ or
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:!!AOSP-PATH!!/out/host/linux-x86/lib
or export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:!!AOSP-PATH!!/out/host/linux-x86/lib64
TRY ALL OF THESE
and then
./dalvikvm --32. If you try to run without the --32 option it will crash (don't know why)
Working Marshmallow Dalvik. To get the GUI apps working you will need to do some more porting and coding which is another project which I am working on.
Took me half a day to figure this out.
References
http://milk.com/kodebase/dalvik-docs-mirror/docs/hello-world.html
Use sabayon Linux. This is a distro that can natively run Android programs and all Linux ones too.
Actually, that's rather android running on Dalvik and the underlying system is already linux.
I guess running a bare Dalvik VM on a desktop linux box is just a matter of getting the sources and compile it.
The GUI stuff is something else.
You are not the only one with this idea, and that is great in internet society terms.
This is probably what you are looking for: http://www.android-x86.org/.
Those guys ported android over to x86.
It still works as an OS, so I'm not sure if you can run Linux and Android(Linux) together without using VirtualBox.
Dalvik runs on Android. The authors of Dalvik are only worrying about it running on Android, as far as we are aware.
Various groups have indicated they are working on getting Dalvik outside of Android. You are probably best off finding and talking to them.
In other words, there are no official instructions of the type you seek.
Sorry!
Getting apps designed for Android to run on Linux is going to be tricky. However, it is possible to run a Dalvik VM on Linux. In fact, this GitHub project has a pre-compiled binary of Dalvik VM for Linux, ready to use! Check the associated blog post for information about how the binary was compiled and how to use it.
Learn to program Java \ C \ C++ and other frameworks
Modify the Android source (I think app_process or something) so it shows a windows on the Linux desktop (learn X11 / Wayland APIs)
Below is a simpile base for you to start with
www.android-x86.org/getsourcecode
Getting Android-x86 source code
First, follow this page to configure your build environment. Then
mkdir android-x86
cd android-x86
repo init -u git.android-x86.org/manifest -b $branch
repo sync
Where $branch is any branch name described in the previous section. This will point the projects created or modified by android-x86 to our git server. All the other projects still point to AOSP.
We also have a git mirror server on SourceForge.net. To use it, you only need to change the repo init command to
repo init -u git.code.sf.net/p/android-x86/manifest -b $branch