i have a working flutter project but when i install agora RTC package it gives Execution failed for task ':agora_rtc_engine:compileDebugKotlin'. error. I'm not even using the package yet, i tried setting up the permissions and all the instructions in the readme section but i think the issue is with the package itself, also my flutter project is null-safety migrated and it's working so I'm sure there's nothing wrong with my project.
I'm not using the package yet. It gives an error just by installing it.
here is the 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"
}
here is my 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
}
here is the gradle --stacktrace
:
see full stacktrace (character limit)
> 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
CodePudding user response:
i found the issue, it's because i was using flutter dev channel, if you have the same issue, make sure you are using the latest flutter stable version, to do this:
- run
flutter channel stable
make sure your pubspec.yaml
file has changed the flutter version to the stable version,
- run
flutter clean
- run
flutter run
you may get an error from flutter lint
package, i solved this issue by removing it.
- source: Github