记录一个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目录下


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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。