增加依赖:flutter pub add path_provider
使用命令: flutter run -v 提示错误
解决方案:
- 打开 .\android\settings.gradle 文件,版本号更新为最新。
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.7.3" apply false
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
}
- 打开 .\android\gradle\wrapper\gradle-wrapper.properties 文件,更新bradle。
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
-
如果在线下载不了,可以离线下载解压到 C:\Users\Jack-PC.gradle\wrapper\dists\gradle-8.11.1-all\2qik7nd48slq1ooc2496ixf4i 文件夹下即可.
-
打开 .\android\app\build.gradle 文件,更新NDK版本。
android {
namespace = "com.example.flutter_app1"
compileSdk = flutter.compileSdkVersion
ndkVersion = rootProject.ext["flutter.ndkVersion"] ?: 'default'
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.flutter_app1"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
- 打开 .\android\gradle.properties 文件,配置DNK版本。
flutter.ndkVersion=27.2.12479018
标签:wrapper,gradle,provider,id,path,android,com,flutter
From: https://www.cnblogs.com/yangwenli/p/18592592