android-studio-apple-m1 icon indicating copy to clipboard operation
android-studio-apple-m1 copied to clipboard

Instructions on how to build?

Open RankoR opened this issue 4 years ago • 23 comments
trafficstars

Hi! Thanks for creating a build, maybe you can publish an instruction how to build it?

RankoR avatar Apr 09 '21 10:04 RankoR

+1 for this, so we can maybe try to open PR as well if needed.

Thanks for the effort and times to make it this happened!

mochadwi avatar Apr 09 '21 10:04 mochadwi

Thanks!

VamChao avatar Apr 10 '21 12:04 VamChao

Oh, I only worked on my macbook, so I couldn't organize it. As soon as I create a build script, and I will push code on the GitHub and update the README. Thank you!!

dsa28s avatar Apr 10 '21 14:04 dsa28s

It seems that this repository only contains JBR sources. Is it correct? Note that anyone can download prebuilt JBR from the official jetbrains website.

andrei-kuznetsov avatar Apr 16 '21 18:04 andrei-kuznetsov

@andrei-kuznetsov Oh i see. When I first started this project, I just started building from the source. I didn't know there was a good page like this (https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime). Thank you.

And, my work environment has not been cleaned up yet. I modified the Android plugin a little bit, and I'm going to commit this part as soon as it's organized. (README.md too.)

dsa28s avatar Apr 16 '21 18:04 dsa28s

I modified the Android plugin a little bit

@dsa28s, Sounds interesting. Google does not publish sources for canary/beta builds. Which sources did you modify?

andrei-kuznetsov avatar Apr 16 '21 21:04 andrei-kuznetsov

@andrei-kuznetsov even more, Google's current sources of AS are not even buildable at all as there're no Bazel dependencies included.

RankoR avatar Apr 16 '21 21:04 RankoR

@andrei-kuznetsov As @RankoR said, Google didn't provide the build tool. So I just referred to the Android studio full source.

I extracted the jar file from the original Android Studio and proceeded with the decompilation. And I modified a little bit by referring to the full source only for the error.

To rebuild a jar file of decompilation, the build was proceeded by provide all jar files to classpath. So it's difficult to work on it. 😢

dsa28s avatar Apr 17 '21 14:04 dsa28s

@dsa28s, understand. Makes sense.

@RankoR, you don't really need these missing bazel dependencies to build android sources.

diff --git a/bazel/common.bazel.rc b/bazel/common.bazel.rc
index 5bba4ae79a..d419f3cba3 100644
--- a/bazel/common.bazel.rc
+++ b/bazel/common.bazel.rc
@@ -95,7 +95,7 @@ build --strategy=CcStrip=standalone
 build --stripopt=--strip-unneeded

 # default android native abis
-build --fat_apk_cpu=x86,x86_64,armeabi-v7a,armeabi,arm64-v8a
+build --fat_apk_cpu=x86,x86_64,armeabi-v7a,arm64-v8a

 build:remote --config=remote_common
 build:remote --nobuild_runfile_links
diff --git a/bazel/toplevel.WORKSPACE b/bazel/toplevel.WORKSPACE
index e00f772c91..45f0303746 100644
--- a/bazel/toplevel.WORKSPACE
+++ b/bazel/toplevel.WORKSPACE
@@ -4,15 +4,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

 setup_external_repositories()

-local_repository(
-    name = "blaze",
-    path = "tools/vendor/google3/blaze",
-)
-
-load("@blaze//:binds.bzl", "blaze_binds")
-
-blaze_binds()
-
 local_repository(
     name = "io_bazel_rules_kotlin",
     path = "tools/external/bazelbuild-rules-kotlin",
diff --git a/build-system/integration-test/integration-tests.gradle b/build-system/integration-test/integration-tests.gradle
index a399a797eb..22586428ec 100644
--- a/build-system/integration-test/integration-tests.gradle
+++ b/build-system/integration-test/integration-tests.gradle
@@ -72,7 +72,7 @@ test {
     // Always run the task, when requested.
     outputs.upToDateWhen { false }

-    maxParallelForks = Runtime.runtime.availableProcessors() / 4
+    maxParallelForks = Math.max(1, (int) (Runtime.runtime.availableProcessors() / 4))

     useJUnit {
         if (System.properties['test.includeCategories'] != null) {

Of course, you'll also need to setup Android SDK and NDK

curl https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip > /aosp/sdk-tools-linux.zip && \
    unzip /aosp/sdk-tools-linux.zip -d /aosp/sdk && \
    /aosp/sdk/tools/bin/sdkmanager "platform-tools" "ndk;20.0.5594570" "platforms;android-29" "build-tools;26.0.0" && \
    ln -s /aosp/sdk/ndk/20.0.5594570 /aosp/sdk/ndk-bundle

ln -s /aosp/sdk ${SRC}/prebuilts/studio/sdk/linux

And fix missing jvmti.h header.

mkdir -p ${SRC}/tools/vendor/google/android-ndk/includes
cp ${PATCHES}/tools.vendor.google.android-ndk.BUILD ${SRC}/tools/vendor/google/android-ndk/BUILD
curl https://android.googlesource.com/platform/art/+/master/openjdkjvmti/include/jvmti.h?format=TEXT | base64 -d > ${SRC}/tools/vendor/google/android-ndk/includes/jvmti.h
# tools.vendor.google.android-ndk.BUILD
package(default_visibility = ["//visibility:public"])

cc_library(
    name = "jvmti",
    includes = ["includes"],
)

I'm not sure why one might want to build studio from sources: there will be missing (closed-sources) parts like c/c++ dev, firebase plugin and the like. If you think that it helps, I can share docker file that builds full environment capable to build Android Studio 4.1.1 from sources (including native agents that are deployed to the device itself). But I don't see the point (unless you are developing some custom IDE on the top of Android Studio).

andrei-kuznetsov avatar Apr 19 '21 12:04 andrei-kuznetsov

I modified the Android plugin a little bit

@dsa28s, Sounds interesting. Google does not publish sources for canary/beta builds. Which sources did you modify?

The branch mirror-goog-studio-master-dev in aosp seem to be adding code related to M1, so i think is appointing to canary build

dan10 avatar Apr 23 '21 14:04 dan10

@dsa28s, understand. Makes sense.

@RankoR, you don't really need these missing bazel dependencies to build android sources.

diff --git a/bazel/common.bazel.rc b/bazel/common.bazel.rc
index 5bba4ae79a..d419f3cba3 100644
--- a/bazel/common.bazel.rc
+++ b/bazel/common.bazel.rc
@@ -95,7 +95,7 @@ build --strategy=CcStrip=standalone
 build --stripopt=--strip-unneeded

 # default android native abis
-build --fat_apk_cpu=x86,x86_64,armeabi-v7a,armeabi,arm64-v8a
+build --fat_apk_cpu=x86,x86_64,armeabi-v7a,arm64-v8a

 build:remote --config=remote_common
 build:remote --nobuild_runfile_links
diff --git a/bazel/toplevel.WORKSPACE b/bazel/toplevel.WORKSPACE
index e00f772c91..45f0303746 100644
--- a/bazel/toplevel.WORKSPACE
+++ b/bazel/toplevel.WORKSPACE
@@ -4,15 +4,6 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

 setup_external_repositories()

-local_repository(
-    name = "blaze",
-    path = "tools/vendor/google3/blaze",
-)
-
-load("@blaze//:binds.bzl", "blaze_binds")
-
-blaze_binds()
-
 local_repository(
     name = "io_bazel_rules_kotlin",
     path = "tools/external/bazelbuild-rules-kotlin",
diff --git a/build-system/integration-test/integration-tests.gradle b/build-system/integration-test/integration-tests.gradle
index a399a797eb..22586428ec 100644
--- a/build-system/integration-test/integration-tests.gradle
+++ b/build-system/integration-test/integration-tests.gradle
@@ -72,7 +72,7 @@ test {
     // Always run the task, when requested.
     outputs.upToDateWhen { false }

-    maxParallelForks = Runtime.runtime.availableProcessors() / 4
+    maxParallelForks = Math.max(1, (int) (Runtime.runtime.availableProcessors() / 4))

     useJUnit {
         if (System.properties['test.includeCategories'] != null) {

Of course, you'll also need to setup Android SDK and NDK

curl https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip > /aosp/sdk-tools-linux.zip && \
    unzip /aosp/sdk-tools-linux.zip -d /aosp/sdk && \
    /aosp/sdk/tools/bin/sdkmanager "platform-tools" "ndk;20.0.5594570" "platforms;android-29" "build-tools;26.0.0" && \
    ln -s /aosp/sdk/ndk/20.0.5594570 /aosp/sdk/ndk-bundle

ln -s /aosp/sdk ${SRC}/prebuilts/studio/sdk/linux

And fix missing jvmti.h header.

mkdir -p ${SRC}/tools/vendor/google/android-ndk/includes
cp ${PATCHES}/tools.vendor.google.android-ndk.BUILD ${SRC}/tools/vendor/google/android-ndk/BUILD
curl https://android.googlesource.com/platform/art/+/master/openjdkjvmti/include/jvmti.h?format=TEXT | base64 -d > ${SRC}/tools/vendor/google/android-ndk/includes/jvmti.h
# tools.vendor.google.android-ndk.BUILD
package(default_visibility = ["//visibility:public"])

cc_library(
    name = "jvmti",
    includes = ["includes"],
)

I'm not sure why one might want to build studio from sources: there will be missing (closed-sources) parts like c/c++ dev, firebase plugin and the like. If you think that it helps, I can share docker file that builds full environment capable to build Android Studio 4.1.1 from sources (including native agents that are deployed to the device itself). But I don't see the point (unless you are developing some custom IDE on the top of Android Studio).

can you provide the docker file please?

dan10 avatar Apr 23 '21 19:04 dan10

https://androidstudio.googleblog.com/2021/04/android-studio-arctic-fox-canary-15.html#:~:text=apple%20silicon%20support%20

mochadwi avatar Apr 30 '21 02:04 mochadwi

https://androidstudio.googleblog.com/2021/04/android-studio-arctic-fox-canary-15.html#:~:text=apple%20silicon%20support%20

There is no download link yet.

VamChao avatar Apr 30 '21 06:04 VamChao

https://androidstudio.googleblog.com/2021/04/android-studio-arctic-fox-canary-15.html#:~:text=apple%20silicon%20support%20

There is no download link yet.

here is the download link: https://developer.android.com/studio/preview/index.html

palvajk avatar Apr 30 '21 06:04 palvajk

I can't find download link for Apple Silicon.

VamChao avatar Apr 30 '21 06:04 VamChao

this is universal build its run on Intel and Apple Silicon natively. But this link contains separate packages https://developer.android.com/studio/archive

palvajk avatar Apr 30 '21 06:04 palvajk

image image

VamChao avatar Apr 30 '21 06:04 VamChao

image

VamChao avatar Apr 30 '21 06:04 VamChao

Képernyőfotó 2021-04-30 - 8 40 45

You can find ARM build here: https://developer.android.com/studio/archive

palvajk avatar Apr 30 '21 06:04 palvajk

Thank you! But... image Can you send me the. Zip link?

VamChao avatar Apr 30 '21 06:04 VamChao

Of course, https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2020.3.1.15/android-studio-2020.3.1.15-mac_arm.zip

palvajk avatar Apr 30 '21 06:04 palvajk

Thank you very much ! I downloaded it successfully. Yeah~

VamChao avatar Apr 30 '21 06:04 VamChao

@dan10

can you provide the docker file please?

https://github.com/andrei-kuznetsov/android-studio-builder/

andrei-kuznetsov avatar May 07 '21 17:05 andrei-kuznetsov