you can find the compileSdkVersion under: android > app > build.gradle
你可以在android > app > build.gradle下找到compileSdkVersion
android {
compileSdkVersion 31
...
}
android {
compileSdkVersion 33
...
}
You can got error with the version 31, it’s not works, try this
it's works for me .
你可以得到错误的版本31,它不工作,试试这个,它是对我的工作。
Check with your configuration in android/app/src/build.gradle file
with new version of flutter compileSdk and targetSdkVersion are mention as below
使用新版Ffltter编译器检查您在android/app/src/build.gradle文件中的配置Sdk和Target SdkVersion如下
android {
compileSdkVersion flutter.compileSdkVersion
.....
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.app"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
I had faced the same issue, In case you cloned a GitHub repository and then when you run that code this is the error that comes up(as it happened with me) then Solution :
我曾经遇到过同样的问题,如果您克隆了一个GitHub存储库,然后当您运行该代码时,这是出现的错误(就像我发生的那样),然后解决方案:
Step 1 : Create a new flutter project at your local system
步骤1:在本地系统中创建新的颤动项目
Step 2 : Copy the code given in main.dart
file of stub project and paste it into main.dart
file of your local project
步骤2:复制存根项目的main.dart文件中给定的代码,并将其粘贴到本地项目的main.dart文件中
Step 3 : Make an 'assets' folder in your local project
步骤3:在本地项目中创建一个‘Assets’文件夹
Step 4 : download asset-files from GitHub and put them into your local 'assets' folder
步骤4:从GitHub下载资产文件,并将其放入本地的资产文件夹
Step 5 : in your local pubspec.yaml
file, add dependency for your 'assets' folder
步骤5:在您的本地pubspec.yaml文件中,添加‘Assets’文件夹的依赖项
Step 6 : Rename MyApp()
in widget testing file to MaterialApp()
步骤6:将微件测试文件中的MyApp()重命名为MaterialApp()
Hit save(in files other than pubspec.yaml
), get all dependencies(in pubspec.yaml
) and you're good to go
点击保存(在pubspec.yaml以外的文件中),获取所有依赖项(在pubspec.yaml中),然后就可以开始了
In short :
Copy the required code and the dependencies you want
Then Save the changes and run
简而言之:复制所需的代码和所需的依赖项,然后保存更改并运行
Error was there in my case mainly because the Flutter V2 has many changes and the code was outdated.
在我的情况下,错误主要是因为颤振V2有很多变化,代码过时了。
Go to android/app/build.gradle
进入安卓/APP/build.gradle
Change:
From: compileSdkVersion 29
To: compileSdkVersion 31
将:从:编译SdkVersion 29更改为:编译SdkVersion 31
Please run, then press f you will notice the SDK is the wrong version.
npx react-native doctor
请运行,然后按f键您会注意到SDK版本错误。NPX反应-本地医生
更多回答
我是一名优秀的程序员,十分优秀!