how to include the commands of envsetup.sh in Android? - android

Hi
I have run the command ./build/envsetup.sh on my source code of android while compiling.
I want to use the following commands present in the same file.
-cgrep
-mmm
-mm
but I get the following errors!!
Command 'pgrep' from package 'procps' (main)
Command 'fgrep' from package 'grep' (main)
Command 'egrep' from package 'grep' (main)
Command 'sgrep' from package 'sgrep' (universe)
Command 'grep' from package 'grep' (main)
Command 'lgrep' from package 'lv' (universe)
Command 'rgrep' from package 'grep' (main)
Command 'zgrep' from package 'gzip' (main)
Command 'dgrep' from package 'debian-goodies' (main)
Command 'vgrep' from package 'atfs' (universe)
Command 'ngrep' from package 'ngrep' (universe)
Command 'wcgrep' from package 'kdesdk-scripts' (main)
Command 'agrep' from package 'agrep' (multiverse)
Command 'xgrep' from package 'xgrep' (universe)
cgrep: command not found
How should I resolve this?
Do I need to make any changes in the envsetup.sh file?

The mm, mmm and cgrep are defined as shell functions. What does the following return for you:
set | egrep "^mmm \(\)|^mm \(\)|^cgrep \(\)"
On my environment I get:
cgrep ()
mm ()
mmm ()
If you are getting nothing back, you are probably sourcing the script wrong. Remember you can't just make the script executable and run it as it won't be exporting the functions back to your shell. You must use either:
. build/envsetup.sh
OR
source build/envsetup.sh
to ensure it runs in parent shell.

You need to return your android root content with this command in the AOPS root directory:
source ./build/envsetup.sh

Related

How to list all possible packages / modules in AOSP via command line?

In AOSP, I often use the following to setup my environment and build target and build the entire image:
$ cd ~/aosp
$ source build/envsetup.sh
$ lunch sdk_phone_x86_64
$ m
I also like to use the following to build a specific package/module instead of the entire image:
$ m <my package>
or
$ cd <path_to_package>
$ mm
Is there a way to simply list all possible packages/modules in all of AOSP? Similar to how running lunch displays all possible targets, I'm interested in seeing a list of all possible packages/modules (e.g. defined in Android.bp and Android.mk).
Follow up question: given a package/module name, is there a way to get the directory or path to the file that defines it?
build/make/envsetup.sh has define the shell function:
- allmod: List all modules.
- pathmod: Get the directory containing a module.

No command 'lint' found

I want to generate lint report for my project.
So on my Ubuntu terminal I gave the command lint my_prj_path
but I'm getting below error,
No command 'lint' found, did you mean:
Command 'link' from package 'coreutils' (main)
Command 'jlint' from package 'jlint' (universe)
Command 'hlint' from package 'hlint' (universe)
Command 'line' from package 'util-linux' (main)
Command 'tint' from package 'tint' (universe)
Command 'dlint' from package 'dlint' (universe)
lint: command not found
May be its very basic question, but I can't find a solution. Please help.
Thanks in advance.
lint is available into /sdk/tools/. So you need to go to directory or add relative path before lint command, like
SDK_PATH/sdk/tools/lint project_path
I made it that way:
Firstly, check that your .bash_profile file contains ANDROID_SDK_ROOT path]
Secondly, add lint() function:
function lint() {
cd $ANDROID_SDK_ROOT/tools/bin;
./lint $1;
}
Now you can call lint commands via terminal, for example, lint --list
On Ubuntu, navigate to android sdk tools directory and down to binaries $ANDROID_ROOT/sdk/tools/bin. Then call
./lint [flags] <project directory>
(note a call to ./lint not just lint)
For example, to get a list of all lint-supported issues call:
./lint --list

error occurs while running rake run:android

I tried to run rake run:android the follwing occurs, kindly assist me.
AndroidManifest change file [C:/Users/giridhran/workspace/myfirst/bin/libs/relea
se/arm-linux-androideabi/4.4.3/extensions/AndroidManifest.xml] from native exten
sion not found !
delete original manifest
Manifest updated by extension saved!
EXT: add additional files to project before build
PWD: C:/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhodes-3.3.2
CMD: D:/installer/android-sdk_r11-windows/android-sdk-windows/platform-tools/aap
t.exe package -f -M C:/Users/giridhran/workspace/myfirst/bin/tmp/AndroidManifest
.xml -S C:/Users/giridhran/workspace/myfirst/bin/tmp/res -A C:/RhoStudio/ruby/li
b/ruby/gems/1.8/gems/rhodes-3.3.2/platform/android/Rhodes/assets -I D:/installer
/android-sdk_r11-windows/android-sdk-windows/platforms/android-8/android.jar -J
C:/Users/giridhran/workspace/myfirst/bin/tmp
C:\Users\giridhran\workspace\myfirst\bin\tmp\AndroidManifest.xml:30: error: No r
esource identifier found for attribute 'xlargeScreens' in package 'android'
Error in AAPT
Before running rake run:android command, please ensure that:
you have set the path of java-bin folder.
you have set the path of Android SDK & NDK.
check the android version in build.xml file.

android monkey runner scripts

I was trying to run a a sample python program using monkey runner but unfortunately throwing an error of this type :
Can't open specified script file
Usage: monkeyrunner [options] SCRIPT_FILE
-s MonkeyServer IP Address.
-p MonkeyServer TCP Port.
-v MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, OFF)
Exception in thread "main" java.lang.NullPointerException
so any one can guide me how to resolve this and how to use monkey runner to execute this type of things
I've found that making the path to the script absolute helped monkeyrunner.
I am invoking the runner from a Python script where a helper class has a startMonkey method:
def startMonkey(self, monkeyScript):
command = [ self.env + '\\tools\\monkeyrunner.bat' ]
command.append( os.path.abspath( monkeyScript ) )
return startProcess( command )
This seems to be working for me.
Script file should be a full path file name try below monkeyrunner c:\test_script\first.py
So go to the folder \ sdk \ tools
and press shift and right click to open command prompt and type monkeyrunner c:\test_script\python_file_name.py

android monkey runner scripts

i am tryig to execute a sample python program through monkey runner command prompt and it is throwing an error
Can't open specified script file
Usage: monkeyrunner [options] SCRIPT_FILE
-s MonkeyServer IP Address.
-p MonkeyServer TCP Port.
-v MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO,
WARNING, SEVERE, OFF)
Exception in thread "main" java.lang.NullPointerException
so any one can guide me how to resolve this one
scriptfile should be a full path file name
try below
monkeyrunner c:\test_script\first.py
try using something like
...\tools>monkeyrunner -v ALL first.py
where first.py was my sample python script which I copied into tools folder of android SDK (the place where monkeyrunner.bat is located)
Under all unix/linux families OS the sha bang syntax can be used.
Edit the first line of your script with the results of the following command:
which monkeyrunner
for example, if monkeyrunner (usually provided with android sdk) has been installed under /usr/local/bin/sdk write:
#!/usr/local/bin/sdk/tools/monkeyrunner
or even use "env"
#!/usr/bin/env monkeyrunner
then set you script file as executable
chmod +x <script>
You can now launch your script from the shell.
It looks not make sense to switch working directory to Android SDK folder but just for obtain some relative references path for itself. It means you have to specify the full path for your script file and the PNG image files you want to save or compare to.
A better way is modify few lines in the "monkeyrunner.bat" under your SDK folder as below. This will use your current path as working directory, so, no necessary to use full path file name.
rem don't modify the caller's environment
setlocal
rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0
rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
rem cd /d %~dp0
rem Check we have a valid Java.exe in the path.
set java_exe=
call %~sdp0\lib\find_java.bat
if not defined java_exe goto :EOF
set jarfile=monkeyrunner.jar
set frameworkdir=
set libdir=
if exist %frameworkdir%%jarfile% goto JarFileOk
set frameworkdir=%~sdp0\lib\
if exist %frameworkdir%%jarfile% goto JarFileOk
set frameworkdir=%~sdp0\..\framework\
:JarFileOk
set jarpath=%frameworkdir%%jarfile%
if not defined ANDROID_SWT goto QueryArch
set swt_path=%ANDROID_SWT%
goto SwtDone
:QueryArch
for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
:SwtDone
if exist %swt_path% goto SetPath
echo SWT folder '%swt_path%' does not exist.
echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
exit /B
:SetPath
call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir%;%swt_path% -Dcom.android.monkeyrunner.bindir=%frameworkdir%\..\..\platform-tools\ -jar %jarpath% %*
I met the same things as you did, I resolved by using "monkeyrunner" command under tools, and your script file should be a full path name. It looks like the directory “tools” is the main directory of MonnkeyRunner. I am depressed that I can't run my script files by pydev IDE directly.
monkeyrunner.bat cygpath -w $(pwd)/monkey.py

Categories

Resources