ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Using Flutter 2 on M1 MacOS Apple Silicon

2021-07-14 19:01:32  阅读:2045  来源: 互联网

标签:MacOS Apple Silicon studio install Android flutter Contents


What I want?

Building universal apps for iOS, Android, Windows, MacOS, Linux using Flutter on a M1 Mac.

 

This is very new and latest. I can't guarantee you can make it at 100%.

There's no official support since Apple silicon is still new in coding world.

 

Their full tutorial is here: https://flutter.dev/docs/get-started/install/macos

 

Here i only address some issues i met.

TL;DR

 

what we need?

1. Android studio preview 2021.1.1 Canery 3 (latest which supports m1)

2. flutter 2 SDK (latest stable version)

3. java sdk ( openjdk 11 from zulu built for macos arm64)

4. cocoapods ( Open your Terminal.app with Rosetta 2 )

 

Step 1 is very easy. 

go https://developer.android.com/studio/archive

and download the one for m1 mac.

 

 

when you open the android studio, don't forget to install all the SDK you need. Here is one important tool. Android SDK command-line Tools 

 

Install the Flutter 2.

go here: https://flutter.dev/docs/get-started/install/macos

Very easy just follow the steps.

 

I need to build apps for desktop so i enabled this(you don't have to, this is optional if you only want to build apps for iOS and Android): https://flutter.dev/desktop

 

Then use commands 

flutter doctor -v

to check your system

 

I had this issue with my Android Studio Preview

 

 

Solve it 

Android Toolchains. Install all the SDK that you need when you open the Android Studio Preview for the first time. 

Xcode. Install Xcode from Apps Store and install xcode command lines. Just wait by several clicks.

cocoapods. Copy and paste a new Terminal.app to desktop and open it using Rosetta 2 like this.

Then in the rosetta 2 terminal, install cocoapods by commands

sudo gem install cocoapods

Ruby 2 is installed on MacOS 11 by default but its fii lib is still built on top of x86_64 architecture though Apple claimed Ruby 2 on MacOS 11 is for 2 architectures such as x86_64 and ARM64, which is a lie.

If you simply install cocoapods using the ARM64 version of ruby 2 on MacOS 11, you will fail to load the fii libs. fii is a lib which can talk to native c libs on macos, we need it so much.

 

Android studio: Unable to find bundled java version.

Solution: https://github.com/flutter/flutter/issues/76215#issuecomment-864407892

in source codes,

flutter/packages/flutter_tools/lib/src/android/android_studio.dart

Line 465 in 3c72ef3

 globals.fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home') : 

There should be check for
join(directory, 'jre', 'Contents', 'Home') instead of
join(directory, 'jre', 'jdk', 'Contents', 'Home')

for newest android studio previews (at least on macos).
Workaround for such people: copy folder

/Applications/Android Studio Preview.app/Contents/jre/Contents to
/Applications/Android Studio Preview.app/Contents/jre/jdk/Contents

Just copy the folder Contents to a new folder jdk inside of the main app. (This is a bug which would be fixed in the future)

 

 

Then go back to my normal terminal which is ARM64 native and do the doctor check.

标签:MacOS,Apple,Silicon,studio,install,Android,flutter,Contents
来源: https://www.cnblogs.com/spaceship9/p/15012451.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有