dsa28s / android-studio-apple-m1

Android Studio Arctic Fox (Canary) for Apple Sillicon
GNU General Public License v2.0
247 stars 7 forks source link

Instructions on how to build? #1

Open RankoR opened 3 years ago

RankoR commented 3 years ago

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

mochadwi commented 3 years ago

+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!

VamChao commented 3 years ago

Thanks!

dsa28s commented 3 years ago

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!!

andrei-kuznetsov commented 3 years ago

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

dsa28s commented 3 years ago

@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.)

andrei-kuznetsov commented 3 years ago

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?

RankoR commented 3 years ago

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

dsa28s commented 3 years ago

@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. 😢

andrei-kuznetsov commented 3 years ago

@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).

dan10 commented 3 years ago

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 commented 3 years ago

@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?

mochadwi commented 3 years ago

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

VamChao commented 3 years ago

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

There is no download link yet.

palvajk commented 3 years ago

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

VamChao commented 3 years ago

I can't find download link for Apple Silicon.

palvajk commented 3 years ago

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

VamChao commented 3 years ago

image image

VamChao commented 3 years ago

image

palvajk commented 3 years ago
Képernyőfotó 2021-04-30 - 8 40 45

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

VamChao commented 3 years ago

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

palvajk commented 3 years ago

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

VamChao commented 3 years ago

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

andrei-kuznetsov commented 3 years ago

@dan10

can you provide the docker file please?

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