Running Cygwin commands from batch file - android

My project is an AndroidNDK project and requires some build commands to run from Cygwin (or a Unix environment). Is there a way to do this using TeamCity?
I tried using the commandline build step and passing in a batch file which first launches cygwin, and then performs the build commands I need. However this does not work, all it does is launch cygwin, but my unix commands do not get executed after this.

How are you launching and running commands from cygwin?
You will have to do bash -c "command you want to run" (assuming bash.exe is on path). Just calling bash and then giving commands will just launch bash.

I used cygwinonce. I tried doing similar you wanted to do.I wanted to start cygwin with default command.
bash --login -i myBashScript.exe
only when we paste myBashScript.exe in bin folder.

Related

How to run an executable in a different dir when running make command in root dir?

Bit of a noob question but I'm building an app in react native and to make development a bit faster I'm using a make file for arbitrary commands. I need to run an executable in a sub-directory but can't get this to work while using the Makefile command.
The command works when I cd into the directory then run it but this doesn't work when I use the exact same commands for the make command and I'm sure there's a one line answer to this somewhere but I haven't been able to find it.
Doing this works
user#device:~/project$ cd android
user#device:~/project/android$ ./gradlew assembleRelease
but having it in the makefile like so doesn't
///////// Start of Makefile /////
apk:
cd android/
./gradlew assembleRelease
///// End of file ///////
user#device:~/project$ make apk
Why not just use android/gradlew assembleRelease?
There is some good info elsewhere on SO about why commands like cd won't work as expected in a makefile.

Windows script to install multiple Android apps

In my Android Studio project I have some different apps and I want to build and install all of them at once. I didn't know if there is any way to do it without the terminal but with the terminal what I do is the following:
gradlew.bat assembleDebug
To build all the apps, and after:
adb -d install app1.apk
To install app1 in my device. If I do:
adb -d install app1.apk | adb -d install app2.apk
I will install app1 and app2 (app1.apk have the whole path of the apk location). So I want to build a script who have the four command for install my four apps but I don't know what to do on windows to do that. I think I can't just create my_script.sh like this:
adb -d install app1.apk
adb -d install app2.apk
adb -d install app3.apk
adb -d install app4.apk
and execute it... so I need your help. How can I do a command script like that on windows?
So, finally I found an answer. Scripts on windows are made it as in Linux but instead .sh there are .bat. Actually I found a better way to do what I want to do on Gradle instead of I was trying to do I use the install task of gradle called like this:
gradlew :app1:installRelease :app2:installRelease :app3:installRelease :app4:installRelease
Even you only need to put the fewer character needed to differenciate tasks. For example if you have Release and Debug build variants you only need to write:
gradlew :app1:iR
To execute the installRelease of app1 in gradle.

how do you run a script

I read these instructions:
BaseGameUtils import using Eclipse
It says you need to run "make_eclipse_compat" script.
Stupid question: How do I run the script on windows?
I tried the following:
start key
cmd.exe (run as administrator)
cd c:\android-basic-samples-master\scripts
run make_eclipse_compat
But that writes not output (no error message either) and does not create the eclipse_compat folder.
I cannot simply double click the script as it has no file ending.
From looking at the file in text editor I'd say it looks rather like a batch file. But appending .bat and running that does not work either.
What is the correct way to run the script?
I looked into the file and the first line says #!/bin/sh
According to the internet that means it is a bourne shell script which you run using bash.exe
So I installed cygwin, copied bash.exe to the android-basic-samples-master folder,
then in cmd.exe executed
bash Scripts/make_eclipse_compat
and the script finished successfully.
Get rid of the run. In Windows, if there is a .bat script, you simple execute:
make_eclipse_compat
or
make_eclipse_compat.bat
In the directory that has the script.

Linux Script run on Startup

I'm looking to build CyanogenMod ROMs for android, I've followed a tutorial to setup the build environment.
This is the tutorial I followed: http://wiki.cyanogenmod.org/w/Build_for_i9305#Prepare_the_device-specific_code
The only question I have is, instead of executing:
cd ~/android/system
source build/envsetup.sh
Every time I want to build the ROM, is there a way to run it on boot? I tried to create a script to do it for me and run it in the startup applications but I couldn't get it to work.
#!/bin/bash
cd ~/android/system/
source build/envsetup.sh
It throws this error:
kane#androidvm ~ $ sudo sh ~/android/system/build/envsetup.sh
/home/kane/android/system/build/envsetup.sh: 1: /home/kane/android/system/build/envsetup.sh: Syntax error: "(" unexpected
What am I doing wrong?
you can try add your code in ~/.bashrc. I think you always need launch a terminal to do your work. Then it will be executed when terminal open.

Android link .so for command line executable?

I am developing a cross-platform library, and am trying to test on Android. I have compiled my library with ndk-build, and am trying to compile and run a command-line test fixture we have for the library.
I use adb push to put the test fixture and .so in /data/local/tmp and chmod both to 777.
Then I use adb shell to run the test, but get the following error
shell#android:/data/local/tmp $ ./mytest
./mytest
link_image[1936]: 7289 could not load needed library 'libtconfig.so' for './mytest' (load_library[1091]: Library 'libtconfig.so' not found)CANNOT LINK EXECUTABLE
Both mytest executable and libtconfig.so are in the same directory. I would have assumed it looks in "." directory first?
I found I can add the path /data/local/tmp to LD_LIBRARY_PATH and it will work, however when using adb shell commands in a script, each "adb shell" is a new instance, so LD_LIBRARY_PATH is reset

Categories

Resources