我正在通过AppCenter构建Flutter Android应用。
我的以下构建脚本取自here
#!/usr/bin/env bash
#Place this script in project/android/app/
cd ..
# fail if any command fails
set -e
# debug log
set -x
cd ..
git clone -b dev https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter doctor
echo "Installed flutter to `pwd`/flutter"
flutter build apk --release
#copy the APK where AppCenter will find it
mkdir -p android/app/build/outputs/apk/; mv build/app/outputs/apk/release/app-release.apk $_
以下是构建日志的摘录:
...
Downloading ios-deploy... 0.4s
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v1.9.7, on Mac OS X 10.14.6 18G87, locale en)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[!] Android Studio (not installed)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
++ pwd
+ echo 'Installed flutter to /Users/vsts/agent/2.155.1/work/1/s/flutter'
+ flutter build apk --release
Installed flutter to /Users/vsts/agent/2.155.1/work/1/s/flutter
Running "flutter pub get" in s... 4.1s
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle...
Sending crash report to Google.
...
像AppCenter一样无法初始化Gradle。 有什么建议么? .gitignore文件:
# Android related
#**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
#**/android/gradlew
#**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
答案 0 :(得分:1)
flutter build apk --release
在本地工作吗?
您在Appcenter中使用哪些构建设置?
您是否像本教程中那样更新了.gitignore?
请尝试提供更多信息。
上周我遇到了类似的问题,我通过添加pre-post.sh来解决了该问题,但看来您遇到了其他问题。
尝试flutter clean
和flutter build
。然后尝试重新构建。
答案 1 :(得分:1)
我也面临着类似的问题。另一种方法是将apk释放到appcenter的发布部分。
答案 2 :(得分:0)
也许不被接受的android许可证正在减慢速度..因为您使用的是某些android软件包。
尝试
flutter doctor --android-licenses
并接受所有许可,然后再尝试