1

Whenever I enable this in my app gradle

dataBinding { 
    enabled = true
}

and then sync -> It completely succeed.

but when I "run" it, It builds fail and shows this error

java.lang.NullPointerException at android.databinding.tool.store.LayoutFileParser.parseOriginalXml(LayoutFileParser.java:135) at android.databinding.tool.store.LayoutFileParser.parseXml(LayoutFileParser.java:93) ...

my app has little amount of Kotlin code, and android version is 3.5, minSdkVersion 19, targetSdkVersion 28, and upgraded to androidX

How can I solve this? which part should I search for solve this problem???

except above code, every thing works perfect.


Edit And when I rolled back my code before upgrading to androidX and compiled it, it also shows "Null point exception" and at this time, there are no extra message without just "Null point exception".


8
  • hi @youngwoon the one reason i can suspect is it is because of androidx. since sometimes it is not able to process or convert the layout files properly. and at runtime it will crash as the class won't be found. also at compile time it can throw some errors. will you please check and post your most recent layout file for unconverted androidx packages. Commented Sep 25, 2019 at 9:11
  • @vikaskumar thank you for your comment!! I can you explain about "post your most recent layout file for unconverted androidx packages"? I can't understand what you want.. sorry for being unfamiliar in English.T_T Commented Sep 26, 2019 at 0:33
  • @youngwoon this question cannot be answered unless you provide all the information... alike the XML file which causes the stack-trace above. you've only shown us the result so far. Commented Sep 26, 2019 at 1:16
  • 1
    @youngwoon sadly the error message does not tell that. it might be, that not a single one of them has <layout> and <data> nodes added, or the layouts may still reference com.android.support libraries instead of androidx libraries (these are not automatically migrated). Commented Sep 26, 2019 at 1:42
  • 1
    okay do one thing just try searching by pressing command + shift + f and type android.support.constraint.ConstraintLayout and see if there are any packages which are still on old packages names even after converting them to androidx. and like so try for recyclerview and cardview and progressbar also with full package names and see them if they are containing androidx or not. i hope this may help, let me know after this. Commented Sep 26, 2019 at 6:16

2 Answers 2

8

Finally I got answer. (cc. android databinding error:Execution failed for task ':app:dataBindingProcessLayoutsDebug')

I guessed it was because of BOM. Someone said it will happen when the code is used in two different circumstances(Window and Mac).

So in 'res' folder, I clicked 'remove BOM' button in android studio and that action changed some xml files.

<?xml version="1.0" encoding="utf-8"?>

But it wasn't worked in Mac. This solution worked only in Window.

Sign up to request clarification or add additional context in comments.

2 Comments

this solution worked for me on my Mac. See my answer in the linked SO post above
I meant the answer by Yanwen in stackoverflow.com/questions/35097445/… worked for me ie removing the BOM on layout files fixed the problem.
0

I tried a little too much but I figured it out. I created the project on the Mac computer and it wasn't a problem when I switched to windows later. When I tried to create a new file, I got this error and just understood why. Every time I right-clicked on the file I just added, I saw an option called "remove BOM". Clicking this solved my problem. But I did not find the solution to the problem logically, I just found it random.

ex: https://prnt.sc/riw6ex

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.