안드로이드 스튜디오를 빌드해보자

EaseTheWorld·2021년 1월 26일
0

성공할 수 있을지 모르겠지만 일단 해보자.
환경은 Win10, 램8GB 노트북

준비 :

  • git windows 버젼
  • 하드 15GB 이상 여유
  • 파일경로가 길기때문에 Filename too long 에러 안만나려면 git config --global core.longpaths true 해줘야함.(레지스트리 LongPathsEnabled는 안해도 되는듯)
  1. 소스 다운로드

$ repo init -u https://android.googlesource.com/platform/manifest -b studio-master-dev
Downloading manifest from https://android.googlesource.com/platform/manifest

repo has been initialized in D:\studio-master-dev
Downloading Repo source from https://gerrit.googlesource.com/git-repo

repo sync 한시간쯤 지나서 Updating files... 메시지 나오기 시작하다가 에러남...ㅠㅜ

$ repo sync -c -j4 -q
Updating files: 100% (163/163), done.
Updating files: 100% (425/425), done.
Updating files: 100% (764/764), done.
Updating files: 100% (719/719), done.
Updating files: 100% (275/275), done.
Updating files: 100% (10163/10163), done.
Updating files: 100% (67691/67691), done.
Updating files: 100% (475/475), done.
Updating files: 100% (265/265), done.
Updating files: 100% (5018/5018), done.
Updating files: 100% (2067/2067), done.
Updating files: 100% (5491/5491), done.
Updating files: 100% (242/242), done.
Updating files: 100% (2337/2337), done.
Updating files: 100% (1897/1897), done.
Updating files: 100% (4487/4487), done.
Updating files: 100% (12/12), done.
Updating files: 100% (3389/3389), done.
Updating files: 100% (10522/10522), done.
Updating files: 100% (39418/39418), done.
Updating files: 100% (35512/35512), done.
Updating files: 100% (521/521), done.
Updating files: 100% (160/160), done.
Updating files: 100% (1520/1520), done.
Updating files: 100% (13394/13394), done.
Updating files: 100% (165/165), done.
Updating files: 100% (1691/1691), done.
Updating files: 100% (1983/1983), done.
Updating files: 100% (162/162), done.
Updating files: 100% (198/198), done.
Updating files: 100% (13/13), done.
Updating files: 100% (112895/112895), done.
Updating files: 100% (600/600), done.
Updating files: 100% (1976/1976), done.

.repo가 15GB 로서 대부분을 차지한다.

  • build
    먼저 bazel 실행되는지 테스트
    $ tools/base/bazel/bazel version
    bash: tools/base/bazel/bazel: /usr/bin/python^M: bad interpreter: No such file or directory

$ cp `which python` /usr/bin/python
파이썬 설치경로에 한글 들어가면 ln 실패하고 cp는 되더라. 그리고 /usr/bin/ 접근해야하니까 git bash 여전히 관리자권한으로 실행.

$ tools/base/bazel/bazel version
Cannot find C:\tools\msys64\usr\bin\bash.exe while trying to set "BAZEL_SH"
NOTE: Bazel for Windows currently hardcodes "C:\tools\msys64", but we
could not find an installation of msys at this path on your machine.
Move your installation there if you already have it or
install it there from http://www.msys2.org.
Make sure to change the path to C:\tools\msys64

See also: https://github.com/bazelbuild/bazel/issues/2447

bash경로가 하드코딩되어있을줄이야...git bash 못쓰겠네. msys64 설치했다. 설치경로는 C:\tools\msys64
그리고 파이썬 설치.
$ pacman -S python3
...
$ which python
/usr/bin/python
깔끔하게 /usr/bin에 깔리네.
그런데...

$ tools/base/bazel/bazel version
Platform msys is not yet supported.
황당하네. 시킨대로 msys2 깔았는데...
그렇다면... 최후의 방법

WSL 로 우분투 깔아보자.
소스는 받아놨지만 그래도 repo, gpg는 다시 해주고.
우분투는 /usr/bin/python3만 있어서
sudo apt install python-is-python3 를 해줘야 /usr/bin/python이 생긴다. symbolic link보단 apt 쓰는걸 추천한다고 한다.

$tools/base/bazel/bazel version
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Build label: 1.1.0-adt-b151843374
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Mar 31 16:35:27 2020 (1585672527)
Build timestamp: 1585672527
Build timestamp as int: 1585672527
드디어 bazel까지 성공
처음부터 WSL 했으면 Filename too long으로 고생 안하지 않았을까..

$tools/base/bazel/bazel build tools/adt/idea/android:profiler-arti
facts
INFO: Writing tracer profile to '/home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/command.profile.gz'
ERROR: no such package '@blaze//': The repository's path is "tools/vendor/google3/blaze" (absolute: "/mnt/d/studio-master-dev/tools/vendor/google3/blaze") but this directory does not exist.
ERROR: no such package '@blaze//': The repository's path is "tools/vendor/google3/blaze" (absolute: "/mnt/d/studio-master-dev/tools/vendor/google3/blaze") but this directory does not exist.
INFO: Elapsed time: 0.917s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

Bazel 빌드는 포기

WSL에서 build_studio.sh
했더니 \r 관련 에러가 나서.
sudo apt install dos2unix 했는데
Unable to locate package 나서
sudo apt update 하고 나서 하니까 깔림.
혹시 몰라서 ant 도 깔았다.

~/studio-master-dev/tools/idea$ ./build_studio.sh
## Building android-studio ##
## Dist dir : /home/easetheworld/studio-master-dev/tools/idea/out/studio/dist
## Qualifier:
## Build Num: SNAPSHOT
## Out dir : /home/easetheworld/studio-master-dev/tools/idea/out/studio
## Prog dir : .
## ASWB? :
## UITESTS? : false

## JAVA_HOME: /home/easetheworld/studio-master-dev/prebuilts/studio/jdk/linux
## BAZEL: ../base/bazel/bazel
ERROR: no such package '@blaze//': The repository's path is "tools/vendor/google3/blaze" (absolute: "/mnt/d/studio-master-dev/tools/vendor/google3/blaze") but this directory does not exist.
## BAZEL_BIN:
Buildfile: /mnt/d/studio-master-dev/tools/idea/build.xml

init:

bazel-dependencies:
[exec] INFO: Writing tracer profile to '/home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/command.profile.gz'
[exec] Loading:
[exec] Loading: 0 packages loaded
[exec] ERROR: no such package '@blaze//': The repository's path is "tools/vendor/google3/blaze" (absolute: "/mnt/d/studio-master-dev/tools/vendor/google3/blaze") but this directory does not exist.
[exec] ERROR: no such package '@blaze//': The repository's path is "tools/vendor/google3/blaze" (absolute: "/mnt/d/studio-master-dev/tools/vendor/google3/blaze") but this directory does not exist.
[exec] INFO: Elapsed time: 0.142s
[exec] INFO: 0 processes.
[exec] FAILED: Build did NOT complete successfully (0 packages loaded)
[exec] FAILED: Build did NOT complete successfully (0 packages loaded)

BUILD FAILED
/mnt/d/studio-master-dev/tools/idea/build.xml:47: The following error occurred while executing this line:
/mnt/d/studio-master-dev/tools/adt/idea/android/build.xml:33: exec returned: 1

Total time: 2 seconds

여전히 blaze 에러.

https://android.googlesource.com/platform/tools/idea/+/refs/heads/studio-master-dev/RELEASE.md 여기보면 blaze 관련된거 지우라고해서 지우고 ant했는데 이번엔 ndk에서 에러남.

~/studio-master-dev/tools/idea$ ant
Buildfile: /mnt/d/studio-master-dev/tools/idea/build.xml

init:

bazel-dependencies:
[exec] INFO: Writing tracer profile to '/home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/command.profile.gz'
[exec] Loading:
[exec] Loading: 0 packages loaded
[exec] Loading: 0 packages loaded
[exec] Loading: 0 packages loaded
[exec] Loading: 0 packages loaded
[exec] Loading: 0 packages loaded
[exec] Loading: 0 packages loaded
[exec] currently loading: tools/adt/idea/android
[exec] Loading: 0 packages loaded
[exec] currently loading: tools/adt/idea/android
[exec] Analyzing: target //tools/adt/idea/android:artifacts (1 packages loaded)
[exec] Analyzing: target //tools/adt/idea/android:artifacts (1 packages loaded, 0 targets configured)
[exec] Analyzing: target //tools/adt/idea/android:artifacts (84 packages loaded, 198 targets configured)
[exec] Analyzing: target //tools/adt/idea/android:artifacts (110 packages loaded, 246 targets configured)
[exec] Analyzing: target //tools/adt/idea/android:artifacts (110 packages loaded, 246 targets configured)
[exec] DEBUG: Rule 'io_bazel_rules_docker' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1573737769 -0500"
[exec] DEBUG: Call stack for the definition of repository 'io_bazel_rules_docker' which is a git_repository (rule definition at /home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/external/bazel_tools/tools/build_defs/repo/git.bzl:195:18):
[exec] - /home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/external/bazel_toolchains/repositories/repositories.bzl:35:9
[exec] - /mnt/d/studio-master-dev/WORKSPACE:41:1
[exec] Analyzing: target //tools/adt/idea/android:artifacts (131 packages loaded, 396 targets configured)
[exec] INFO: Call stack for the definition of repository 'remote_java_tools_linux' which is a http_archive (rule definition at /home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/external/bazel_tools/tools/build_defs/repo/http.bzl:292:16):
[exec] - /home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/external/bazel_tools/tools/build_defs/repo/utils.bzl:205:9
[exec] - /DEFAULT.WORKSPACE.SUFFIX:260:1
[exec] ERROR: /mnt/d/studio-master-dev/tools/base/bazel/repositories.bzl:206:13: //external:android/crosstool depends on @androidndk//:default_crosstool in repository @androidndk which failed to fetch. no such package '@androidndk//': The repository's path is "/mnt/d/studio-master-dev/prebuilts/studio/sdk/linux/ndk-bundle" (absolute: "/mnt/d/studio-master-dev/prebuilts/studio/sdk/linux/ndk-bundle") but a symlink could not be created for it, because: /mnt/d/studio-master-dev/prebuilts/studio/sdk/linux/ndk-bundle (No such file or directory)
[exec] ERROR: Analysis of target '//tools/adt/idea/android:artifacts' failed; build aborted: Analysis failed
[exec] INFO: Elapsed time: 39.654s
[exec] INFO: 0 processes.
[exec] FAILED: Build did NOT complete successfully (145 packages loaded, 691 targets configured)
[exec] FAILED: Build did NOT complete successfully (145 packages loaded, 691 targets configured)

BUILD FAILED
/mnt/d/studio-master-dev/tools/idea/build.xml:47: The following error occurred while executing this line:
/mnt/d/studio-master-dev/tools/adt/idea/android/build.xml:33: exec returned: 1

Total time: 40 seconds

https://issuetracker.google.com/issues/126764883 여기보면 다른 사람들도 빌드실패..
repositories.bzl에서 "name":"androidndk"...블록 없애고 해봐도 안되네..

~/studio-master-dev/tools/idea$ ant
Buildfile: /mnt/d/studio-master-dev/tools/idea/build.xml

init:

bazel-dependencies:
[exec] INFO: Writing tracer profile to '/home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/command.profile.gz'
[exec] Loading:
[exec] Loading: 0 packages loaded
[exec] Analyzing: target //tools/adt/idea/android:artifacts (0 packages loaded, 0 targets configured)
[exec] ERROR: /home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/external/local_config_cc/BUILD:47:1: in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'arm64-v8a'
[exec] INFO: Call stack for the definition of repository 'remote_java_tools_linux' which is a http_archive (rule definition at /home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/external/bazel_tools/tools/build_defs/repo/http.bzl:292:16):
[exec] - /home/easetheworld/.cache/bazel/_bazel_easetheworld/38015431c366c1b7d42227bb31271bb2/external/bazel_tools/tools/build_defs/repo/utils.bzl:205:9
[exec] - /DEFAULT.WORKSPACE.SUFFIX:260:1
[exec] ERROR: Analysis of target '//tools/adt/idea/android:artifacts' failed; build aborted: Analysis of target '@local_config_cc//:toolchain' failed; build aborted
[exec] INFO: Elapsed time: 4.067s
[exec] INFO: 0 processes.
[exec] FAILED: Build did NOT complete successfully (8 packages loaded, 110 targets configured)
[exec] FAILED: Build did NOT complete successfully (8 packages loaded, 110 targets configured)

BUILD FAILED
/mnt/d/studio-master-dev/tools/idea/build.xml:47: The following error occurred while executing this line:
/mnt/d/studio-master-dev/tools/adt/idea/android/build.xml:33: exec returned: 1

Total time: 4 seconds

0개의 댓글