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.
Related
I have installed Android Studio on my mac M1
I have added a virtual device in Android Studio using Device Manager
The app builds fine from inside Android Studio......however when I run npx react-native run-android from command line in VSCode, I get the error No emulators found as an output of emulator -list-avds
However when I navigate to emulator folder using cd ~/Library/Android/sdk/emulator and run command ./emulator -avd {AVD_NAME}, the emulator starts fine.....however even with the emulator running, the command npx react-native run-android still gives the error No emulators found as an output of emulator -list-avds
UPDATE 04/26 - I followed instructions from #qqNade, however I am still getting same error...see screenshot below:
Just noticed from the screenshot above, the error
/bin/sh: adb: command not found
..also, when I run echo $PATH in terminal, I get the following response:
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
I dont see any reference to android in there, so I assume thats not a good thing
UPDATE 04/26 #2
I added a ~/.zshrc file and populated it as per below:
export ANDROID_HOME="$HOME/Library/Android/sdk"
export
PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
..that solved the /bin/sh: adb: command not found error, but now I have a new one:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
....at least its launching the emulator now
UPDATE 04/26 #3
A number of SO posts told me to run the following command from android folder (and then clean)
chmod +x gradlew;
...now Im getting a different error:
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
./gradlew: line 188: syntax error: unexpected end of file
Im wondering if this has anything to do with fact that I created the app originally on Windows.....and this is the first time Im trying to build on Mac?
I checked gradlew file in VSCode and its showing as LF (not CRLF) which as I understand it is correct when building for Mac
I also faced such a problem, to solve it you need to open a command prompt and enter
nano ~/.zsh_profile
after which you need to add this to the file and save
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
then enter on the command line
source $HOME/.zsh_profile
I want to help you.
You're in the home directory (you can go there with cd $HOME or cd ~)
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
source ~/.bash_profile (or source ~/.zshrc, take a look at my note at the end please)
After that, when you execute command vi .bash_profile (or vi .zshrc), you should see something like that
At this point, you can try to execute emulator -list-avds command again
And yes, echo $PATH should show you entries related with Android like ~/Library/Android/sdk/platform-tools
echo $ANDROID_HOME as well
If still not working, I would try to navigate to android folder and run the commands below one more time
chmod +x gradlew
./gradlew clean
react-native run-android
NOTE: Please be sure which shell your mac is using with the command below.
echo $0
Further reading
setting up development environment
I have used homebrew for setting up
echo $PATH
/bin:/usr/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/userName/Library/Android/sdk/emulator:/Users/userName/Library/Android/sdk/platform-tools
when we get this error,
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
try running this command and it will update the gradlew file with access permission, this is for M1 chip machine only
cd android
chmod +x gradlew
This solved my issue
I am running linux mint 17.2, I have repo installed and the path to repo is added to my .bashrc. I have previously initiated my repo.
I have followed the instructions on the Android Source Downloading and How to Build CyanogenMod pages.
The problem is: I have written a bash script to automate a number of the commands I would like to use to start a build. My script in a simple form is the following:
#!/bin/bash
cd ~/Android/Cyanogenmod/cm12_1/android/system
source build/envsetup.sh
repo sync --force-sync -j8
exec $SHELL
When I run this, it reports:
/home/username/Desktop/Cyanogenmod_cm12_1_Grouper_Build : line 4 repo: command not found
If I copy and paste each line into a fresh terminal instance (or by just running a script of #!/bin/bash exec $SHELL to open a terminal) it works perfectly.
What I have tried: I have tried including a sleep 10 before the repo sync --force-sync -j8 but that made no difference. I have also tried explicitly initiating the repo and force adding it to my PATH for the current terminal session directly before attempting the repo sync --force-sync -j8. The code for that test was the following:
#!/bin/bash
mkdir -p ~/Android/Cyanogenmod/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/Android/Cyanogenmod/bin/repo
chmod a+x ~/Android/Cyanogenmod/bin/repo
cd ~/Android/Cyanogenmod/cm12_1/android/system/
source build/envsetup.sh
PATH=~/Android/Cyanogenmod/bin/repo:$PATH
repo sync --force-sync -j8
exec $SHELL
The following 2 questions have a similar title, but neither are my question, this and this.
Any help or suggestions would be great, thank you!
To summarize, there turned out to be 2 problems. The first, was in my attempted solution of manually setting the path in the script as PATH=~/Android/Cyanogenmod/bin/repo:$PATH should have been just PATH=~/Android/Cyanogenmod/bin:$PATH.
The second, and overall larger problem, was an incorrectly added PATH variable (to repo) in my .bashrc. This was fixed by adding the line export PATH=$PATH:$HOME/Android/Cyanogenmod/bin to the end of my .profile, followed by logging out/in.
I followed a tutorial to use command to build, run, ... in phonegap at http://docs.phonegap.com but I can't use those commands, except the Create command.
The Create command is:
create ./test1 com.test1 test1
the original command is: $ /path/to/cordova-android/bin/create.bat /path/to/my_new_cordova_project com.example.cordova_project_name CordovaProjectName
After created project successfully, I run the command:
cd test1/cordova/build
the original command is: $ /path/to/my_new_cordova_project/cordova/build.bat
but it throws an error:
'build' is not recognized as an internal or external command,
operable program or batch file.
Then I go to my new project folder, go in folder: cordova to look for build.bat, but I see nothing.
Can you show me how to fix this stuff, i want to use command to build my phonegap project. Thanks!
Additional info:
Using phonegap 2.6, android platform.
Windows 7 64bit.
I'm able to run command: ant, java, javac, and some in the android platform tools,...
I'm trying to follow the Getting Started with Android tutorial on Windows. I'm on step 4. Setup a New Project. I type in ./create c:\projects\test com.example.test test, then receive an error:
An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...
I've modified my PATH system environment variable, adding %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools. %ANDROID_HOME% points to c:\adt-bundle\sdk.
I can run the following commands successfully:
java
javac
ant
adb
However, running android results in -bash: android: command not found.
I'm stumped. Anyone know what I'm missing in order to be able to create Phonegap projects?
make sure you can run the commands below from your terminal:
ant -version
java -version
android -h
If you get command not found, you need to fix that first before trying to create Phonegap projects. Once you update your PATH variable, you need to restart the command prompt/terminal before be able to use those commands.
To make things easier, make sure you have ANT_HOME, JAVA_HOME and ANDROID_HOME variable defined too!
Edit:
Make sure you are using Window's command prompt and not cygwin shell.
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.