Android Studio Preview Not Showing RecyclerView and Toolbar Correctly - java

Please find the screenshots
I searched lot for this. My android studio is updated with 3.0.1.
Here are the dependencies in my project. Is the issue with studio 3.0.1?
compile 'com.android.support:appcompat-v7:23.4.+'
compile 'com.android.support:design:23.3.0'`
Here is the xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>

If resolution Strategy is present in your build.gradle file then please add updated dependency as below
configurations.all {
resolutionStrategy {
force 'com.android.support:design:27.0.1'
force 'com.android.support:support-v4:27.0.1'
force 'com.android.support:appcompat-v7:27.0.1'
}
}

In android Studio ,Go to File->Project Structure->Dependencies
Then click on green + sign and choose library dependencies.
There you can search recyclerview and include that dependency,
Build your project again
Hope this Helps

Add these dependencies in your build.gradle file (Not in project level gradle).
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'

you need to update libraries to last(nearly last) versions:
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:design:27.0.2'
and change your compileSdkVersion to 27(nearly last version)

Related

NestedScrollView breaks suggestions in Android Studio

Here is the strange behavior. I have this layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="#style/AppTheme.FragmentBackground.XXXX.Parent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="#+id/appbar"
layout="#layout/layout_appbar" />
<LinearLayout
android:layout_width="match_parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_height="wrap_content">
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
So far, everything seems perfect. Although, if I replace the LinearLayout with a NestedScrollView, all of a sudden, the suggestions just do not work! If I remove the nested scrollview, everything seems to work again. Here are my gradle dependencies:
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'androidx.appcompat:appcompat-resources:1.6.0'
implementation 'androidx.core:core:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.5'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.preference:preference:1.2.0'
implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'androidx.fragment:fragment:1.5.5' // Forecast Charts
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' // maps v2
implementation 'androidx.asynclayoutinflater:asynclayoutinflater:1.0.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.maps.android:android-maps-utils:2.4.0'
// needed for timestamps manip
implementation 'net.danlew:android.joda:2.11.2'
implementation "androidx.camera:camera-camera2:1.2.1"
implementation "androidx.camera:camera-lifecycle:1.2.1"
implementation "androidx.camera:camera-view:1.2.1"
implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:18.1.0'
//implementation 'com.google.mlkit:barcode-scanning:17.0.2'
implementation 'androidx.window:window:1.0.0'
while my gradle is gradle-7.5-bin.zip and my plugins are
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
version '2.0.1' apply false }
Also a popup of broken IDE is appeared and here is the log:
java.lang.NullPointerException
at org.jetbrains.android.dom.AttributeProcessingUtil.registerAttributesForClassAndSuperclasses(AttributeProcessingUtil.java:315)
at org.jetbrains.android.dom.AttributeProcessingUtil.processLayoutAttributes(AttributeProcessingUtil.java:604)
at org.jetbrains.android.dom.AttributeProcessingUtil.processAttributes(AttributeProcessingUtil.java:681)
at org.jetbrains.android.dom.AndroidDomExtender.registerExtensions(AndroidDomExtender.java:56)
at org.jetbrains.android.dom.AndroidDomExtender.registerExtensions(AndroidDomExtender.java:28)
at com.intellij.util.xml.reflect.DomExtenderEP.extend(DomExtenderEP.java:91)
at com.intellij.util.xml.impl.DynamicGenericInfo.runDomExtenders(DynamicGenericInfo.java:124)
at com.intellij.util.xml.impl.DynamicGenericInfo.lambda$checkInitialized$0(DynamicGenericInfo.java:55)
at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:114)
at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:44)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
at com.intellij.util.xml.impl.DynamicGenericInfo.checkInitialized(DynamicGenericInfo.java:54)
at com.intellij.util.xml.impl.DynamicGenericInfo.getAttributeChildrenDescriptions(DynamicGenericInfo.java:231)
at com.intellij.xml.impl.dom.AbstractDomChildrenDescriptor.getAttributeDescriptor(AbstractDomChildrenDescriptor.java:184)
at com.intellij.xml.impl.dom.AbstractDomChildrenDescriptor.getAttributeDescriptor(AbstractDomChildrenDescriptor.java:195)
at org.jetbrains.android.dom.layout.LayoutElementDescriptor.getAttributeDescriptor(LayoutElementDescriptors.kt:124)
at com.intellij.psi.impl.source.xml.XmlAttributeDelegate.getDescriptionImpl(XmlAttributeDelegate.java:68)
at com.intellij.psi.impl.source.xml.XmlAttributeDelegate.lambda$getDescriptor$0(XmlAttributeDelegate.java:55)
at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158)
at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:39)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:227)
at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:227)
at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:114)
at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:44)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228)
at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:28)
at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:72)
at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155)
at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:121)
at com.intellij.psi.impl.source.xml.XmlAttributeDelegate.getDescriptor(XmlAttributeDelegate.java:53)
at com.intellij.psi.impl.source.xml.XmlAttributeImpl.getDescriptor(XmlAttributeImpl.java:191)
at com.intellij.psi.impl.source.xml.XmlAttributeReference$1.compute(XmlAttributeReference.java:23)
at com.intellij.psi.impl.source.xml.XmlAttributeReference$1.compute(XmlAttributeReference.java:20)
at com.intellij.openapi.util.NullableLazyValue.getValue(NullableLazyValue.java:20)
at com.intellij.psi.impl.source.xml.XmlAttributeReference.getDescriptor(XmlAttributeReference.java:110)
at com.intellij.psi.impl.source.xml.XmlAttributeReference.resolve(XmlAttributeReference.java:50)
at com.intellij.codeInsight.TargetElementUtilBase.getReferencedElement(TargetElementUtilBase.java:177)
at com.intellij.codeInsight.TargetElementUtilBase.doGetReferenceOrReferencedElement(TargetElementUtilBase.java:165)
at com.intellij.codeInsight.TargetElementUtilBase.getReferenceOrReferencedElement(TargetElementUtilBase.java:210)
at com.intellij.codeInsight.TargetElementUtilBase.getReferencedElement(TargetElementUtilBase.java:254)
at com.intellij.codeInsight.TargetElementUtilBase.doFindTargetElement(TargetElementUtilBase.java:233)
at com.intellij.codeInsight.TargetElementUtilBase.findTargetElement(TargetElementUtilBase.java:298)
at com.intellij.codeInsight.TargetElementUtil.findTargetElement(TargetElementUtil.java:147)
at com.jetbrains.cidr.lang.psi.impl.OCTargetElementUtil.findTargetElement(OCTargetElementUtil.java:47)
at com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider.getPsiElementIn(TextEditorPsiDataProvider.java:226)
at com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider.getSlowData(TextEditorPsiDataProvider.java:139)
at com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider.lambda$getData$0(TextEditorPsiDataProvider.java:93)
at com.intellij.ide.impl.DataManagerImpl.getSlowData(DataManagerImpl.java:153)
at com.intellij.ide.impl.DataManagerImpl.lambda$getDataRule$2(DataManagerImpl.java:121)
at com.intellij.ide.impl.DataManagerImpl.lambda$getDataRule$4(DataManagerImpl.java:126)
at com.intellij.ide.impl.DataManagerImpl.getDataFromProvider(DataManagerImpl.java:77)
at com.intellij.openapi.actionSystem.impl.PreCachedDataContext.getData(PreCachedDataContext.java:182)
at com.intellij.openapi.actionSystem.impl.PreCachedDataContext$InjectedDataContext.getData(PreCachedDataContext.java:327)
at com.intellij.openapi.actionSystem.DataKey.getData(DataKey.java:63)
at org.jetbrains.android.quickDefinitions.AndroidImplementationViewSessionFactory.createSession(AndroidImplementationViewSession.kt:55)
at com.intellij.codeInsight.hint.actions.ShowRelatedElementsActionBase.performForContext(ShowRelatedElementsActionBase.java:86)
at com.intellij.codeInsight.hint.actions.ShowRelatedElementsActionBase.actionPerformed(ShowRelatedElementsActionBase.java:63)
at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:65)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:579)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$10(IdeKeyEventDispatcher.java:704)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$11(IdeKeyEventDispatcher.java:704)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:256)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.doPerformActionInner(IdeKeyEventDispatcher.java:701)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:645)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:590)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:473)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:462)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:227)
at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:804)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:740)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:439)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:803)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:438)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:119)
at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:604)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:436)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:873)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:484)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="#style/AppTheme.FragmentBackground.XXXX.Parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/appbar"
layout="#layout/layout_appbar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
</LinearLayout>
Use Clean Project and Rebuild Project. And Sync Project with Gradle files and download the latest version of Android Studio and then it will suggest.
Sometimes, by default, Android Studio does not show the suggestion.

Bottom Navigation Bar in Android Studio not Working?

bottomNavigationView.setOnNavigationItemSelectedListener{
when (it.itemId){
R.id.local1 -> make_Fragment(fragment1)
R.id.local2-> make_Fragment(fragment2)
R.id.local3 -> make_Fragment(fragment3)
}
true
}
Here bottomNavigationView is throwing error : Unresolved reference: bottomNavigationView and also i defined the id on mainactivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".main.MainActivity">
<FrameLayout
android:id="#+id/fl_wapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/bottomNavigationView"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="#menu/bottom_nav"
/>
</RelativeLayout>
Here bottomNavigationView shows error and also when(it.itemId){
the bottomNavigationView is the id of the bottom bar.i also tried clean project and rebuild project.
tell me a solution to resolve this problem?
add these in build.gradle(:app)
id 'kotlin-android'
id 'kotlin-android-extensions'
this in dependencies
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"
like this
dependencies {
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10" }
add this import statement in MainActivity.kt
import kotlinx.android.synthetic.main.mainactivity.*
it will work just fine :)...
Add this dependencies in build.gradle
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
Add kotlin code implementation
Please refer this my github repository for better understanding.
https://github.com/meshramaravind/BottomNavigtaionApp

BottomAppBar backgrounTint is not correctly match to parent and showing in half of screen

i try my layout code and the BottomAppBar is not showing perfectly i search everywhere but found no question about it.
i tried this on Android Studio 3.4 my gradle dependencies are
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0-beta01'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
}
Code i use in home_bottomappbar.xml
<androidx.coordinatorlayout.widget.CoordinatorLayout
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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottom_app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:backgroundTint="#color/colorPrimaryDark"
app:fabAlignmentMode="center"
app:fabAttached="true"
app:fabCradleDiameter="0dp"
app:fabCradleVerticalOffset="10dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bottom_app_bar"
app:backgroundTint="#color/colorPrimary"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Replace the Coordinator layout with Relative or Liner Layout. It will work fine.
I was having the same problem for a while too
The solution is to change the width of the BottomAppBar to fill_parent, it should work fine now :)

CardView class "could not be found" despite implementing it in the gradle file

For some reason, my CardView cannot find the class. I'm using it as the root layout and I have implemented it in the gradle file. I tried all the tips on SO but nothing works:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/item_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:orientation="horizontal"
card_view:cardCornerRadius="4dp">
<TextView
android:id="#+id/username_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/username_display" />
<TextView
android:id="#+id/password_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/password_display" />
</android.support.v7.widget.CardView>
This is the complete Gradle file:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ozbek.cryptpass"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'com.android.support:design:28.0.1'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha04'
implementation 'com.android.support:cardview-v7:28.0.0'
testImplementation 'junit:junit:4.13-beta-2'
androidTestImplementation 'androidx.test:runner:1.2.0-alpha04'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha4'
}
And this is the error I'm getting:
The following classes could not be found:
- android.support.v7.widget.CardView (Fix Build Path, Edit XML, Create Class)
your cardView doesn't show because there is nothing to show since you are setting its height="wrap_content" and the only children is empty , try to set your cardView height to 60dp to see if it will show something
android:layout_height="60dp"
edit
as i can notice in your edit you are using androidx so you should use this :
implementation 'androidx.cardview:cardview:1.1.0'
and in your xml file :
androidx.cardview.widget.CardView
if you want to use the old classes : add android:enableJetifier=true to your gradle.properties and use the appcompat dependencies instead.

Trouble importing android.support.v7.widget.CardView into Eclipse

I use Eclipse and I'm trying to create an application using the new support-library-v7:21.+ from Lollipop.
Created my new project
imported in eclipse the support-library-v7
changed in project-properties of support library the line: target=android-21 with 21 target
changed the target of my application in 21
imported the library in my project
clean all
After all i still got the invalid R declaration. I restarted Eclipse and then, after re-importing the library, seem went! I created a Tolbar and a NavigationDrawer as well without problem - it works.
Now, i would like to put a CardView in my ListView items:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
>
<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/codename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/versione"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/timestamp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.v7.widget.CardView>
</LinearLayout>
well, first error: No resource identifier found for attribute 'cardCornerRadius'.
I tried to delete the attribute, restart the application but I get a the following crash:
java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_width attribute.
I don't understand what the problem is.
Adding the library
Gradle
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'
Eclipse
Using android.support.v7.widget.CardView in my project (Eclipse)
Proper LinearLayout
As the error said, a LinearLayout needs a layout_width and a layout_heighth. Always.
I have outlined the steps that worked for me as an answer to this question. It should work.
I had the same issue.
Tried adding Eclipse->properies->Android->Libraries->Add = CardView is not there.
Tried Eclipse->properies->JavaBuildPath->Libraries->Add Jars->(select from CardView->libs) did not work.
what worked:
cardview->project.properites, add android.library=true if missing.
We need to do both the things add android.support.v7.widget.CardView as a library project and also add + check it's jar file in java build path
Go to File -> Import -> Existing Android code into workspace --> Browse (Go to sdk/extras/android/support/v7/cardview) --> Click ok --> Click Finish
Right click on cardview project --> Properties --> Android(Left Pane) --> Enable isLibrary (tick the checkbox) --> Apply --> ok
Right click on your project --> Properties --> Android(Left pane) --> Add (under library) --> cardview --> apply --> ok
right click on your project again --> build path --> configure build path -->under libraries-->add jar-->expand cardview-->expand libs-->select android.support.v7.widget.CardView.jar
under order and export-->check android.support.v7.widget.CardView.jar-->click
Hope it will work fine.
It is obvious that you didn't import the CardView support project as your main project's library. To import CardView library, you need to do this:
1, first, import CardView support library into you Eclipse. The process should be like this:
File-->Import-->Android-->Existing Android Code into Eclipse-->Browse-->.../sdk/extras/android/support/v7/cardview-->OK-->Finish. Then you will see project of android-support-v7-cardview in your Eclipse in which all resource and jar is.
2, add android-support-v7-cardview into your main project as a library. Just like this: right-click your project-->Properties-->Android-->Add, and select android-support-v7-cardview into your project.
And then, rebuild your project. Errors about CardView in your project will be finished.
Inside your build.gradle file (inside dependencies section) add the last versions for support library and cardView support library:
dependencies {
...
...
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.0.1'
}

Categories