本文最后更新于 2026年5月11日。
检查是否有模拟器
(TraeAI-3) E:\mydoc\sync_pc_home_work\myWPapp\wordpress_app [0:0] $ flutter emulators
Flutter assets will be downloaded from https://mirrors.ustc.edu.cn/flutter.
Make sure you trust this source!
1 available emulator:
Id • Name • Manufacturer • Platform
Medium_Phone_API_36.1 • Medium Phone API 36.1 • Generic • android
To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.
You can find more information on managing emulators at the links below:
https://developer.android.com/studio/run/managing-avds
https://developer.android.com/studio/command-line/avdmanager
(TraeAI-3) E:\mydoc\sync_pc_home_work\myWPapp\wordpress_app [0:0] $
启动模拟器
我发现有一个可用的Android模拟器"Medium_Phone_API_36.1"。现在启动这个模拟器,然后我们可以在模拟器上运行应用来避免跨域错误。
flutter emulators --launch Medium_Phone_API_36.1
检查设备状态
(TraeAI-3) E:\mydoc\sync_pc_home_work\myWPapp\wordpress_app [0:0] $ flutter devices
Flutter assets will be downloaded from https://mirrors.ustc.edu.cn/flutter.
Make sure you trust this source!
Found 4 connected devices:
sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 16
(API 36) (emulator)
Windows (desktop) • windows • windows-x64 • Microsoft
Windows [Version 10.0.26100.7462]
Chrome (web) • chrome • web-javascript • Google
Chrome 143.0.7499.41
Edge (web) • edge • web-javascript • Microsoft
Edge 143.0.3650.80
Run "flutter emulators" to list and start any available device emulators.
If you expected another device to be detected, please run "flutter doctor"
to diagnose potential issues. You may also try increasing the time to wait
for connected devices with the "--device-timeout" flag. Visit
https://flutter.dev/setup/ for troubleshooting tips.
模拟器上运行
模拟器已成功启动并连接到Flutter开发环境。现在我可以在模拟器上运行应用程序,这样就能避免浏览器中的跨域错误了
flutter run -d emulator-5554
打包成apk命令
flutter build apk --release --target-platform android-arm64
md编辑器与api搜索冲突需要禁用
自定义CPT时使用类似下面的api端点
/wp-json/wp/v2/yiyuan
默认的端点时posts
/wp-json/wp/v2/posts?_embed&per_page=10&page=1&status=publish,private,draft
第一次打包花了约1h,没成功
(TraeAI-7) E:\mydoc\sync_pc_home_work\myWPapp\wordpress_app [0:0] $ flutter build apk --no-shrink
Resolving dependencies...
Downloading packages...
characters 1.4.0 (1.4.1 available)
flutter_secure_storage 9.2.4 (10.0.0 available)
flutter_secure_storage_linux 1.2.3 (3.0.0 available)
flutter_secure_storage_macos 3.1.3 (4.0.0 available)
flutter_secure_storage_platform_interface 1.1.2 (2.0.1 available)
flutter_secure_storage_web 1.2.1 (2.1.0 available)
flutter_secure_storage_windows 3.1.2 (4.1.0 available)
js 0.6.7 (0.7.2 available)
matcher 0.12.17 (0.12.18 available)
material_color_utilities 0.11.1 (0.13.0 available)
test_api 0.7.7 (0.7.8 available)
Got dependencies!
Try `flutter pub outdated` for more information.
Running Gradle task 'assembleRelease'... Checking the license for package NDK (Side by side) 28.2.13676358 in C:\Users\weiyo\AppData\Local\Android\Sdk\licenses
Running Gradle task 'assembleRelease'... License for package NDK (Side by side) 28.2.13676358 accepted.
Running Gradle task 'assembleRelease'... Preparing "Install NDK (Side by side) 28.2.13676358 v.28.2.13676358".
"Install NDK (Side by side) 28.2.13676358 v.28.2.13676358" ready.
Installing NDK (Side by side) 28.2.13676358 in C:\Users\weiyo\AppData\Local\Android\Sdk\ndk\28.2.13676358
"Install NDK (Side by side) 28.2.13676358 v.28.2.13676358" complete.
"Install NDK (Side by side) 28.2.13676358 v.28.2.13676358" finished.
Checking the license for package Android SDK Build-Tools 35 in C:\Users\weiyo\AppData\Local\Android\Sdk\licenses
License for package Android SDK Build-Tools 35 accepted.
Preparing "Install Android SDK Build-Tools 35 v.35.0.0".
"Install Android SDK Build-Tools 35 v.35.0.0" ready.
Installing Android SDK Build-Tools 35 in C:\Users\weiyo\AppData\Local\Android\Sdk\build-tools\35.0.0
"Install Android SDK Build-Tools 35 v.35.0.0" complete.
"Install Android SDK Build-Tools 35 v.35.0.0" finished.
[========= ] 25%
[========= ] 25% Fetch remote repository...
[=======================================] 100% Fetch remote repository...
Checking the license for package Android SDK Platform 34 in C:\Users\weiyo\AppData\Local\Android\Sdk\licenses
License for package Android SDK Platform 34 accepted.
Preparing "Install Android SDK Platform 34 (revision 3)".
"Install Android SDK Platform 34 (revision 3)" ready.
Installing Android SDK Platform 34 in C:\Users\weiyo\AppData\Local\Android\Sdk\platforms\android-34
"Install Android SDK Platform 34 (revision 3)" complete.
"Install Android SDK Platform 34 (revision 3)" finished.
[========= ] 25%
[========= ] 25% Fetch remote repository...
[=======================================] 100% Fetch remote repository...
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 2020 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Checking the license for package CMake 3.22.1 in C:\Users\weiyo\AppData\Local\Android\Sdk\licenses
License for package CMake 3.22.1 accepted.
Preparing "Install CMake 3.22.1 v.3.22.1".
"Install CMake 3.22.1 v.3.22.1" ready.
Installing CMake 3.22.1 in C:\Users\weiyo\AppData\Local\Android\Sdk\cmake\3.22.1
"Install CMake 3.22.1 v.3.22.1" complete.
"Install CMake 3.22.1 v.3.22.1" finished.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseNativeLibs'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
> Could not resolve io.flutter:armeabi_v7a_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
Required by:
project :app
> Could not resolve io.flutter:armeabi_v7a_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/armeabi_v7a_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/armeabi_v7a_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/armeabi_v7a_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/armeabi_v7a_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Got socket exception during request. It might be caused by SSL misconfiguration
> Connection reset
> Could not resolve io.flutter:arm64_v8a_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
Required by:
project :app
> Could not resolve io.flutter:arm64_v8a_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/arm64_v8a_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/arm64_v8a_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Got socket exception during request. It might be caused by SSL misconfiguration
> Connection reset
> Could not resolve io.flutter:x86_64_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
Required by:
project :app
> Could not resolve io.flutter:x86_64_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/x86_64_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/x86_64_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Got socket exception during request. It might be caused by SSL misconfiguration
> Connection reset
> Could not resolve io.flutter:flutter_embedding_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
Required by:
project :app > project :flutter_secure_storage
project :app > project :path_provider_android
> Could not resolve io.flutter:flutter_embedding_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/flutter_embedding_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/flutter_embedding_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Got socket exception during request. It might be caused by SSL misconfiguration
> Connection reset
* 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 49m 7s
Running Gradle task 'assembleRelease'... 2948.3s
[!] Gradle threw an error while downloading artifacts from the network.
Retrying Gradle Build: #1, wait time: 100ms
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseNativeLibs'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
> Could not resolve io.flutter:armeabi_v7a_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
Required by:
project :app
> Could not resolve io.flutter:armeabi_v7a_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/armeabi_v7a_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/armeabi_v7a_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/armeabi_v7a_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/armeabi_v7a_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Got socket exception during request. It might be caused by SSL misconfiguration
> Connection reset
> Could not resolve io.flutter:arm64_v8a_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
Required by:
project :app
> Could not resolve io.flutter:arm64_v8a_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/arm64_v8a_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/arm64_v8a_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Got socket exception during request. It might be caused by SSL misconfiguration
> Connection reset
> Could not resolve io.flutter:x86_64_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
Required by:
project :app
> Could not resolve io.flutter:x86_64_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/x86_64_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/x86_64_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Got socket exception during request. It might be caused by SSL misconfiguration
> Connection reset
> Could not resolve io.flutter:flutter_embedding_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
Required by:
project :app > project :flutter_secure_storage
project :app > project :path_provider_android
> Could not resolve io.flutter:flutter_embedding_release:1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/flutter_embedding_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_release/1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf/flutter_embedding_release-1.0.0-1527ae0ec577a4ef50e65f6fefcfc1326707d9bf.pom'.
> Got socket exception during request. It might be caused by SSL misconfiguration
> Connection reset
* 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 19s
Running Gradle task 'assembleRelease'... 20.1s
[!] Gradle threw an error while downloading artifacts from the network.
Gradle task assembleRelease failed with exit code 1