DataBinding causing a Kotlin compiler error










1















I have following branch in Bitbucket : https://bitbucket.org/ali-rezaei/tmdb/src/dataBinding/



I get following Kotlin compiler error when I build the project :



e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.


Error is related to :



app:visibleGone="@isLoaded"


in the following layout :



<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>
<variable
name="isLoaded"
type="boolean" />
</data>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.MainActivity">

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@isLoaded" />

</android.support.v4.widget.SwipeRefreshLayout>

<include
layout="@layout/network_state_item"
app:visibleGone="@!isLoaded" />

</FrameLayout>

</layout>


I appreciate if you can help me out.










share|improve this question
























  • app:visibleGone . Post the @BindingAdapter annotated method

    – Blackbelt
    Nov 13 '18 at 9:56











  • I'm curious if it's because of your variable type, what'd happen if you change boolean to Boolean? Or even java.lang.Boolean?

    – Aaron
    Nov 13 '18 at 9:58












  • @Blackbelt bitbucket.org/ali-rezaei/tmdb/src/dataBinding/app/src/main/java/…, thanks

    – Ali
    Nov 13 '18 at 9:59











  • @Aaron, I got the same error message.

    – Ali
    Nov 13 '18 at 10:02















1















I have following branch in Bitbucket : https://bitbucket.org/ali-rezaei/tmdb/src/dataBinding/



I get following Kotlin compiler error when I build the project :



e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.


Error is related to :



app:visibleGone="@isLoaded"


in the following layout :



<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>
<variable
name="isLoaded"
type="boolean" />
</data>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.MainActivity">

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@isLoaded" />

</android.support.v4.widget.SwipeRefreshLayout>

<include
layout="@layout/network_state_item"
app:visibleGone="@!isLoaded" />

</FrameLayout>

</layout>


I appreciate if you can help me out.










share|improve this question
























  • app:visibleGone . Post the @BindingAdapter annotated method

    – Blackbelt
    Nov 13 '18 at 9:56











  • I'm curious if it's because of your variable type, what'd happen if you change boolean to Boolean? Or even java.lang.Boolean?

    – Aaron
    Nov 13 '18 at 9:58












  • @Blackbelt bitbucket.org/ali-rezaei/tmdb/src/dataBinding/app/src/main/java/…, thanks

    – Ali
    Nov 13 '18 at 9:59











  • @Aaron, I got the same error message.

    – Ali
    Nov 13 '18 at 10:02













1












1








1








I have following branch in Bitbucket : https://bitbucket.org/ali-rezaei/tmdb/src/dataBinding/



I get following Kotlin compiler error when I build the project :



e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.


Error is related to :



app:visibleGone="@isLoaded"


in the following layout :



<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>
<variable
name="isLoaded"
type="boolean" />
</data>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.MainActivity">

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@isLoaded" />

</android.support.v4.widget.SwipeRefreshLayout>

<include
layout="@layout/network_state_item"
app:visibleGone="@!isLoaded" />

</FrameLayout>

</layout>


I appreciate if you can help me out.










share|improve this question
















I have following branch in Bitbucket : https://bitbucket.org/ali-rezaei/tmdb/src/dataBinding/



I get following Kotlin compiler error when I build the project :



e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.


Error is related to :



app:visibleGone="@isLoaded"


in the following layout :



<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>
<variable
name="isLoaded"
type="boolean" />
</data>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.MainActivity">

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@isLoaded" />

</android.support.v4.widget.SwipeRefreshLayout>

<include
layout="@layout/network_state_item"
app:visibleGone="@!isLoaded" />

</FrameLayout>

</layout>


I appreciate if you can help me out.







android kotlin android-databinding






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 15:37







Ali

















asked Nov 13 '18 at 9:55









AliAli

4,6211650114




4,6211650114












  • app:visibleGone . Post the @BindingAdapter annotated method

    – Blackbelt
    Nov 13 '18 at 9:56











  • I'm curious if it's because of your variable type, what'd happen if you change boolean to Boolean? Or even java.lang.Boolean?

    – Aaron
    Nov 13 '18 at 9:58












  • @Blackbelt bitbucket.org/ali-rezaei/tmdb/src/dataBinding/app/src/main/java/…, thanks

    – Ali
    Nov 13 '18 at 9:59











  • @Aaron, I got the same error message.

    – Ali
    Nov 13 '18 at 10:02

















  • app:visibleGone . Post the @BindingAdapter annotated method

    – Blackbelt
    Nov 13 '18 at 9:56











  • I'm curious if it's because of your variable type, what'd happen if you change boolean to Boolean? Or even java.lang.Boolean?

    – Aaron
    Nov 13 '18 at 9:58












  • @Blackbelt bitbucket.org/ali-rezaei/tmdb/src/dataBinding/app/src/main/java/…, thanks

    – Ali
    Nov 13 '18 at 9:59











  • @Aaron, I got the same error message.

    – Ali
    Nov 13 '18 at 10:02
















app:visibleGone . Post the @BindingAdapter annotated method

– Blackbelt
Nov 13 '18 at 9:56





app:visibleGone . Post the @BindingAdapter annotated method

– Blackbelt
Nov 13 '18 at 9:56













I'm curious if it's because of your variable type, what'd happen if you change boolean to Boolean? Or even java.lang.Boolean?

– Aaron
Nov 13 '18 at 9:58






I'm curious if it's because of your variable type, what'd happen if you change boolean to Boolean? Or even java.lang.Boolean?

– Aaron
Nov 13 '18 at 9:58














@Blackbelt bitbucket.org/ali-rezaei/tmdb/src/dataBinding/app/src/main/java/…, thanks

– Ali
Nov 13 '18 at 9:59





@Blackbelt bitbucket.org/ali-rezaei/tmdb/src/dataBinding/app/src/main/java/…, thanks

– Ali
Nov 13 '18 at 9:59













@Aaron, I got the same error message.

– Ali
Nov 13 '18 at 10:02





@Aaron, I got the same error message.

– Ali
Nov 13 '18 at 10:02












1 Answer
1






active

oldest

votes


















3














The changes I would do are: Here



<variable
name="isLoaded"
type="boolean" />


Instead of passing boolean I would pass an instance of your VM



 <variable
name="vm"
type="com.sample.android.tmdb.ui.MovieViewModel" />


in your fragment, you do



 mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false)
mBinding?.setVariable(BR.vm, mViewModel)
mBinding?.setLifecycleOwner(this)


this way, your VM is connected to the lifecycle of your fragment.



Declare a method



 @BindingAdapter("visibleGone")
fun View.visibleGone(visible: Boolean)
setVisibility(if (visible) View.VISIBLE else View.GONE)



declare a LiveData<Boolean> variable in you MovieViewModel and connect it in your layout. Eg.



 val loading: LiveData<Boolean>


then in your layout you could have



 <android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@!safeUnbox(vm.loading)" />





share|improve this answer























  • Thanks, BR.vm is not recognized. I tried both import com.android.databinding.library.baseAdapters.BR and import com.sample.android.tmdb.BR

    – Ali
    Nov 13 '18 at 10:22











  • did you build ? Push on a different branch and past here the link

    – Blackbelt
    Nov 13 '18 at 10:23












  • bitbucket.org/ali-rezaei/tmdb/src/new-dataBinding

    – Ali
    Nov 13 '18 at 10:42











  • Yes, it was related to build. Now I just get network_state_item layout and not RecyclerView

    – Ali
    Nov 13 '18 at 10:43











  • network_state_item.xml post it

    – Blackbelt
    Nov 13 '18 at 10:46










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278290%2fdatabinding-causing-a-kotlin-compiler-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














The changes I would do are: Here



<variable
name="isLoaded"
type="boolean" />


Instead of passing boolean I would pass an instance of your VM



 <variable
name="vm"
type="com.sample.android.tmdb.ui.MovieViewModel" />


in your fragment, you do



 mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false)
mBinding?.setVariable(BR.vm, mViewModel)
mBinding?.setLifecycleOwner(this)


this way, your VM is connected to the lifecycle of your fragment.



Declare a method



 @BindingAdapter("visibleGone")
fun View.visibleGone(visible: Boolean)
setVisibility(if (visible) View.VISIBLE else View.GONE)



declare a LiveData<Boolean> variable in you MovieViewModel and connect it in your layout. Eg.



 val loading: LiveData<Boolean>


then in your layout you could have



 <android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@!safeUnbox(vm.loading)" />





share|improve this answer























  • Thanks, BR.vm is not recognized. I tried both import com.android.databinding.library.baseAdapters.BR and import com.sample.android.tmdb.BR

    – Ali
    Nov 13 '18 at 10:22











  • did you build ? Push on a different branch and past here the link

    – Blackbelt
    Nov 13 '18 at 10:23












  • bitbucket.org/ali-rezaei/tmdb/src/new-dataBinding

    – Ali
    Nov 13 '18 at 10:42











  • Yes, it was related to build. Now I just get network_state_item layout and not RecyclerView

    – Ali
    Nov 13 '18 at 10:43











  • network_state_item.xml post it

    – Blackbelt
    Nov 13 '18 at 10:46















3














The changes I would do are: Here



<variable
name="isLoaded"
type="boolean" />


Instead of passing boolean I would pass an instance of your VM



 <variable
name="vm"
type="com.sample.android.tmdb.ui.MovieViewModel" />


in your fragment, you do



 mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false)
mBinding?.setVariable(BR.vm, mViewModel)
mBinding?.setLifecycleOwner(this)


this way, your VM is connected to the lifecycle of your fragment.



Declare a method



 @BindingAdapter("visibleGone")
fun View.visibleGone(visible: Boolean)
setVisibility(if (visible) View.VISIBLE else View.GONE)



declare a LiveData<Boolean> variable in you MovieViewModel and connect it in your layout. Eg.



 val loading: LiveData<Boolean>


then in your layout you could have



 <android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@!safeUnbox(vm.loading)" />





share|improve this answer























  • Thanks, BR.vm is not recognized. I tried both import com.android.databinding.library.baseAdapters.BR and import com.sample.android.tmdb.BR

    – Ali
    Nov 13 '18 at 10:22











  • did you build ? Push on a different branch and past here the link

    – Blackbelt
    Nov 13 '18 at 10:23












  • bitbucket.org/ali-rezaei/tmdb/src/new-dataBinding

    – Ali
    Nov 13 '18 at 10:42











  • Yes, it was related to build. Now I just get network_state_item layout and not RecyclerView

    – Ali
    Nov 13 '18 at 10:43











  • network_state_item.xml post it

    – Blackbelt
    Nov 13 '18 at 10:46













3












3








3







The changes I would do are: Here



<variable
name="isLoaded"
type="boolean" />


Instead of passing boolean I would pass an instance of your VM



 <variable
name="vm"
type="com.sample.android.tmdb.ui.MovieViewModel" />


in your fragment, you do



 mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false)
mBinding?.setVariable(BR.vm, mViewModel)
mBinding?.setLifecycleOwner(this)


this way, your VM is connected to the lifecycle of your fragment.



Declare a method



 @BindingAdapter("visibleGone")
fun View.visibleGone(visible: Boolean)
setVisibility(if (visible) View.VISIBLE else View.GONE)



declare a LiveData<Boolean> variable in you MovieViewModel and connect it in your layout. Eg.



 val loading: LiveData<Boolean>


then in your layout you could have



 <android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@!safeUnbox(vm.loading)" />





share|improve this answer













The changes I would do are: Here



<variable
name="isLoaded"
type="boolean" />


Instead of passing boolean I would pass an instance of your VM



 <variable
name="vm"
type="com.sample.android.tmdb.ui.MovieViewModel" />


in your fragment, you do



 mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false)
mBinding?.setVariable(BR.vm, mViewModel)
mBinding?.setLifecycleOwner(this)


this way, your VM is connected to the lifecycle of your fragment.



Declare a method



 @BindingAdapter("visibleGone")
fun View.visibleGone(visible: Boolean)
setVisibility(if (visible) View.VISIBLE else View.GONE)



declare a LiveData<Boolean> variable in you MovieViewModel and connect it in your layout. Eg.



 val loading: LiveData<Boolean>


then in your layout you could have



 <android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:visibleGone="@!safeUnbox(vm.loading)" />






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 10:09









BlackbeltBlackbelt

128k22216242




128k22216242












  • Thanks, BR.vm is not recognized. I tried both import com.android.databinding.library.baseAdapters.BR and import com.sample.android.tmdb.BR

    – Ali
    Nov 13 '18 at 10:22











  • did you build ? Push on a different branch and past here the link

    – Blackbelt
    Nov 13 '18 at 10:23












  • bitbucket.org/ali-rezaei/tmdb/src/new-dataBinding

    – Ali
    Nov 13 '18 at 10:42











  • Yes, it was related to build. Now I just get network_state_item layout and not RecyclerView

    – Ali
    Nov 13 '18 at 10:43











  • network_state_item.xml post it

    – Blackbelt
    Nov 13 '18 at 10:46

















  • Thanks, BR.vm is not recognized. I tried both import com.android.databinding.library.baseAdapters.BR and import com.sample.android.tmdb.BR

    – Ali
    Nov 13 '18 at 10:22











  • did you build ? Push on a different branch and past here the link

    – Blackbelt
    Nov 13 '18 at 10:23












  • bitbucket.org/ali-rezaei/tmdb/src/new-dataBinding

    – Ali
    Nov 13 '18 at 10:42











  • Yes, it was related to build. Now I just get network_state_item layout and not RecyclerView

    – Ali
    Nov 13 '18 at 10:43











  • network_state_item.xml post it

    – Blackbelt
    Nov 13 '18 at 10:46
















Thanks, BR.vm is not recognized. I tried both import com.android.databinding.library.baseAdapters.BR and import com.sample.android.tmdb.BR

– Ali
Nov 13 '18 at 10:22





Thanks, BR.vm is not recognized. I tried both import com.android.databinding.library.baseAdapters.BR and import com.sample.android.tmdb.BR

– Ali
Nov 13 '18 at 10:22













did you build ? Push on a different branch and past here the link

– Blackbelt
Nov 13 '18 at 10:23






did you build ? Push on a different branch and past here the link

– Blackbelt
Nov 13 '18 at 10:23














bitbucket.org/ali-rezaei/tmdb/src/new-dataBinding

– Ali
Nov 13 '18 at 10:42





bitbucket.org/ali-rezaei/tmdb/src/new-dataBinding

– Ali
Nov 13 '18 at 10:42













Yes, it was related to build. Now I just get network_state_item layout and not RecyclerView

– Ali
Nov 13 '18 at 10:43





Yes, it was related to build. Now I just get network_state_item layout and not RecyclerView

– Ali
Nov 13 '18 at 10:43













network_state_item.xml post it

– Blackbelt
Nov 13 '18 at 10:46





network_state_item.xml post it

– Blackbelt
Nov 13 '18 at 10:46

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278290%2fdatabinding-causing-a-kotlin-compiler-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3