hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
278 stars 22 forks source link

Flutter: Debug Run with Android Device #237

Open hhstore opened 3 years ago

hhstore commented 3 years ago

related:

hhstore commented 3 years ago

flutter 连接真实设备调试:

flutter 连接真机调试体验:

踩坑:

关于模拟器对比:

ref:

hhstore commented 3 years ago

1. flutter 连接 Android 手机调试开发教程:

1.1 手机设置:

踩坑: 注意 iMac 使用 USB-C 连接 Android 手机, 注意一定要等手机弹出连接选项 -> USB 文件传输模式. 才是正常. 这样 flutter device, 才能找到 Android 手机设备. 数据线, 要支持数据传输, 不能只是充电线.

小米手机可能遇到 apk 安装失败:

1.2 Mac 设置:


-> % flutter run
Multiple devices found:
Redmi K30 Pro (mobile) • b6da3c35                             • android-arm64 • Android 10 (API 29)
iPhone 8 (mobile)      • EF2FA701-7500-48CD-844D-00053D3466A0 • ios           • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
iPhone 11 (mobile)     • AC61ACFD-E743-4CF0-8DE4-9C822A9C1ECF • ios           • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
iPhone 11 Pro (mobile) • F467BF0B-3899-4FF5-81C0-3A9BA90C3993 • ios           • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
[0]: Redmi K30 Pro (b6da3c35)
[1]: iPhone 8 (EF2FA701-7500-48CD-844D-00053D3466A0)
[2]: iPhone 11 (AC61ACFD-E743-4CF0-8DE4-9C822A9C1ECF)
[3]: iPhone 11 Pro (F467BF0B-3899-4FF5-81C0-3A9BA90C3993)
Please choose one (To quit, press "q/Q"): 0
Launching lib/main.dart on Redmi K30 Pro in debug mode...
Running Gradle task 'assembleDebug'...

image

image

1.3 FAQ:

1.3.1 path_provider 报错:

image


# 重新拉包:
flutter pub get

# 删除 build 历史:
flutter clean

# 重新启动:
flutter run

1.3.2 小米手机开发者选项 - 大坑:

image

Running Gradle task 'assembleDebug'... Done                        10.0s
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...                14.0s
Error: ADB exited with exit code 1
Performing Streamed Install

adb: failed to install /Users/henry/Documents/iSpace/hh/flutter-starter/build/app/outputs/flutter-apk/app.apk: Failure
[INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]
Error launching application on Redmi K30 Pro.

-[x] 需要关闭选项: 高风险功能开启提醒. (这一项, 是开发者选项的最后一项) fuck.

image

hhstore commented 3 years ago

flutter 打包发布:

Android 发布:

iOS 发布:

hhstore commented 3 years ago

1

hhstore commented 3 years ago

Android Studio 编译 原生项目:

image

hhstore commented 2 years ago

flutter release 发布包:

Android:


# 打 fat 包, 混合各 arm 版本的 API. 包体积大.
flutter build apk

# 分版本打包, 包体积变小
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi