遇到的問題:
ERROR: Unable to find method 'org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(Ljava/lang/String;Lorg/gradle/api/internal/file/FileResolver;)V'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
解決的辦法: "File"->"Settings"->"Languages & Frameworks"->"Kotlin", 選擇:
檢查了build.gradle:
buildscript {
ext.kotlin_version = '1.0.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
修正: ext.kotlin_version = '1.3.50'
然後編譯遇到了個大坑:
More than one file was found with OS independent path 'lib/armeabi-v7a/libScreenRecordLib.so'
報錯截圖:
後來發現需要做如下配置build.gradle(app):
android {
...
packagingOptions {
exclude 'lib/armeabi-v7a/libScreenRecordLib.so'
exclude 'lib/x86_64/libScreenRecordLib.so'
exclude 'lib/arm64-v8a/libScreenRecordLib.so'
exclude 'lib/x86/libScreenRecordLib.so'
}
}
問題成功解決