DEV Community

Discussion on: Android Data Binding

Collapse
 
manishkherde profile image
manishkherde

Hi Subbu,
I'm working on AOSP internal apps and using AOSP Marshmallow version on Ubuntu 5.x. I wanted to use data binding in these apps. But here is the problem,
Whenever I build my app with databinding integration, throws a error for databinding objects and classes.

Can you help me out to understand how to build (make) databinding apps in AOSP. May be I need to specify some parameters in the make file, but I am not sure what exactly to write in make file.

Please :-)

Thanks in advance

Collapse
 
subbramanil profile image
Subbu Lakshmanan • Edited

Absolutely I love to help you in whatever way I can. Please post the error that you see when compiling the AOSP module, so that I can get a clear idea.

If you are using Marshmallow version of AOSP (I'm assuming the release version: 6.0.0_r1),

  1. Source of Data-binding library should present in here. It has a sample app that might give some idea.
  2. The prebuilt aar file in here.

Please verify if you have either one. In my opinion, using the pre-built aar file would be simple to start with.

Collapse
 
zhjian1987 profile image
zhjian1987

Hi,Subbu

As we know if compile app with android studio to support data-binding, we only need to add

dataBinding {
    enabled true
}

in build.gralde.

But how to enable android data-binding in Android.mk if we want to compile app with AOSP? Thanks.

Thread Thread
 
subbramanil profile image
Subbu Lakshmanan • Edited

Hi,

What's the Android version you are using?

I’m not sure how much I can help as I haven’t done it before.

I believe DataBinding should be enabled from 'build.gradle' file. In Android.mk file, you should declare the dependencies.

Check it out this link:

androidxref.com/6.0.1_r10/xref/fra...

From my observation of this app,

It uses,

In Project level gradle file,

classpath "com.android.databinding:dataBinder:${config.version}”

In App level gradle file,

apply plugin: ‘com.android.databinding'

By looking at the module definition of data-binding library,

androidxref.com/6.0.1_r10/xref/fra...

And something interesting I found from this SO question,

stackoverflow.com/questions/481139...

I would imagine, you might need to reference the libraries in your make file.

com.android.databinding:adapters
com.android.databinding:baseLibrary
com.android.databinding:library

This is what we did in one of our apps to have appcompat support.

LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat \
                                                               android-support-v4

LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
LOCAL_SRC_FILES := $(call all-java-files-under, app)
LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/app/src/main/res \
                                                   frameworks/support/v7/appcompat/res

LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.design \
--extra-packages android.support.v7.appcompat

Similar to this there should be a way to add the DataBinding libraries as well.

Sorry It took long to respond.

Thread Thread
 
sankes profile image
shankes

HI Subbu,could you give me a demo about how to support databinding in AOSP.
Thanks very much