Dev*_*ots 2 macos android gradle flutter
我正在开发一个 Flutter 应用程序,它集成了使用 Protobuff 的本机包。我在 Android Studio 和 Mac(Apple 操作系统)上工作。
\n在 Windows 上,可以构建应用程序,但由于我在 MacO 上工作,所以无法再构建应用程序。我收到以下错误:
\nFAILURE: Build failed with an exception.\n\n* What went wrong:\nExecution failed for task \xe2\x80\x98:mypackage:generateDebugProto\xe2\x80\x99.\n> Could not resolve all files for configuration \xe2\x80\x98:mypackage:protobufToolsLocator_protoc\xe2\x80\x99.\n > Could not find protoc-3.9.2-osx-aarch_64.exe (com.google.protobuf:protoc:3.9.2).\n Searched in the following locations:\n https://jcenter.bintray.com/com/google/protobuf/protoc/3.9.2/protoc-3.9.2-osx-aarch_64.exe\n\n* Try:\nRun with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.\n\n* Get more help at https://help.gradle.org\n\nBUILD FAILED in 888ms\nException: Gradle task assembleDebug failed with exit code 1\nRun Code Online (Sandbox Code Playgroud)\niOS 上的构建也不起作用。
\n我该如何解决这个错误?您对问题出在哪里有什么想法吗?
\nDev*_*ots 16
我找到了基于以下内容的解决方案:https ://github.com/grpc/grpc-java/issues/7690
我创建了文件$HOME/.gradle/gradle.properties::
protoc_platform=osx-x86_64
Run Code Online (Sandbox Code Playgroud)
我的 build.gradle :
protobuf {
// Configure the protoc executable
protoc {
// for apple m1, add protoc_platform=osx-x86_64 in $HOME/.gradle/gradle.properties
if (project.hasProperty('protoc_platform')) {
artifact = "com.google.protobuf:protoc:3.9.2:${protoc_platform}"
} else {
artifact = "com.google.protobuf:protoc:3.9.2"
}
}
plugins {
javalite {
// The codegen for lite comes as a separate artifact
if (project.hasProperty('protoc_platform')) {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0:${protoc_platform}"
} else {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
x86_64适用于英特尔和苹果芯片
import org.apache.tools.ant.taskdefs.condition.Os
// Compatible with macOS on Apple Silicon
def archSuffix = Os.isFamily(Os.FAMILY_MAC) ? ':osx-x86_64' : ''
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.20.1$archSuffix"
}
plugins {
javalite {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0$archSuffix"
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8835 次 |
| 最近记录: |