I am using Android Studio for my Android projects. I faced an issue when builds crash with strange stacktrace, like this:
Error:Execution failed for task ':app:compileDevDebugJavaWithJavac'.
java.lang.RuntimeException: failure, see logs for details.
cannot generate view binders java.lang.NullPointerException
at android.databinding.tool.reflection.ModelMethod.isBoxingConversion(ModelMethod.java:155)
at android.databinding.tool.store.SetterStore.isBetterParameter(SetterStore.java:946)
at android.databinding.tool.store.SetterStore.getBestSetter(SetterStore.java:838)
and it was seemed that the databinding became broken as whole.
I made refactoring before and moved classes between packages.
In my case, I relied on Android Studio when renaming and moving classes between packages. But it didn't proceed correction for XMLs of layouts where were references on refactored classes in the type attribute of variable element in data.
So my previous type's value pointed to non existing files and build crashed.
It's simple mistake but it may take more time to find the source. Hope this would help someone.
For me, this started happening after updating Android Studio to version 3.5.2
To fix it, I downgraded Android Gradle Plugin
buildscript {
repositories {
//..........
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
//......
}
}
Make sure you import all classes you reference in xml bindings
I had code something like:
android:visible="#{obj instanceof A}"
I was getting that same error.
Turns out that class A was not imported on top. Adding <import type="com.company.A"> tag resolved the problem.
P.S. android:visible is a custom binding adapter I have.
If this question is still relevant. For me I figured that in my xml layout file I was including a class (not an instance of one) as a variable, i.e I had this code
<variable
name="Converters"
type="com.example.flexapp.utils.Converters" />
and it should have been
<import type="com.example.flexapp.utils.Converters"/>
since this was a class and not an object.
in my case my problem was in a LongClickListener that the method for this listener must have returned a boolean but my method returned void so when I added the correct return statement it worked just fine.
keep in mind if you use a data binding method you must return the correct value or else the error it throws is not helpful at all.
You may have stumbled upon this question after migrating to Android X. If that's the case, and you're positive your XML files are okay, but it's still not working, you should start looking at libraries that generate code.
Libraries that generate code cannot be easily converted by the Jettifyer. Some info here - https://blog.danlew.net/2018/11/14/the-reality-of-migrating-to-androidx/
In my case, I updated the obvious ones, but I still was missing something. So, what I did was go into my develop branch (that wasn't Android X), ran a build, and dug into the build folder to see all of the libraries that generated code. Once I did that, I was able to look at the suspects one by one until I found the dependency that was causing this issue. You could either update it, or, in my case, remove it, and this error was resolved. :)
The getter function for any instance that you refer from your xml file might not have been defined or the getter function might not have public access specifier.
Downgrading Android Gradle Plugin to 3.5.1 fixed the issue for me
I face this problem when I define variable like this (Android Studio don't warning anything)
<data>
<variable
name="onGlobalLayoutA"
type="ViewTreeObserver.OnGlobalLayoutListener"/>
<import type="android.view.ViewTreeObserver"/>
</data>
And I solve it by
<data>
<variable
name="onGlobalLayoutA"
type="android.view.ViewTreeObserver.OnGlobalLayoutListener"/>
</data>
Hope this would help someone.
In my case, the reason was that I used a type for a variable which is another module and that module is added as 'implementation ' in build script. Changing to 'api ' resolved the issue.
Clearly not the same issue as the one posted by atlascoder but I mention regardless, maybe someone gits this article with the same problem as I had.
As #hiddeneyes02 mentioned, this started happen when upgrading from Android Gradle Plugin from 3.5.1 to 3.5.2, this seems to be the bug:
https://issuetracker.google.com/issues/143778134
When I built the project with the command tool I got the same errors as in this post:
When building Android project with Android Gradle Plugin v. 3.5.2 my builds fail
In my case I wrote wrong the name of my view model variable inside the XML file. I had it named VProgressBar instead of vProgressBar:
android:visibility="#{fatherViewModel.vProgressBar}"
hi i am a beginner for android i was decompile an app and i det the code source but when i import it on eclipse its give me this error:
error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.
i try some tips that i found it in stack-overflow but not working
if you know the solution help me
This may caused you haven't installed API > 21 in your computer (http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html).
Open SDK Manager and install it.
And another important thing i want to talk about is why you use Eclipse instead of Android Studio? eclipse is now no longer supported by Google
This question already has answers here:
No resource found that matches the given name '#style/Theme.AppCompat.Light'
(4 answers)
Closed 6 years ago.
I want to compile and run the project (Signal-Android : Openwhisper) by using Eclipse. Is there anyway to do that? (the reason that I have to use Eclipse because of its add-on 'call graph viewer'. I want the call graph of the project. If anyone has other idea, you can post here also)
I have ADT installed already.
when I tried to run it. Lots of error appeared
No resource found that matches the given name 'Theme.AppCompat.NoActionBar'.
No resource found that matches the given name '#style/Theme.AppCompat.Light.DarkActionBar'.
No resource found that matches the given name '#style/Widget.AppCompat.ActionBar'.
... Actually it has more than 20 lines of error
Errors from Eclipse:
I found that most people using Android Studio but I cant find how to create call graph.
I tried to add Appcompat v7 as support Library but in Propertied > android > Library when I click add. It has nothing inside but I'm sure in sdk/extras/android/support/v7/appcompat/libs has v7 appcompat.jar
Check the android version you have downloaded and installed... and which version is set as target for your application...
I am a new in Android Development and I am having some issue about the R.java file. And I read some suggestions that in order to generate this file you shouldn't have any error on the XML file. In my case I fave an error in my styles.xml
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
And also this:
ActionBarActivity cannot be resolved to a type
And I read this solution that I need to reference the AppCompat but when I checked on my settings the AppCompat has an error.
I already updated my SDK tools with the latest one
And also can you help me how can I solve the problem in the R.java. What I know is it is auto generated but in my case it doesn't generate even I start a new project.
Can you help me with this? So that I can continue my study. Thanks.
I'm trying to bind a project with Xamarin Studio so I successfully removed the errors and it bind correctly !
BUT some class are not generated in C#. Why ?
I worked with the Metadata.xml to bind correctly the name of the package -> PICTURE
and it allowed me to use this JAR (osmbonuspack) in my project.
At compile, I have some warning message like : "class ... matched no nodes. (error code : BG8A04). -> PICTURE
I think it is because of this warning that I can't use these new class in my project ! -> [PICTURE in comment below]
And i know that these class exist (I used JD-Gui to see the class in the JAR) -> [PICTURE in comment below]
So, why Xamarin doesn't bind correctly some class ?
PS : Sorry, I can't post more than 2 links so I post in comment the next screenshot
Looks like I found the problem.
Sample project is here (sorry for the mess in folders structure). I had to add gson jar to solve problem with converting KmlDocument methods that use it. Xamarin is "terrific" as always. You may have noticed a huge number of warning during the binding generation. It appears that some of them are real "errors" and some of them tell you that Xamarin wasn't able to generate some classes (KmlDocument for example).
First and main problem is that you have three jars in one binding project. I don't know if that is an Android binding limitation or I don't know but I never managed to create binding project for more than one jar. So my suggestion is to create three separate binding projects. That should help.