老师我把flutter引入后运行native程序报如下错误
Execution failed for task ‘:flutter:compileDebugLibraryResources’.
A failure occurred while executing com.android.build.gradle.tasks.CompileLibraryResourcesTaskCompileLibraryResourcesActionCouldnotisolatevaluecom.android.build.gradle.tasks.CompileLibraryResourcesTaskCompileLibraryResourcesAction Could not isolate value com.android.build.gradle.tasks.CompileLibraryResourcesTaskCompileLibraryResourcesActionCouldnotisolatevaluecom.android.build.gradle.tasks.CompileLibraryResourcesTaskCompileLibraryResourcesParams_Decorated@350ec077 of type CompileLibraryResourcesTask.CompileLibraryResourcesParams
Could not resolve all dependencies for configuration ‘:flutter:detachedConfiguration1’.
The project declares repositories, effectively ignoring the repositories you have declared in the settings.
You can figure out how project repositories are declared by configuring your build to fail on project repositories.
See https://docs.gradle.org/7.3.3/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories for details.
Could not find com.android.tools.build:aapt2:7.2.1-7984345.
Searched in the following locations:
- https://storage.flutter-io.cn/download.flutter.io/com/android/tools/build/aapt2/7.2.1-7984345/aapt2-7.2.1-7984345.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in ‘Maven POM’ format, you need to adjust the ‘metadataSources { … }’ of the repository declaration.
Required by:
project :flutter
Could not resolve all files for configuration ‘:flutter:debugCompileClasspath’.
Could not find androidx.lifecycle:lifecycle-common:2.2.0.
Required by:
Caused by: org.gradle.internal.snapshot.impl.IsolationException: Could not isolate value com.android.build.gradle.tasks.CompileLibraryResourcesTask$CompileLibraryResourcesParams_Decorated@350ec077 of type CompileLibraryResourcesTask.CompileLibraryResourcesParams
project :flutter > io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187
Could not find androidx.lifecycle:lifecycle-common-java8:2.2.0.
Required by:
project :flutter > io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187
Could not find androidx.lifecycle:lifecycle-runtime:2.2.0.
Required by:
Caused by: org.gradle.api.internal.artifacts.configurations.ResolveExceptionWithHints: Could not resolve all dependencies for configuration ‘:flutter:detachedConfiguration1’.
project :flutter > io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187
Could not find androidx.fragment:fragment:1.1.0.
Required by:
project :flutter > io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187
Could not find androidx.annotation:annotation:1.1.0.
Required by:
project :flutter > io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187
Could not find androidx.tracing:tracing:1.0.0.
Required by:
project :flutter > io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187
Could not find androidx.core:core:1.6.0.
Required by:
project :flutter > io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187
Could not find androidx.window:window-java:1.0.0-beta04.
Required by:
project :flutter > io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187
setti.gradle和app下的build。gradle如下
import org.gradle.api.initialization.resolve.RepositoriesMode
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "MyNative"
include ':app'
include ':flutter_module'
setBinding(new Binding([gradle: this]))
evaluate(new File(
settingsDir.parentFile,
'flutter_module/.android/include_flutter.groovy'// new
))
project(':flutter_module').projectDir = new File('../flutter_module')
plugins {
id 'com.android.application’
id ‘org.jetbrains.kotlin.android’
}
apply plugin: ‘kotlin-android’
android {
compileSdk 32
defaultConfig {
applicationId "com.paladin.mynative"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
repositories {maven {url("https://maven.aliyun.com/repository/google")}}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation project(':flutter')
}
repositories {
mavenCentral()
}