V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wuliaoshixia
V2EX  ›  Android

XDM 有用 Mac M1 开发 Android 和 Flutter 的吗?开发中遇到的一些问题来讨论下?

  •  
  •   wuliaoshixia · 2021-02-04 08:31:30 +08:00 · 6279 次点击
    这是一个创建于 1170 天前的主题,其中的信息可能已经有所发展或是发生改变。
    LZ 入手了 10 天左右,android 开发环境搭好了,跑 Android 项目没问题,比之前公司 i5+16G 内存的快。
    之前 i5+16Gclean 后编译项目要 8 分钟,现在 Mac m1 16G 编译花费 2 分多。
    Android 项目目前能正常开发。

    Git 工具是用的是 SmartGit,也能正常使用。

    Flutter 环境目前有点问题,使用的是 beta 分支的 SDK,flutter doctor 检测命令正常,AndroidStuio Flutter 和 Dart 插件也安装正常。但是连接真机跑代码时,却一直卡在“Running Gradle task 'assembleDebug'...”,查看了下 Gradle 的目录,发现 Gradle-6.7-all.zip 下载正常。

    XDM 有遇到 Flutter 卡在这一步的吗???
    16 条回复    2021-02-04 22:42:42 +08:00
    wuliaoshixia
        1
    wuliaoshixia  
    OP
       2021-02-04 08:34:44 +08:00
    Android 开发的 JDK 使用的是 Zulu OpenJDK
    leo7723
        2
    leo7723  
       2021-02-04 09:02:55 +08:00   ❤️ 1
    单独打开安卓项目 RUN 一遍看下,至少报错会更详细一些。
    有可能和机器没有关系。
    zeropercenthappy
        3
    zeropercenthappy  
       2021-02-04 09:18:16 +08:00
    这描述没法判断是机器的问题。
    flutter-sdk/packages/flutter_tools/gradle/flutter.gradle 设置好镜像。
    试试挂代理或者用手机热点再试试,可能是网络问题,其它依赖没下下来。
    Carver9527
        4
    Carver9527  
       2021-02-04 09:40:45 +08:00 via iPhone
    加个编译参数 v,把详细的日志打出来,看看卡在哪一步了
    bullettrain1433
        5
    bullettrain1433  
       2021-02-04 09:46:04 +08:00
    flutter 安装时候 termimal 用 rossetta 打开
    HarryQu
        6
    HarryQu  
       2021-02-04 09:51:10 +08:00
    M1 的编译速度可以提升这么多的吗?
    hongch
        7
    hongch  
       2021-02-04 09:58:45 +08:00
    “发现 Gradle-6.7-all.zip 下载正常“
    那不就是正在下载 gradle 吗,你直接用 android studio 打开 Android 工程,在 android 工程下跑./gradlew assembleDebug 看进度
    DGideas
        8
    DGideas  
       2021-02-04 10:03:15 +08:00
    XDM 是啥,“兄弟们”?没别的意思哈,看着怎么这么奇怪呢 。。
    janxin
        9
    janxin  
       2021-02-04 10:17:58 +08:00
    之前看了一下 M1 下面这么折腾,我都是劝人还不如暂时不要用它做安卓相关开发。

    Flutter 的支持目前也不好,开发的 M1 设备才拿到没几天,要完全兼容大概一段时间。而且现在要跑在 Rosetta 2 下面,不如 LZ 你看一下你的所有的环境是不是都跑在 Rosetta 2 下了?
    unmois
        10
    unmois  
       2021-02-04 10:39:18 +08:00
    宁是胡萝卜大佬吗
    limerence12138
        11
    limerence12138  
       2021-02-04 11:01:03 +08:00
    Android studio 还是没有原生适配啊,用起来卡卡的,还有一些页面会卡死
    Richy
        12
    Richy  
       2021-02-04 14:19:41 +08:00
    Android:目前 Android Studio 还没有适配 M1,可以用 IDEA 代替,不过目前 AGP 版本 4.1.1 无法直接安装 apk,需要新建 gradle 任务 [installDebug] ,每次安装后要手动打开 app,不知道有没有同学有解决方案

    Flutter: 目前在用 VS Code Insiders 版本,暂时没有什么问题。gradle 运行慢大多是因为下载 gradle 太慢了。
    wuliaoshixia
        13
    wuliaoshixia  
    OP
       2021-02-04 22:36:44 +08:00
    @Carver9527
    flutter doctor -v
    [✓] Flutter (Channel beta, 1.25.0-9.0.pre.2, on macOS 11.2 20D64 darwin-arm,
    locale zh-Hans-CN)
    • Flutter version 1.25.0-9.0.pre.2 at /Users/sheep/Project/flutter_beta
    • Framework revision 5d36f2e7f5 (3 weeks ago), 2021-01-14 15:57:49 -0800
    • Engine revision 7a8f8ca02c
    • Dart version 2.12.0 (build 2.12.0-133.7.beta)
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/sheep/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android
    Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
    1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

    [✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

    [✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
    🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
    🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
    1.8.0_242-release-1644-b3-6915495)

    [✓] Connected device (1 available)
    • SKW A0 (mobile) • 7692d5ee • android-arm64 • Android 10 (API 29)
    wuliaoshixia
        14
    wuliaoshixia  
    OP
       2021-02-04 22:38:10 +08:00
    @hongch gradle 应该是下载下来了,执行 flutter run -v,发现卡在下面这个步骤了
    [ +914 ms] Welcome to Gradle 6.7!
    [ ] Here are the highlights of this release:
    [ ] - File system watching is ready for production use
    [ ] - Declare the version of Java your build requires
    [ ] - Java 15 support
    [ ] For more details see https://docs.gradle.org/6.7/release-notes.html
    [ +187 ms] Starting a Gradle Daemon, 3 busy Daemons could not be reused, use --status for details
    wuliaoshixia
        15
    wuliaoshixia  
    OP
       2021-02-04 22:40:55 +08:00
    找到原因了,原来是依赖没有下载下来😂
    [+378206 ms] FAILURE: Build failed with an exception.
    [ +12 ms] * What went wrong:
    [ ] A problem occurred configuring root project 'android'.
    [ ] > Could not resolve all artifacts for configuration ':classpath'.
    [ ] > Could not download kotlin-compiler-embeddable-1.3.50.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.50)
    [ ] > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.3.50/kotlin-compiler-embeddable-1.3.50.jar'.
    [ ] > Read timed out
    [ ] > Could not download kotlin-daemon-embeddable-1.3.50.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.50)
    [ ] > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-daemon-embeddable/1.3.50/kotlin-daemon-embeddable-1.3.50.jar'.
    [ ] > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-daemon-embeddable/1.3.50/kotlin-daemon-embeddable-1.3.50.jar'.
    [ +17 ms] > Remote host closed connection during handshake
    [ ] * Try:
    [ ] Run 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.
    [ ] * Get more help at https://help.gradle.org
    [ ] BUILD FAILED in 6m 19s
    wuliaoshixia
        16
    wuliaoshixia  
    OP
       2021-02-04 22:42:42 +08:00
    @zeropercenthappy 果然还是得用梯子先下一下依赖。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5257 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 05:53 · PVG 13:53 · LAX 22:53 · JFK 01:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.