Skip to content

Commit a5b4d77

Browse files
author
hide
committed
chore:README
1 parent fbc5876 commit a5b4d77

1 file changed

Lines changed: 35 additions & 60 deletions

File tree

README.md

Lines changed: 35 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
# AndroidRemoteBuildWithDocker
22

3-
If you build Android project on MacBook or other laptop, you may think your computer performance is not enough.
3+
If you build Android project on MacBook or other laptops, you must think your computer performance is not enough. Your laptop battery is not enough as well. And you must spend a lot time on waiting it.
44
So you may want a powerful and portable workstation. It is impossible. But you can build on remote PC.
5+
The trouble on me as well. But I have fixed it. I used to build with [Mainframer](https://github.com/buildfoundation/mainframer) on my powerful desktop.
6+
It is a problem that Mainframer configuring is not simple. In case I want to build on a cloud service or a new computer, tremendous steps of configuration make me feel tired. Whereas a virtualization technology , such as `Docker` and `Kubernetes`, is very efficient that I've used it in everywhere.
7+
In this repo, I make a docker image for a **builder server** that contains Android environment and [Mainframer](https://github.com/buildfoundation/mainframer). You can deploy a google cloud or amazon cloud server for your remote and powerful building. On the other hand, , you can run on your desktop in case you have a powerful/high-performance PC with your laptop under one LAN. It works on not only **terminal** but also **Android Studio**.
58

6-
The trouble on me as well, I used to build with [Mainframer](https://github.com/buildfoundation/mainframer) on my desktop that is high-performance/powerful.
9+
# Server configuration
10+
<details><summary>click to expand</summary>
711

8-
In this repo, I make a docker image with [Mainframer](https://github.com/buildfoundation/mainframer) to create a **builder server**. It works on not only **terminal** but also **Android Studio**.
12+
First step is building docker image. In your terminal, run this command `docker build -t mainframer-docker .`
913

10-
# Build server
11-
In order to build the docker image run following command `docker build -t mainframer-docker .`
12-
* The docker image is setup to build go, clang, gcc, buck, rust, gradle and gradle android projects. If you want to make your docker image smaller you can comment out what you don't need in the Dockerfile.
14+
Last step is starting it: run `docker run --restart always -d -p 23:22 mainframer-docker`.
1315

14-
To run the docker image run `docker run -d -p 23:22 mainframer-docker`.
16+
Now, if there is no error, run `docker container ls | grep mainframer-dockers` to detect if it is started. May everything is very well.
17+
</details>
1518

16-
# Client
17-
18-
Beside the project specific setup we need 2 more things, an ssh-key in order to make communication between client and server easier to maintain. And a ssh config for our server.
19+
# Client configuration
20+
<details><summary>click to expand</summary>
21+
Beside the project specific setup we need 2 more things, an ssh-key that is used to easily communicate between client and server. And a ssh configuring for our server.
1922

2023
```bash
2124
ssh-keygen -t rsa -f ~/.ssh/remote-builder -q -N ""
@@ -36,7 +39,7 @@ Beside the project specific setup we need 2 more things, an ssh-key in order to
3639

3740
To SSH to the docker container: `ssh remote_builder`
3841

39-
For android you can now just copy the mainframer folder and rename it `.mainframer` and you should be go to run ` bash ./mainframer.sh ./gradlew assembleDebug`.
42+
For android you can now just copy the mainframer folder and rename it `.mainframer` and you should run ` bash ./mainframer.sh ./gradlew assembleDebug`.
4043

4144
**And now enjoy faster builds**
4245

@@ -47,67 +50,39 @@ For android you can now just copy the mainframer folder and rename it `.mainfram
4750
### build with Android Studio
4851

4952
1. open Android Studio, then do these steps:
53+
54+
2. use Android studio to open your project.
5055

51-
1. click **Run → Edit Configuration → +**.
56+
3. click **Run → Edit Configuration → +**.
5257

53-
1. select your **Android App**.
58+
4. select your **Android App**.
5459

55-
1. name a new name, e.g. remote-build.
60+
5. name a new name, e.g. remote-build.
5661

57-
1. in **Module**, select submodule name, may be `app`.
62+
6. in **Module**, select submodule name, may be `app`.
5863

59-
1. in **Before Launch**, click **-** to delete `Gradle-aware Make`
64+
7. in **Before Launch**, click **-** to delete `Gradle-aware Make`
6065

61-
1. in **Before Launch**, click **+**, add **Run External Tool**, input a new name,like `remote assembleDebug`.
66+
8. in **Before Launch**, click **+**, add **Run External Tool**, input a new name,like `remote assembleDebug`.
6267

6368

64-
1. in **Program**, input `bash`.
69+
9. in **Program**, input `bash`.
6570

66-
1. in **Parameters** input `mainframer.sh ./gradlew :app:assembleDebug -Pandroid.enableBuildCache=true`
71+
10. in **Parameters** input `mainframer.sh ./gradlew :app:assembleDebug -Pandroid.enableBuildCache=true`
6772

68-
1. in **Working directory** , input `$ProjectFileDir$`.
73+
11. in **Working directory** , input `$ProjectFileDir$`.
6974

7075

76+
</details>
7177

7278
### In addition
7379

74-
when you got the error:
75-
```
76-
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/xxx/.ssh/remote-builder.pub"
77-
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
78-
79-
/usr/bin/ssh-copy-id: ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
80-
ERROR: @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
81-
ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
82-
ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
83-
ERROR: Someone could be eavesdropping on you right now (man-in-the-middle attack)!
84-
ERROR: It is also possible that a host key has just been changed.
85-
ERROR: The fingerprint for the ECDSA key sent by the remote host is
86-
ERROR: SHA256:tbW7XTrFLjqAIUp+SjQ+koR+GJak26E+rmXfLs5w7Es.
87-
ERROR: Please contact your system administrator.
88-
ERROR: Add correct host key in /home/xxx/.ssh/known_hosts to get rid of this message.
89-
ERROR: Offending ECDSA key in /home/xxx/.ssh/known_hosts:32
90-
91-
ERROR: remove with:
92-
ERROR: ssh-keygen -f "/home/xxx/.ssh/known_hosts" -R "[127.0.0.1]:23"
93-
ERROR: ECDSA host key for [127.0.0.1]:23 has changed and you have requested strict checking.
94-
ERROR: Host key verification failed.
95-
```
96-
Obviously, you need run `ERROR: ssh-keygen -f "/home/xxx/.ssh/known_hosts" -R "[127.0.0.1]:23"`. and retry.
97-
98-
A next error:
99-
```
100-
101-
FAILURE: Build failed with an exception.
102-
103-
* What went wrong:
104-
Could not determine java version from '11.0.11'.
105-
106-
```
107-
run `./gradlew wrapper --gradle-version 5.1.1`
108-
109-
**install some sdk?**
110-
111-
1. start your docker,
112-
1. run `ssh remote_builder` to enter your docker container. Or use docker command to enter it.
113-
1. run `/sdk/tools/bin/sdkmanager--install "ndk;21.0.6113669" --channel=3`.
80+
**How to install other sdk?**
81+
Modify Dockerfile to rebuild. Or follow these steps:
82+
83+
1. start your docker.
84+
2. run `ssh remote_builder` to enter your docker container. Or use docker command to enter it.
85+
3. by the time you entered the bash on your docker container, run `/sdk/tools/bin/sdkmanager--install "ndk;21.0.6113669" --channel=3`.
86+
87+
**Mainframer also can build other kind of project**
88+
You can fork this project to edit `Dockerfile` to make it work for your project.

0 commit comments

Comments
 (0)