实施时发生错误 livekit_client: ^0.5.9 package #flutter

Error occurred while implement livekit_client: ^0.5.9 package #flutter

错误:

失败:构建失败,出现异常。

Could not load compiled classes for build file 'C:\src\flutter.pub-cache\hosted\pub.dartlang.org\livekit_client-0.5.9\android\build.gradle' from cache. Failed to notify project evaluation listener. Could not get unknown property 'android' for project ':livekit_client' of type org.gradle.api.Project. Could not find method implementation() for arguments [project ':flutter_webrtc'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Could not find method implementation() for arguments [project ':device_info_plus'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Could not get unknown property 'android' for project ':livekit_client' of type org.gradle.api.Project.

6 秒内构建失败 异常:Gradle 任务 assembleDebug 失败,退出代码为 1

**Flutter version**
PS D:\AndroidStudioProjects\git_repo\talky> flutter --version
Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5464c5bac7 (3 weeks ago) • 2022-04-18 09:55:37 -0700
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2
PS D:\AndroidStudioProjects\git_repo\talky>



**AndroidMainfest.xml**

required permissions +
<application
    .....
    .....
 <service    
android:name="de.julianassmann.flutter_background.IsolateHolderService"
            android:enabled="true"
            android:exported="false"
            android:foregroundServiceType="mediaProjection" />
    </application>


**Kotlin version - 1.6.10
Project level Build gradle
Dependency
**

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

flutter clean,pub get,invalidcash 重启无效

我是如何通过以下方法解决我的问题的:

从中删除制作包的问题 /.pub-cache/hosted/pub.dartlang.org

运行 flutter pub get 改变这个:

distributionUrl=https://services.gradle.org/distributions/gradle-5.6.2-all.zip 为此:

distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip 然后在 project-folder/buil.gradle

改变这个:

类路径'com.android.tools.build:gradle:3.5.0' 为此:

类路径'com.android.tools.build:gradle:4.1.1' 然后 运行 这个命令

颤动干净

构建或运行 您的项目。在此版本中 livekit_client : ^0.5.9 android gradle 已更新。这就是为什么我们需要将 android 项目 gradle 更新到 4.1.1.

祝你好运。