未知主机 CPU 架构: arm64 、安卓 NDK SiliconM1 苹果 MacBook Pro [英] Unknown host CPU architecture: arm64 , Android NDK SiliconM1 Apple MacBook Pro

查看:196
本文介绍了未知主机 CPU 架构: arm64 、安卓 NDK SiliconM1 苹果 MacBook Pro的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Windows 操作系统中运行良好的项目,但是当我更换笔记本电脑并在 MacBook Pro M1 中打开一个现有项目时.我无法在 MacBook pro M1 中运行现有的 android 项目.首先我得到了

<块引用>

任务:app:kaptDevDebugKotlin"的执行失败.>失败执行时发生org.jetbrains.kotlin.gradle.internal.KaptExecution >java.lang.reflect.InvocationTargetException(无错误提示)

这个错误是由于 Room 数据库我应用了一个修复程序,在 Room 数据库之前添加了下面的库,并且将我的 JDK 位置从文件结构从 JRE 更改为 JDK.

<块引用>

kapt "org.xerial:sqlite-jdbc:3.34.0"

//房间组件kapt "org.xerial:sqlite-jdbc:3.34.0";实现androidx.room:room-ktx:$rootProject.roomVersion";kapt "androidx.room:room-compiler:$rootProject.roomVersion";androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"

在那之后,我遇到了一个问题,即未知的主机 CPU 架构:arm64

我的项目中有一个 SDK 正在使用下面这一行.

android {外部原生构建{ndk构建{路径Android.mk"}}ndkVersion '21.4.7075529'}

<块引用>

[CXX1405] 使用 ndkBuild 构建时出错/Users/mac/Desktop/Consumer-Android/ime/dictionaries/jnidictionaryv2/Android.mk:构建命令失败.执行过程时出错/Users/mac/Library/Android/sdk/ndk/21.4.7075529/ndk-build with参数 {NDK_PROJECT_PATH=nullAPP_BUILD_SCRIPT=/Users/mac/Desktop/Consumer-Android/ime/dictionaries/jnidictionaryv2/Android.mkAPP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=1APP_PLATFORM=android-21NDK_OUT=/Users/mac/Desktop/Consumer-Android/ime/dictionaries/jnidictionaryv2/build/intermediates/cxx/Debug/4k4s2lc6/objNDK_LIBS_OUT=/Users/mac/Desktop/Consumer-Android/ime/dictionaries/jnidictionaryv2/build/intermediates/cxx/Debug/4k4s2lc6/libAPP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n} 错误:未知主机 CPU 架构:arm64

导致此问题的原因以及每当我对此行发表评论时

<块引用>

路径Android.mk"

它开始工作正常,有什么办法可以帮助我用这段代码运行这个项目而不会出现这个 NDK 问题?

更新 - Room 似乎在最新的更新中得到修复,因此您可以考虑将 Room 更新到最新版本(2.3.0-alpha01/2.4.0-alpha03 或更高版本)

GitHub 问题跟踪器

解决方案

解决了这个问题.

查找器 ->转到文件夹(/Users/mac/Library/Android/sdk/ndk/21.4.7075529)->现在编辑 ndk-build 在文本编辑器中打开它并粘贴下面的代码脚本并重新运行您的项目.

来自

#!/bin/shDIR="$(cd "$(dirname "$0")" && pwd)"$DIR/build/ndk-build "$@";

#!/bin/shDIR="$(cd "$(dirname "$0")" && pwd)"arch -x86_64/bin/bash $DIR/build/ndk-build "$@";

参考链接

I've got a project that is working fine in windows os but when I switched my laptop and opened an existing project in MacBook Pro M1. I'm unable to run an existing android project in MacBook pro M1. first I was getting

Execution failed for task ':app:kaptDevDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException (no error message)

this error was due to the Room database I applied a fix that was adding below library before Room database and also changed my JDK location from file structure from JRE to JDK.

kapt "org.xerial:sqlite-jdbc:3.34.0"

   //Room components
    kapt "org.xerial:sqlite-jdbc:3.34.0"
    implementation "androidx.room:room-ktx:$rootProject.roomVersion"
    kapt "androidx.room:room-compiler:$rootProject.roomVersion"
    androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"

after that now I'm getting an issue which is Unknown host CPU architecture: arm64

there is an SDK in my project that is using this below line.

android {
    externalNativeBuild {
        ndkBuild {
           path 'Android.mk'
        }
    }
    ndkVersion '21.4.7075529'


}

[CXX1405] error when building with ndkBuild using /Users/mac/Desktop/Consumer-Android/ime/dictionaries/jnidictionaryv2/Android.mk: Build command failed. Error while executing process /Users/mac/Library/Android/sdk/ndk/21.4.7075529/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/mac/Desktop/Consumer-Android/ime/dictionaries/jnidictionaryv2/Android.mk APP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=/Users/mac/Desktop/Consumer-Android/ime/dictionaries/jnidictionaryv2/build/intermediates/cxx/Debug/4k4s2lc6/obj NDK_LIBS_OUT=/Users/mac/Desktop/Consumer-Android/ime/dictionaries/jnidictionaryv2/build/intermediates/cxx/Debug/4k4s2lc6/lib APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n} ERROR: Unknown host CPU architecture: arm64

which is causing this issue and whenever I comment on this line

path 'Android.mk'

it starts working fine, is there any way around which will help me run this project with this piece of code without getting this NDK issue?

Update - it seems that Room got fixed in the latest updates, Therefore you may consider updating Room to lastest version (2.3.0-alpha01 / 2.4.0-alpha03 or above)

GitHub Issue Tracker

解决方案

solved this issue.

Finder -> Go To Folder(/Users/mac/Library/Android/sdk/ndk/21.4.7075529) -> now edit ndk-build open it in text editor and paste below code script and re-run your project.

from

#!/bin/sh
DIR="$(cd "$(dirname "$0")" && pwd)"
$DIR/build/ndk-build "$@"

to

#!/bin/sh
DIR="$(cd "$(dirname "$0")" && pwd)"
arch -x86_64 /bin/bash $DIR/build/ndk-build "$@"

Reference Link

这篇关于未知主机 CPU 架构: arm64 、安卓 NDK SiliconM1 苹果 MacBook Pro的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆