is this the right place to ask about building andr...
# android
j
is this the right place to ask about building android apps on apple's new silicon?
if so im getting
Copy code
* What went wrong:
Execution failed for task ':EtsyLib:compileDebugLibraryResources'.
> A failure occurred while executing com.android.build.gradle.tasks.CompileLibraryResourcesTask$CompileLibraryResourcesAction
   > There were multiple failures while executing work items
      > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
         > AAPT2 aapt2-4.2.1-7147631-osx Daemon #1: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
      > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
         > AAPT2 aapt2-4.2.1-7147631-osx Daemon #2: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
      > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
         > AAPT2 aapt2-4.2.1-7147631-osx Daemon #3: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
      > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
         > AAPT2 aapt2-4.2.1-7147631-osx Daemon #4: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
      > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
         > AAPT2 aapt2-4.2.1-7147631-osx Daemon #5: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
      > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
         > AAPT2 aapt2-4.2.1-7147631-osx Daemon #6: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
      > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
         > AAPT2 aapt2-4.2.1-7147631-osx Daemon #7: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
      > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
         > AAPT2 aapt2-4.2.1-7147631-osx Daemon #8: Daemon startup failed
           This should not happen under normal circumstances, please file an issue if it does.
I tried different Android Studio verisons but ultimately it comes up running on the cli so this seems to be some kind of android gradle plugin or gradle issue
oddly a coworker is able to build without this problem but we cant identify differences between our machines, both fresh setups
n
what JDK are you using?
j
Copy code
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment Homebrew (build 11.0.12+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)
i also tried
Copy code
openjdk 11.0.10 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
OpenJDK 64-Bit Server VM (build 11.0.10+0-b96-7249189, mixed mode)
this one is bundled in Android Studio for Apple Silicon package ^
i get the same error with both
i tried nuking
~/.gradle
and the local
.gradle
inside the repo directory
im on Gradle 6.9 and AGP 4.2.1
n
What version of Android studio? Can you try with AGP 7.0?
d
We've not run into issues on M1 with Gradle 7.0.2 and AGP 7 The one thing we're looking to do now is to swap our JDK to be Liberica for 11 since they have an ARM64 native JDK. This is simply because the performance gain isn't what we expected. The other option was going to JDK 17 for either OpenJDK or Oracle, which we didn't want to do.
j
im not using Android Studio, im building from the cli
is apple silicon not supported in 6.x? release notes have support listed with some performance hits
ill try getting the ARM64 native JDK and see if it makes a difference
c
FWIW I saw apple silicon native support in the Gradle 7.X release notes: https://docs.gradle.org/7.0/release-notes.html#apple-silicon Not sure what it implies “Native support…” but there’s that.
j
according to release notes m1 support was backported to 6.9 https://docs.gradle.org/6.9/release-notes.html
👍 1
d
anyone have idea how we can add buildscan tag for M1 build on gradle?
g
I’m using like this
Copy code
def osName = System.getProperty("os.name")
def osArch = System.getProperty("os.arch")
def hostOs = ""
def jvmArch = ""

// <https://github.com/openjdk/jdk/blob/ffa34ed42/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java#L68>
switch(osName) {
    case { it.startsWith("Windows") }: hostOs = "win32"; break;
    case { it.startsWith("Darwin") }: hostOs = "darwin"; break;
    case { it.contains("OS X") }: hostOs = "darwin"; break;
    default: hostOs = osName.toLowerCase()
}

// <https://github.com/openjdk/jdk/blob/ffa34ed42/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java#L68>
switch(osArch) {
    case "i386": jvmArch = "x86"; break;
    case "x86_64": jvmArch = "amd64"; break;
    default: jvmArch = osArch
}

tag(hostOs)
value("os.name", hostOs)
tag(jvmArch)
value("jvm.arch", jvmArch)

// <https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment#Determine-Whether-Your-App-Is-Running-as-a-Translated-Binary>
if (hostOs == "darwin" && ext.execAndGetStdout("sysctl", "sysctl.proc_translated") == "sysctl.proc_translated: 1") {
    value("os.proc.translated", "true")
} else {
    value("os.proc.translated", "false")
}
👍 2
d
thanks for sharing man 👍
j
Hi and thanks a lot for this contribution @ganachoco. We adapted it and made it part of our sample list https://github.com/gradle/gradle-enterprise-build-config-samples/blob/main/build-d[…]dle-samples/capture-processor-arch/gradle-processor-arch.gradle
👍 2