java.lang.NullPointerException when dataBinding enabled = true - android

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".

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.

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

Related

Android Studio Rendering: "high_quality" in attribute "breakStrategy" is not a valid integer

Rendering Problems
"high_quality" in attribute "breakStrategy" is not a valid integer
([N] similar errors not shown)
Tip: Try to refresh the layout.
([N] is a variable number.)
This message was produced after I restarted Android Studio, for all activities and any other design-able files (such xml/pref_XXX.xml files)!
I searched all project files (Ctrl+Shift+F) for "high_quality" and "breakStrategy" but found nothing!
The interesting note is no problem in designing! Just show this message.
Also, I tried Clean Project, Rebuild Project, Synchronize (Ctrl+Alt+Y), Synchronize app, pressing the refresh hyperlink inside the mentioned message, restarting Android Studio again, ... But no avail!
I have updated the android sdk build-tools, platfom-tools, API 25 and works.

IndexNotReadyException - Android Studio

While changing the values of a widget in properties tab, AndroidStudio keeps on throwing IndexNotReadyException. But after few minutes while retrying, the error is not occurring.
Here is the error log:
com.intellij.openapi.project.IndexNotReadyException: Please change caller according to com.intellij.openapi.project.IndexNotReadyException documentation
at com.intellij.util.indexing.FileBasedIndexImpl.handleDumbMode(FileBasedIndexImpl.java:856)
at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:805)
at com.intellij.util.indexing.FileBasedIndexImpl.processExceptions(FileBasedIndexImpl.java:930)
at com.intellij.util.indexing.FileBasedIndexImpl.collectFileIdsContainingAllKeys(FileBasedIndexImpl.java:1190)
at com.intellij.util.indexing.FileBasedIndexImpl.processFilesContainingAllKeys(FileBasedIndexImpl.java:1018)
at com.intellij.psi.impl.search.PsiSearchHelperImpl$26.compute(PsiSearchHelperImpl.java:1096)
at com.intellij.psi.impl.search.PsiSearchHelperImpl$26.compute(PsiSearchHelperImpl.java:1093)
I've updated the AndroidStudio, to latest one. But still the error occurs. Any fix or work around?
Happens because of the background indexing processes.
When the IDE is indexing, if we try to change the values in properties tab, then IndexNotReadyException is thrown.
Wait till indexing is complete.
Hope Google fixes this in AndroidStudio's next release!
File-> Invalidate Cache and Restart
This will stop the old indexing process and start a new one.
After that wait for indexing, and let that project build.
I faced the same problem and found solution according to this, I have changed the API level 22 to 21, problem solved.
API Level for XML layout was set **Automatically Pick Best ** which was API 22
And I change this API 22 to API 21:
and the exception removed.
Hope this help. Thanks
If you have tried opening the project built in esclipse from default Open Project option from Android Studio, try Importing the project and open it.
when that happend, run gradle method,
then incremental builds are rebuild and indexing is restarted:
task _deleteIncrementals << {
def dirName = new File("${rootDir}/$project.name/build/intermediates/builds/debug/")
dirName.deleteDir()
}

Issue with projectfolder called (AndroidProjects)?

I have a wired issue. If i set up a folder called AndroidProjects and put my project in there... Android-Studio fails with gradle.
one error is:
IllegalStateException:
PsiFile not parsed for file D:/AndroidProjects/MyApplication/settings.gradle.
Wait until onPsiFileAvailable() is called.
sometimes it says that gradle has a fatal error....
if i set up my projectlocation to e.g. andropro everyting is working fine.
My thoughts:
may problems with 2 big letters in projectfoldername
may foldername is to long
may android or project are registered words in android-studio
Is there a knowen issue using foldernames like i did above?
couldn't find anything on the net.

Android Studio Mac new project errors after freshly created project

When I create a new project on android studio, I get the error. "URI is not registered" on my xmlns:android="http://schemas.android.com/apk/res/android" . I go to my event log, click configure, and the error goes away, yet I get errors in the "android:icon, label and theme" values under application along with the "android:name and label" attributes under activity in the AndroidManifest.xml.
Also, when trying to open my activity_main.xml layout files, I get the error
10:23:12 AM IllegalStateException: #NotNull method com/android/tools/idea/rendering/ManifestInfo.getActivityThemes must not return null
It works on the PC, but I am definitely missing something on the Mac. Thanks for all of the help!
Update to version 3.0 Canary build on Mac. Fixes all problems.

Android: Gradle Error in Android Studio

I recently added some .gifs to my /drawable so that I can use them with buttons. This worked fine (no errors). Now, when I go to rebuild/run my application, I get the following error:
Error: Gradle: Execution failed for task ':MyProject:mergeDebugResources'. > Index: 0
I'm not sure how to fix this (and there appears to be no other similar issues that I could find online.
Edit: Now it's the same error, but it also says (at the end of the first error)
Running /Applications/Android Studio.app/sdk/build-tools/android-4.2.2/aapt failed. See output
Okay, I fixed the issue. It was quite weird.
A) I had some capital letters in my res/drawables folder. Not too weird -- I can see how that would remove the first error.
B) Then, however, a lot of values in my main activity file became undefined. I had to manually import 'com.myapp.R'. Now that was weird.
Fortunately, everything is now working.
I hope that if anyone gets the same errors as me, that this response can help them.

Categories

Resources