Flutter-Android编译报错与解决方案汇总

报错一:java.lang.NullPointerException: Cannot invoke "String.length()" because "" is null

解决方案:

I solved this problem by upgrading Android Gradle Plugin to version 8.3.1.

You can use Tools->AGP Upgrade Assistant to upgrade Android Gradle plugin.

报错二:Namespace not specified. Specify a namespace in the module's build file.

解决方案:

allprojects {

repositories {

google()

mavenCentral()

}

// This code is where all the magic happens and fixes the error.

subprojects {

afterEvaluate { project ->

if (project.hasProperty('android')) {

project.android {

if (namespace == null) {

namespace project.group

}

}

}

}

}

// This code is where all the magic happens and fixes the error.

}

报错三:Class 'kotlin.Suppress' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

解决方案:

https://stackoverflow.com/questions/67699823/module-was-compiled-with-an-incompatible-version-of-kotlin-the-binary-version-o

The expected version is the Kotlin for kotlin-gradle-plugin

The binary version is what is downloaded (or previously compiled) for com.android.tools.build:gradle

buildscript {

ext.kotlin_version = '1.5.20' // <= expected version is 1.5.1

}

dependencies {

classpath 'com.android.tools.build:gradle:7.3.1' // downloads 1.7.1 Metadata

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // <= 1.5.20 used here

}

KGP、Gradle、AGP版本对应表:https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin

通过差对应表,将主工程下的KGP版本升级即可。

From

ext.kotlin_version = '1.7.10'

to

ext.kotlin_version = '2.0.0'

相关推荐
geovindu9 小时前
sql:Search-Optimized SQL Queries using mysql 9.0
android·数据库·sql·mysql·数据库开发·数据库架构
程序员老刘10 小时前
Flutter你看看人家RN
flutter·react native·ai编程
知之则吱吱11 小时前
Android 开发者验证机制迎来新变化:核心要求、实施时间与开发者应对指南
android·google
墨天梦12 小时前
D09_Retrofit接口与数据转换
android·kotlin·retrofit
电商API_1800790524713 小时前
闲鱼商品列表API接口商品详情API接口请求示例(含一份真实响应数据示例)
android·数据挖掘·网络爬虫·跨境电商·反向海淘
我命由我1234513 小时前
Android 广播 - 组件通信
android·java·开发语言·android studio·android jetpack·android-studio·android runtime
阿俊-全栈开发13 小时前
LikeShop 单商户标准版商品管理二开:分类、SKU 规格与库存联动实现
android·likeshop·likeshop开源商城
用户21816970493016 小时前
Kotlin 语法二
android
妖星16 小时前
android 源码分析surfaceFinger是如何通过设置属性启动bootanim
android