我想使用名爲Holdr的庫(https://github.com/evant/holdr)根據我的佈局文件生成類,以便在我的活動中輕鬆引用這些佈局中的視圖。Kotlin中Holdr的未解決的引用
我可以驗證類生成在構建時細
./gradlew assembleDebug
佈局activity_main.xml中類生成Holdr_ActivityMain.java在
app/build/generated/source/holdr/
科特林任務
期間給了我兩個錯誤:app:compileDebugKotlin
錯誤
e: (8, 44): Unresolved reference: holdr
e: (12, 24): Unresolved reference: Holdr_ActivityMain
這裏是我的類
import com.myapp.holdr.Holdr_ActivityMain
public class MainActivity : Activity() {
private var holdr: Holdr_ActivityMain? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
這裏是我的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.holdr'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/java'
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
buildscript {
ext.kotlin_version = '0.10.770'
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka.holdr:gradle-plugin:1.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
任何幫助,將不勝感激,謝謝。
相關問題科特林的錯誤追蹤系統:https://youtrack.jetbrains.com/issue/KT-17989 – BoD 2017-05-21 13:22:42