任务 ':rtmp_publisher:compileReleaseKotlin' 执行失败
Posted
技术标签:
【中文标题】任务 \':rtmp_publisher:compileReleaseKotlin\' 执行失败【英文标题】:Execution failed for task ':rtmp_publisher:compileReleaseKotlin'任务 ':rtmp_publisher:compileReleaseKotlin' 执行失败 【发布时间】:2021-11-20 11:16:27 【问题描述】:编译项目(构建 apk)时返回错误:
e: C:\Users\1\FlutterSDK\flutter\.pub-cache\hosted\pub.dartlang.org\rtmp_publisher-0.3.7\android\src\main\kotlin\com\app\rtmp_publisher\Camera.kt: (634, 49): Unresolved reference: startStream
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':rtmp_publisher:compileReleaseKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Kotlin 版本相关
Gradle 文件 android\build.gradle:
buildscript
ext.kotlin_version = '1.5.10'
repositories
google()
jcenter()
dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
classpath 'com.android.tools.build:gradle:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
allprojects
repositories
google()
jcenter()
rootProject.buildDir = '../build'
subprojects
project.buildDir = "$rootProject.buildDir/$project.name"
subprojects
project.evaluationDependsOn(':app')
task clean(type: Delete)
delete rootProject.buildDir
Gradle 文件 android\app\build.gradle:
def localProperties = new Properties()
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 FileNotFoundException("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"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists())
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android
compileSdkVersion 30 // was 28
// added for rtmp
packagingOptions
exclude 'project.clj'
sourceSets
main.java.srcDirs += 'src/main/kotlin'
lintOptions
disable 'InvalidPackage'
defaultConfig
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "youinroll.com"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
versionCode 3
signingConfigs
release
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
buildTypes
release
signingConfig signingConfigs.release
shrinkResources false
minifyEnabled false
allprojects
repositories
google()
mavenCentral()
mavenurl "https://storage.googleapis.com/download.flutter.io"
flutter
source '../..'
dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
应用程序已使用手机摄像头进行广播,问题出在其中。 显然问题出在 connectimg java 和 kotlin 中。 更新和删除颤振/gradle 执行。
【问题讨论】:
【参考方案1】:升级项目和 gradle 设置后,我遇到了同样的问题。
我设法通过减少 kotlin 版本来解决这个问题
ext.kotlin_version = '1.3.50'
这开始给出代码编译问题,为此,我从 build.gradle 文件中删除了这一行
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
【讨论】:
以上是关于任务 ':rtmp_publisher:compileReleaseKotlin' 执行失败的主要内容,如果未能解决你的问题,请参考以下文章