Flutter打包问题记录

一直用iOS模拟器和真机调试,并没有出现问题。使用了Andorid模拟器或生成APK是报了不少错误。记录以下花费比较长的问题。

问题1
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac

该提示下面还有一堆Could not get.

对于iOS哥哥提示一句,Andorid编译靠的是Gradle,出现此类基本上就是Gradle的配置需要改动。

对于上诉问题,主要是因为Flutter默认的Gradle maven源是qiang外面的,所以我们需要改成国内阿里巴巴的源。由于Flutter.io的下载地址不稳定,我们把两个地址都添加进来。

在 工程名/android/bulid.gradle文件中

修改

    repositories {
//        google()
//        jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
    }
allprojects {
    repositories {
//        google()
//        jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }

        maven { url 'http://download.flutter.io' }
        maven { url "https://storage.googleapis.com/download.flutter.io" }
    }
}

请参考flutter环境安装踩坑

问题2

http请求的权限的添加。由于Andorid9和iOS某个版本之后都禁止了http,只允许https,但是实际情况中秒不了要用http。两个平台需要分别进行设置。

Android解决方案参考

iOS解决方案参考

问题3

Android生成APK需要key

Flutter-Build An Android Release Apk

问题4

app:lintVitalRelease

Android Studio打包时候报错:app:lintVitalRelease

额外参考

https://flutter.dev/docs/deployment/android

https://flutter.dev/docs/deployment/ios

你可能感兴趣的:(Flutter打包问题记录)