请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

混合后运行报错

老师我把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


2: Task failed with an exception.

  • What went wrong:
    Execution failed for task ‘:flutter:compileDebugJavaWithJavac’.

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()
}


正在回答 回答被采纳积分+3

2回答

宝慕林9277168 2023-05-05 01:06:31

能问下 修改了flutter的sdk 中的哪个gradle 吗?

0 回复 有任何疑惑可以回复我~
  • 已解决这个问题。具体可以参考这个链接:https://blog.csdn.net/qq_36162336/article/details/129854348
    回复 有任何疑惑可以回复我~ 2023-07-03 17:47:19
  • 提问者 慕工程2421507 #2
    flutter/packages/flutter_tools/gradle/flutter.gradle 修改的这里面的
    回复 有任何疑惑可以回复我~ 2023-07-04 10:09:45
学术袁 2022-08-19 14:15:58

可能是jdk、gradle版本问题导致的。
https://developer.android.google.cn/studio/releases/gradle-plugin?hl=zh-cn

0 回复 有任何疑惑可以回复我~
  • 提问者 慕工程2421507 #1
    感谢回复已经解决了 不是gradle问题 需要修改flutter的sdk目录下的gradle
    回复 有任何疑惑可以回复我~ 2022-08-31 14:45:44
  • 慕婉清3015855 回复 提问者 慕工程2421507 #2
    请问这个问题是如何解决的,能提供一些细节吗?
    回复 有任何疑惑可以回复我~ 2023-06-29 22:35:41
  • 提问者 慕工程2421507 回复 慕婉清3015855 #3
    抱歉才看到 我是修改的flutter/packages/flutter_tools/gradle/flutter.gradle把maven库指定里代理仓库就好了,看到你上面回复了 解决了就好 抱歉哈
    回复 有任何疑惑可以回复我~ 2023-07-04 10:14:05
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信