執(zhí)行flutter build aar后報錯:
FAILURE: Build failed with an exception.
* Where:
Initialization script '/Users/temp/Documents/flutter/packages/flutter_tools/gradle/aar_init_script.gradle' line: 19
* What went wrong:
Android property not found.
* 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 17s
Gradle task assembleAarDebug failed with exit code 0.
問題定位flutter目錄下aar_init_script.gradle文件筑舅,插入throw代碼段茵典,即可顯示哪里出錯。
if (!project.hasProperty("android")) {
throw new GradleException(project.toString())
throw new GradleException("Android property not found.")
}
重新執(zhí)行build操作
FAILURE: Build failed with an exception.
* Where:
Initialization script '/Users/temp/Documents/flutter/packages/flutter_tools/gradle/aar_init_script.gradle' line: 19
* What went wrong:
project ':url_launcher_macos'
* 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.
顯示url_launcher_macos出錯,到flutter目錄下隱藏文件.pub-cache內(nèi)的hosted目錄下
image.png
將pub.dartlang.org與pub.flutter-io.cn文件夾目錄下的url_launcher_macos相關(guān)緩存都刪除了,重新執(zhí)行build aar操作闰渔,打包成功。
Running Gradle task 'assembleAarDebug'...
Running Gradle task 'assembleAarDebug'... Done 57.0s
? Built build/host/outputs/repo.
Running Gradle task 'assembleAarProfile'...
Running Gradle task 'assembleAarProfile'... Done 126.0s (!)
? Built build/host/outputs/repo.
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 96.2s
? Built build/host/outputs/repo.