领域与Android数据绑定混淆

时间:2018-05-15 10:57:18

标签: android kotlin realm android-databinding

我有一个构建正常的应用程序,但只要我使用@ RealmClass / RealmModel或RealmObject使我的一个类感知Realm,我就会收到大量错误,如下所示。

这是一个错误还是我做错了什么?

e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AccountsmoduleBinding.java:49: error: cannot find symbol protected AccountsmoduleBinding(DataBindingComponent _bindingComponent, View _root, ^ symbol: class DataBindingComponent location: class AccountsmoduleBinding w: C:\Dane.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jre7\1.1.4-2\272a21c30432c943d618008fbbd34762eb0d6c8a\kotlin-stdlib-jre7-1.1.4-2.jar: kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AccountsmoduleBinding.java:79: error: cannot find symbol @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AccountsmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AccountsmoduleBinding.java:90: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AccountsmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AccountsmoduleBinding.java:101: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AccountsmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AllaccountsmoduleBinding.java:18: error: cannot find symbol protected AllaccountsmoduleBinding(DataBindingComponent _bindingComponent, View _root, ^ symbol: class DataBindingComponent location: class AllaccountsmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AllaccountsmoduleBinding.java:38: error: cannot find symbol @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AllaccountsmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AllaccountsmoduleBinding.java:49: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AllaccountsmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AllaccountsmoduleBinding.java:60: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AllaccountsmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AnotherfragmentLayoutBinding.java:22: error: cannot find symbol protected AnotherfragmentLayoutBinding(DataBindingComponent _bindingComponent, View _root, ^ symbol: class DataBindingComponent location: class AnotherfragmentLayoutBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AnotherfragmentLayoutBinding.java:43: error: cannot find symbol @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AnotherfragmentLayoutBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AnotherfragmentLayoutBinding.java:54: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AnotherfragmentLayoutBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AnotherfragmentLayoutBinding.java:65: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AnotherfragmentLayoutBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AppactivationmoduleBinding.java:82: error: cannot find symbol protected AppactivationmoduleBinding(DataBindingComponent _bindingComponent, View _root, ^ symbol: class DataBindingComponent location: class AppactivationmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AppactivationmoduleBinding.java:126: error: cannot find symbol @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AppactivationmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AppactivationmoduleBinding.java:137: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AppactivationmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\AppactivationmoduleBinding.java:148: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class AppactivationmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\BiometryloginmoduleBinding.java:62: error: cannot find symbol protected BiometryloginmoduleBinding(DataBindingComponent _bindingComponent, View _root, ^ symbol: class DataBindingComponent location: class BiometryloginmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\BiometryloginmoduleBinding.java:97: error: cannot find symbol @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class BiometryloginmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\BiometryloginmoduleBinding.java:108: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class BiometryloginmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\BiometryloginmoduleBinding.java:119: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class BiometryloginmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\ConfirmationmoduleBinding.java:41: error: cannot find symbol protected ConfirmationmoduleBinding(DataBindingComponent _bindingComponent, View _root, ^ symbol: class DataBindingComponent location: class ConfirmationmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\ConfirmationmoduleBinding.java:68: error: cannot find symbol @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class ConfirmationmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\ConfirmationmoduleBinding.java:79: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class ConfirmationmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\ConfirmationmoduleBinding.java:90: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class ConfirmationmoduleBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\DashboardmoduleaccountsfragmentBinding.java:30: error: cannot find symbol protected DashboardmoduleaccountsfragmentBinding(DataBindingComponent _bindingComponent, ^ symbol: class DataBindingComponent location: class DashboardmoduleaccountsfragmentBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\DashboardmoduleaccountsfragmentBinding.java:54: error: cannot find symbol @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class DashboardmoduleaccountsfragmentBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\DashboardmoduleaccountsfragmentBinding.java:65: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class DashboardmoduleaccountsfragmentBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\DashboardmoduleaccountsfragmentBinding.java:76: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class DashboardmoduleaccountsfragmentBinding e: C:\Dane\Projekty\Livecycle\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\pl\qus\livecycle\databinding\DashboardmoduleBinding.java:30: error: cannot find symbol protected DashboardmoduleBinding(DataBindingComponent _bindingComponent, View _root,

CUT

Gradle插件:

apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: "kotlin-kapt" apply plugin: 'realm-android' apply plugin: 'org.jetbrains.dokka-android'

数据类:

@RealmClass open class AccountData ( @PrimaryKey @SerializedName("id") var _id : String = "", var accountNumber: String = "", @SerializedName("type") var _type : String = "", var name : String = "", var availableFunds: Float = 0f, var balance: Float = 0f, @SerializedName("currency") var _currency: String = "", var ownerName : String = "", var interestRate : Float = 0f, var sortCode : String = "", var iban : String = "", var openingDate : String = "", var overdraft : Float = 0f, var lockedFunds : Float = 0f, var creditLimit : Float = 0f, var defaultName: String = "" ) : RealmModel { var type : AccountType get() = AccountType.valueOf(_type) set(value) { _type = value.name }

var currency : CurrencyType
    get() = CurrencyType.valueOf(_currency)
    set(value) { _currency = value.name }

var currency : CurrencyType get() = CurrencyType.valueOf(_currency) set(value) { _currency = value.name }

1 个答案:

答案 0 :(得分:3)

@RealmClass
open class AccountData (
    ...
) : RealmModel {
    var type : AccountType  // <-- this is not a supported field type
        get() = AccountType.valueOf(_type)
        set(value) { _type = value.name }

var currency : CurrencyType // <-- this is not a supported field type
    get() = CurrencyType.valueOf(_currency)
    set(value) { _currency = value.name }
}

您需要使用@Ignore注释标记不受支持的“帮助”字段。

@field:Ignore
var type : AccountType  // <-- this is not a supported field type
    get() = AccountType.valueOf(_type)
    set(value) { _type = value.name }

@field:Ignore
var currency : CurrencyType // <-- this is not a supported field type
    get() = CurrencyType.valueOf(_currency)
    set(value) { _currency = value.name }
}