记录一个flutter打包aar异常问题

执行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.")
    }

重新执行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内的hosted目录下


记录一个flutter打包aar异常问题_第1张图片
image.png

将pub.dartlang.org与pub.flutter-io.cn文件夹目录下的url_launcher_macos相关缓存都删除了,重新执行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.

你可能感兴趣的:(记录一个flutter打包aar异常问题)