我有一个工作的扑动项目,但当我安装agora RTC包它给执行失败的任务':agora_rtc_engine:compileDebugKotlin'。错误。我甚至还没有使用这个包,我试着设置权限和所有的说明在自介绍部分,但我认为问题是与包本身,我的flutter项目是零安全迁移,它正在工作,所以我确信没有什么问题与我的项目。
我还没有使用这个包。只要安装它就会出现错误。
这里是app/gradle.build
:
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.malhamti_app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
这是我的android/build.gradle
:
ext.kotlin_version = '1.6.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这里是gradle --stacktrace
:参见完整的stacktrace(字符限制)
> Task :agora_rtc_engine:compileProfileKotlin FAILED
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraRtcEnginePlugin.kt: (251, 18): Type mismatch: inferred type is String? but String was expected
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraSurfaceViewFactory.kt: (16, 1): Class 'AgoraSurfaceViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraSurfaceViewFactory.kt: (20, 3): 'create' overrides nothing
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraTextureViewFactory.kt: (12, 1): Class 'AgoraTextureViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraTextureViewFactory.kt: (17, 3): 'create' overrides nothing
> Task :agora_rtc_engine:compileDebugKotlin FAILED
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraRtcEnginePlugin.kt: (251, 18): Type mismatch: inferred type is String? but String was expected
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraSurfaceViewFactory.kt: (16, 1): Class 'AgoraSurfaceViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraSurfaceViewFactory.kt: (20, 3): 'create' overrides nothing
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraTextureViewFactory.kt: (12, 1): Class 'AgoraTextureViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraTextureViewFactory.kt: (17, 3): 'create' overrides nothing
> Task :agora_rtc_engine:compileReleaseKotlin FAILED
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraRtcEnginePlugin.kt: (251, 18): Type mismatch: inferred type is String? but String was expected
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraSurfaceViewFactory.kt: (16, 1): Class 'AgoraSurfaceViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraSurfaceViewFactory.kt: (20, 3): 'create' overrides nothing
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraTextureViewFactory.kt: (12, 1): Class 'AgoraTextureViewFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory
e: /Users/doabletech/Development/Tools/flutter_sdk/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-5.1.0/android/src/main/kotlin/io/agora/agora_rtc_engine/AgoraTextureViewFactory.kt: (17, 3): 'create' overrides nothing
FAILURE: Build completed with 3 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':agora_rtc_engine:compileProfileKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
see full [stacktrace][3] here (character limit)
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':agora_rtc_engine:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
see full [stacktrace][3] here (character limit)
==============================================================================
3: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':agora_rtc_engine:compileReleaseKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
see full [stacktrace][3] here (character limit)
BUILD FAILED in 4s
49 actionable tasks: 49 executed
我发现了这个问题,这是因为我正在使用扑动开发通道,如果您遇到同样的问题,请确保您使用的是最新的flutter稳定版本,以执行以下操作:
- run
flutter channel stable
确保您的pubspec.yaml
文件已将flutter版本更改为稳定版本,
- run
flutter clean
- 运行
flutter run
你可能会从flutter lint
包中得到一个错误,我通过删除它来解决这个问题。
- 来源:Github
编辑:似乎有一个问题与flutter 3.0.0导致与agora相同的错误,将flutter降级到2.12.5为我解决了这个问题。