Android TabLayout CompatTextView can not be resolved - android

I was using TabLayout, but after copying it in my src, I am getting following errors:
(1) android.support.v7.internal.widget.CompatTextView can not be resolved
(2) styleable cannot be resolved or is not a field Though I checked other answers in stackoverflow, but failed to get proper solution. I already imported android.R
(3) I checked that in my android-support-v7-appcompat.jar the class CompatTextView is missing. How this can be possible.
(4) Will there be any legal issue if I copy the TabLayout class given by google for my app?
Please help.
Update:
I added import android.support.v7.appcompat.R; instead of android.R and getting following several error like Widget_Design_TabLayout cannot be resolved or is not a field TabLayout_tabIndicatorHeight cannot be resolved or is not a field TabLayout_tabIndicatorColor cannot be resolved or is not a field etc. Please suggest.

Converting comments into the answer as you have found them helpful and able to resolve your issue.
I don't know why are you importing/copying it manually in your project, because TabLayout is part of design support library, you just need to include its artifact ID in your build.gradle file to access its classes and resources!
compile 'com.android.support:design:+' //replace + with latest version

Related

error: package databinding does not exist and error: cannot find symbol BR

After working on many xml and activities, everything was just fine. Now this error comes. And the worst thing is i can not find issue.
error: package databinding does not exist
and this
error: cannot find symbol BR
Build stack trace only shows this.
Can some tell me what is way to find issue in project. Because gradle errors just showing databinding class build error.
As i searched lot. This answer recommends to run with debug. When i build with debug then there are over 100k lines. How can i find exact issue line no?
The issue was not directly link to Android Databinding. There were a
bug in the project (some variables not correctly setted)
I would recommend to use gradle with "--debug and --stacktrace"
for more informations, it's helping a lot.
And this answer says to add some dependency. When i add this dependency
It is a problem caused by android-apt plugin. It ignores the provided
dependency that data binding plugin adds.
https://bitbucket.org/hvisser/android-apt/issue/38/android-apt-breaks-brand-new-data-binding#comment-18504545
You can work around it by adding: apt
'com.android.databinding:compiler:1.0-rc0 to your gradle file.
I tried this but below error comes
Could not find method apt() for arguments [com.android.databinding:compiler:1.0-rc0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
How to get rid of this issue. Can android tell exactly where is the problem?

No resource identifier found for attribute error when trying to compile xamarin android project

I'm using Xamarin to build an android application but I'm having this error every time I try to compile the application.
I've added my attrs.xml file to Resources/values, referenced my namespace like this:
xmlns:custom="http://schemas.android.com/apk/res/mynamespace" and added the property to the view.
What am I missing? I've seen several examples but all seem to be working ok.
The reference is all in lower letters to avoid errors. I've also tried removing the http://... part and changing the folder "res" for "lib". These changes make the app to compile but I'm unable then to get the value of the parameter.
Please, any help will be really appreciated.
Best regards.
I've found the answer to my problem. It seems that it's not necessary to keep the lower letters when referencing the package name so if your package name is "MyNamespace", instead of using:
xmlns:custom="http://schemas.android.com/apk/res/mynamespace
you have to use:
xmlns:custom="http://schemas.android.com/apk/res/MyNamespace
It works now!

Android Support Library v7 R.id. Error

I have added the support library v7 to my project and I think it worked because ActionBarActivity is recognized (import android.support.v7.app.ActionBarActivity works).
The problem is that for all my R.ids the R is underlined with the message R cannot be resolved to a variable.
What am I doing wrong?
The problem is probably with R, not anything to do with the support library. Sometimes cleaning the project solves the problem.
A Google search with that message ("R cannot be resolved to a variable") returns tons of answers, try those. Also Stackoverflow is full of these:
"R cannot be resolved to a variable"?
Eclipse error: R cannot be resolved to a variable
Eclipse giving error, missing R.java file after recent update
If it's got nothing to do with that, then maybe you've got an error in some XML file.

Android: R cannot be resolved after adding a new class

I get the following error in eclipse: r cannot be resolved. However that appeared just after I added my own library as a resource to my project. It seems that eclipse cannot resolve which R to use, the library one or the project one. Note also that the library is marked with the is library check box in the project set-up. Also whenever I remove my library from the reference list eclipse does not show any errors, but upon compiling logCat shows a Class Not Found exception. How do I fix this issue?
Thanks
R is an autogenerated class. If you clean the project, the error should dissapear.
R.java is not getting generated for your project which is done automatically, pls check whether something wrong with any XML file or check console if there is any problem in XML it will show you something related to XML or check something wrong with importing packages. If its not about any XML errors then check on importing that library project in your project. you may get some imports related to something like this: com.android.R then remove this if you see this and then manage imports again.

R.java file from Android library project not importing into application project

I followed the instructions here on how to create an Android library project, and use it in an Android application:
http://developer.android.com/guide/developing/eclipse-adt.html
but it is not working. I can see the library project is added to my application but I cannot reference anything in it because it won't build. The R.java file from the lib is NOT being added to my application project, so the lib project contains tons of errors, everywhere it tries to reference it's own R.java file.
I don't know if this has anything to do with it, but in the console there are messages stating that the there is "No resource identifier found for attribute 'X' in package 'Lib Package'. My library package has a a few styleable attributes defined for a custom view I made, all of which are being complained about in this console message. The library builds just fine, and I don't get those messages in the console until I hook the library to my application, so I don't know what's up with this.
I really would like to get this working. I've spent two entire days on it, to no avail. Please offer any ideas you might have to help!
The answer to my conundrum was that the library had an attrs.xml file that defined a few custom attributes for a custom view I created. I removed attrs.xml and hardcoded the values in the custom view code, rebuilt the library, and problem solved.
This isn't cool though, what this means is that custom views with custom attributes can't be used in libraries. I hope Google fixes this.
It's actually a matter of file duplicity. You can't build a project that contains more than one instance of the same file. Due to the nature of an android project XML files are usually the first the negate a successful build.

Categories

Resources