2

Я не могу добавить notifyPropertyChanged (int itemId) из-за определенной проблемы в gradle, я думаю!BR не может быть разрешен

любая помощь будет хорошо оценили

public class RegisterForm extends BaseObservable { 
    @Bindable 
    public String firstName; 


    @Bindable 
    public int getFirstNameLabelVisibility(){ 
     return TextUtils.isEmpty(firstName) ? View.INVISIBLE : View.VISIBLE; 
    } 

    public void setFirstNameFromView(String firstNameFromView) { 
     firstName = firstNameFromView; 

//  notifyPropertyChanged(BR.firstName); this line is giving error! 
    } 


} 

build.gradle // для App

apply plugin: 'com.android.application' 
apply plugin: 'com.android.databinding' 
apply plugin: 'android-apt' 
android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.example.jivrajsingh.databindingimp" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_7 
     targetCompatibility JavaVersion.VERSION_1_7 
    } 
} 
configurations { 
    apt 
} 
dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    apt 'com.android.databinding:compiler:1.0-rc0' 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.squareup.okhttp:okhttp:2.4.0' 
    compile 'com.google.android.gms:play-services-auth:8.3.0' 
    compile 'com.google.android.gms:play-services-gcm:8.3.0' 
} 

build.gradle // для проекта

// Top-level build file where you can add configuration options common to all sub-projects/modules. 



buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.0.0-alpha1' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
     // classpath 'com.android.tools.build:gradle:1.3.0' 
     classpath 'com.android.databinding:dataBinder:1.0-rc2' 
     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

Спасибо за ваше драгоценное время)

+1

почему вы оба? 'classpath 'com.android.tools.build: gradle: 2.0.0-alpha1'' и' classpath' com.android.tools.build: gradle: 1.3.0'' также где вы включаете привязку данных в графе App? ... Вы прочитали «Руководство по привязке данных»? – Selvin

+0

, который прокомментировал код (gradle: 1.3.0) .. раньше у меня было это, тогда я изменил его на 2.0 –

+0

Я редактирую его здесь тоже ... что-нибудь еще ?? –

ответ

2

У вас есть старая настройка плагина с новой версией градиента. Удалите подключаемый модуль привязки данных & к его зависимости от пути к классам. Теперь она интегрирована и все, что вам нужно, это

android { 
    dataBinding { enabled = true } 
} 

http://developer.android.com/tools/data-binding/guide.html

Смежные вопросы