How to do an android mm clean? - android

I'm building custom module in Android source using the mm command.
When I run mm clean, it seems that the whole project is cleaned.
How can I restrict the clean to just the current module?

Use mm -B, it will rebuild all, equivalent to clean and then make.

Another way to do without mm is to give make clean-<target name> from root of Android source.
Similarly you can build the required module alone with make <target name>

On older make-based AOSP build system, use
mm -B
to rebuild the module.
On newer Ninja+Soong based AOSP build systems, it seems that -B no longer works. It gives the error Unknown option: -B.
One possible alternative is to use the NINJA_ARGS environment variable to pass additional Ninja arguments to underlying build engine.
For example, the following command removes all output and intermediate files:
NINJA_ARGS="-t clean" mm
In this case clean is an extra tool to the Ninja build system. See https://ninja-build.org/manual.html#_extra_tools for other tools.
One thing to notice is that the clean tool seems to clear all the dependencies of the module, instead of the module itself. I haven't found a way to assign a rule to limit the clean scope to the module only.
references: https://android.googlesource.com/platform/build/soong/+/HEAD/docs/best_practices.md

make <lib> 2>&1 | grep -e "install"
This will make the and print all the libs that were re-compiled.

Prefixing "clean-" to the module name will do the clean build in Android
For ex,
m clean-libskia

Related

How to clean a module in AOSP?

This is the same question as previously another one which I found the solution in is invalid.
Because the command mm -B is invalid.
So how could I clean one specific module in AOSP with clean the other part?
how to make clean module in android
$ make clean-<moudlename>
eg: make clean-libxyz (to clean libxyz.so)
https://dolinux.blogspot.com/2012/05/how-to-make-clean-module-in-android.html
or
NINJA_ARGS="-t clean" mm
You cannot do that , we can build a simple module with this command:
mmm “path to build”
but we cannot clean a module with this command. to perform cleaning source , you should use this command:
make clean

Building wpa_supplicant with 'mm' command

I am new to Android. I have the entire source code of Android for the imx platform. I would like to build the wpa_supplicant folder present under external folder. Everytime I make a change, instead of building the entire source, I would like to build only the wpa_supplicant folder. I have read that using the 'mm' command I can do it. However, i am not sure where to find the 'mm' command. For when I type #mm external/wpa_supplicant_8, I get the following error message displayed:
The program 'mm' can be found in the following packages:
* mountmanager
* multimail
Try: apt-get install
I am not sure if I need to do an apt-get install or the binary is present somewhere I else. Can someone help me with this? Also, how do I compile only a single application present in external folder? Please help.
Run the build/envsetup.sh script from your root folder:
path/to/android# . ./build/envsetup.sh
Then lunch for your device, and you'll be able to mm as necessary.
Go to Android directory and run $:source ./build/envsetup.sh
'android$:lunch` and select the configuration which you are building.
Now go to the directory where project located and execute mm or 'mma' (to build the dependencies also)

Spoon with Espresso, Eclipse & Jenkins

call java -jar spoon-runner-1.1.1-jar-with-dependencies.jar
-- apk D:\Workspace\gitrepo\ProjectX\bin\ProjectX.apk
-- test-apk D:\Workspace\gitrepo\ProjectXTest\bin\TestX.apk
I created a folder in my workspace & added spoon runner jar in that folder. Also, I placed spoon client jar in my test project's libs folder. When I'm executing the batch file, nothing happens.
Also, looking for a way to integrate the test report[well, if I can run it] in my Jenkins automated post build email.
If anybody can give a step by step answer it will be really helpful.
Thanks.
If you can, I really recommend moving your project to Android Studio and using the Spoon Gradle plugin. Running spoon with a Gradle setup is much easier.
Try to run directly from command line(I think you have space between "--" and the parameters, try --apk, --apk-test, like the following):
call java -jar spoon-runner-1.1.1-jar-with-dependencies.jar --apk D:\Workspace\gitrepo\ProjectX\bin\ProjectX.apk --test-apk D:\Workspace\gitrepo\ProjectXTest\bin\TestX.apk

AOSP and IntelliJ IDEA

Has anyone tried to work with AOSP using IntelliJ IDEA? I see in Android sources a specific folder (development/ide/intellij) but I cannot find any information how to use it in case of Android development (for Eclipse the information can be found here: http://source.android.com/source/using-eclipse.html) Can anyone provide similar instructions how to start developing Android in IDEA?
Also a good reading here: https://shuhaowu.com/blog/setting_up_intellij_with_aosp_development.html
If you get
Couldn't find idegen.jar. Please run make first.
You'll need to generate it first:
source build/envsetup.sh
cd development/tools/idegen
mm
croot
development/tools/idegen/idegen.sh
Be prepared that AOSP files indexing in IJ takes long time (more than 1 hour on my notebook with an SSD on board), a reason to use Eclipse, as I believe it doesn't need to build indexes so loads AOSP code much faster.
It's worth reducing android.iml file with removing AOSP parts you are not interested in. You can add them to development/tools/idegen/excluded-paths via a regular expression pattern, see README file there.
I added following lines to excluded-paths:
^cts
^developers
^development
^external
.*/tests/.*
^sdk
so my android.iml got quite moderate size and loads in about 1-2 minutes instead.
idegen has also intellij-gen.sh which can generate IJ project for given module.
As mentioned in the article above, you can tweak IJ to work faster (add more RAM, etc). Here goes my idea64.vmoptions just in case:
-server
-Xms2048m
-Xmx4096m
-XX:MaxPermSize=1024M
-XX:ReservedCodeCacheSize=1024M
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:ParallelGCThreads=8
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:CMSIncrementalDutyCycleMin=0
-XX:-TraceClassUnloading
-XX:+TieredCompilation
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
You can google idea.vmoptions optimization, there are some posts about it (and where I took my IJ config from)
From AOSP root folder,
1) First build your target. That will generate whatever java files that need to be generated during aosp build.
2) Create a shadow dir of aosp dir using lndir.
Assuming your aosp dir is ~john/work/aosp/ics.
Then create ~/john/work/aosp/icsshadow
Cd to icsshadow and invoke "lndir ../ics". That will create symlinks to everything under ics.
3) Now you use icsshadow for all the stuff your IDE needs/generates. If you use ics folder, the aosp build some times fails if the IDE generates any build artifacts.
4) cd to icsshadow directory.
Invoke development/tools/idegen/idegen.sh
Wait until it is done.
5) If you want to use IntelliJ, open android.ipr from icsshadow folder. If you want to use Eclipse, Please check Using Eclipse to edit/browse AOSP code.
Official instructions can be found by going to development/tools/idegen path and checking the README file. It's a good idea to read it yourself. This is the content for IntelliJ:
If you're using IntelliJ...
If this is your first time using IDEGen...
IDEA needs a lot of memory. Add "-Xms748m -Xmx748m" to your VM options
in "IDEA_HOME/bin/idea.vmoptions" on Linux or
"IntelliJ IDEA.app/Contents/Info.plist" on OS X.
Create a JDK configuration named "1.6 (No Libraries)" by adding a new
JDK like you normally would and then removing all of the jar entries
under the "Classpath" tab. This will ensure that you only get access to
Android's core libraries and not those from your desktop VM.
From the project's root directory...
Repeat these steps after each sync...
1) make (to produce generated .java source)
2) development/tools/idegen/idegen.sh
3) Open android.ipr in IntelliJ. If you already have the project open,
hit the sync button in IntelliJ, and it will automatically detect the
updated configuration.
If you get unexpected compilation errors from IntelliJ, try running
"Build -> Rebuild Project". Sometimes IntelliJ gets confused after the
project changes significantly.
The following error message might pop up when following the instructions.
Couldn't find idegen.jar. Please run make first.
You can fix the error message by reading here: https://www.protechtraining.com/blog/post/860?ncr=1
Run the below command from the Android source root directory.
make idegen -j4 && development/tools/idegen/idegen.sh
Then launch IntelliJ idea, and select the .ipr file generated. Then on the next screen select the .ipr based project property.
Works for me and better than using the android studio, because there is an annoying background scan all the time with the android studio.

Ant Build Android Project With Dependencies

I'm trying to build an app (let's call it android-app) with a dependency on an SDK (let's call it sdk) via Ant. Eclipse is not installed on this computer (for reasoning, it's a CI box with Jenkins).
Both projects are in two completely separate directories side by side. android-app is in the directory ~/.jenkins/jobs/android-app/workspace and sdk is in the directory ~/.jenkins/jobs/sdk/workspace.
Let's assume both projects are "vanilla" and have not been built with Ant before. I cd to the ../android-app/workspace directory and run android update project -p . --library ~/.jenkins/jobs/sdk/workspace which passes. I then cd to the ../sdk/workspace directory and run android update project -p . which also passes.
At this point I cd back to the ../android-app/workspace directory and run ant clean build. It fails with the error:
BUILD FAILED
/path/to/ant/build.xml:440:
/path/to/sdk/workspace resolve to a path with no project.properties file for
project /path/to/android-app/workspace
... where /path/to is the full path to the directories. I simplified it here.
If I cd to the sdk workspace and open project.properties, I receive the following:
# ProGuard
proguard.config=proguard.cfg
# Project target.
target=android-10
android.library=true
It does exist. So do all of these files:
So, why is this failing? What am I doing wrong? I tried to provide as many details as possible. Please let me know if I can provide anything additional.
Well, I encounter this problem too.
I use strace to find out what the hell is going on and found that the path you specified in project.properties will be appended with your current folder path as its prefix.
For example,
/home/myfolder/project > ant debug
And the library you specified in project.properties is /path/to/library
Then, the path will become
/home/myfolder/project/path/to/library
Just to fill in the answer gap here, my Java version was completely off. I'm super embarrassed.

Categories

Resources