Error: package android:support.v4.#### does not exist - android

I want to add fragments to my application and I installed the xamarin.android.support.v4 and other required but it gives an error
error: package android:support.v4.view or app or content etc. does not exist.
I have tried on a blank project with the same results.
I am using Android 7.0 and the latest support library.

For now,i want to also add RecyclerView and CardView
To use these two controls, you need to install the Xamarin.Android.Support.v7.RecyclerView package and Xamarin.Android.Support.v7.CardView in your project. When you install the Xamarin.Android.Support.v7.RecyclerView package using Nuget, the Xamarin.Android.Support.v4 package will automatically be installed.
And you can use RecyclerView like this:
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
And so is the CardView:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:scaleType="centerCrop" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#333333"
android:text="Caption"
android:id="#+id/textView"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="4dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
You can refer to the official document RecyclerView of Xamarin for using and customizing RecyclerView in Xamarin.Android applications.
If there is still problem, could you please provide a minimal reproducible demo, so can we continue to investigate this issue.

Related

Google pre-launch report - Multiple items have the same description

Google now provides a 'Pre-Launch Report' when a new Beta version of an app is uploaded to the Play Store. My last Pre-Launch reports contained a complete dialog full of 'Multiple items have the same description'. I have now found out what, in my case, caused the problem and my solution. A simplified layout for my dialog that still showed the problem is the following:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/displayHeightLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/displayHeightLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="#string/displayInfoEms"
android:labelFor="#id/displayHeight"
android:text="#string/displayHeightLbl" />
<TextView
android:id="#+id/displayHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="#string/displayInfoEms" />
</LinearLayout>
<Button
android:id="#+id/displayInfoOkBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="dismissDisplayInfos"
android:text="#string/btnOk" />
</LinearLayout>
</ScrollView>
Google documentation suggested installing TalkBack and Accessibility Scanner, which enabled me to test and reproduce the problem. The solution is documented below.
The solution lay in adding
android:importantForAccessibility="no"
to the definition of the second TextView, as follows:
<TextView
android:id="#+id/displayHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
android:ems="#string/displayInfoEms" />
I assume that the reason for the report is that the first TextView contains an android:labelFor attribute, referring to the second TextView, and that the Accessibility Scanner looks at both and thinks that the descriptions are the same. Is this a bug in the Accessibility Scanner?

Android Widget displays error and updateAppWidget couldn't find any view

I’ve created a widget with the wizard. Then I’ve customized the layout.
I tried to run but all I got is the error view of the widget “Problem loading widget”.
Checking the log I found this error:
W/AppWidgetHostView: updateAppWidget couldn't find any view, using error view
It says that the system could not find any view, but my layout is defined in res/layout/ and declared in widget info xml file.
What am I missing? Here is the project on GitHub.
You're not doing much that's wrong. The entire app widget is setup correctly. It is purely a layout issue. It doesn't seem to be happy with the complexity of the playback_widget.xml file. I changed the file to the following:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/playback_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/poster_imageview"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/ic_headset_mic_light_black_140dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/title_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textAlignment="center"
android:textColor="#color/primaryTextColor"
android:textSize="16sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/default_text_padding">
<ImageView
android:id="#+id/player_previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:layout_toLeftOf="#+id/player_play_pause"
android:src="#drawable/ic_skip_previous_white_32dp" />
<ImageView
android:id="#+id/player_play_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_play_arrow_white_40dp" />
<ImageView
android:id="#+id/player_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:layout_toRightOf="#id/player_play_pause"
android:src="#drawable/ic_skip_next_white_32dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
The widget views appear fine now. I realise this probably isn't the exact layout that you're after, but you'll just have to play around with it until you find something that it is happy with.
Home screen widgets can be a bit tricky because you have a more limited set of views and less flexibility in terms of the layout.
Also I haven't checked but I'm not sure that the following view is allowed in homescreen widgets:
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="?colorAccent" />
Also if you have trouble getting that error to go away. Destroy the home screen widget and restart the phone. They sometimes get into a dorked up state during development.
But in any event your project is working fine for me after the playback_widget.xml change. Android 8.0.

Android Studio shows wrong layout in layout preview (ActionBarOverlayLayout?!)

I have a nice FrameLayout as main container and some other views inside it's hierarchy.
But the preview shows a simple ActionBarOverlayLayout.
What is that? Why is it here?
I have Android Studio 3.0.0
I have tried:
Restart Android Studio. Refresh the preview by resizing. Changed the preview device, changed the SDK of the preview, changed the blueprint\design options, pressed "force refresh layout" Button.
XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp">
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="match_parent"
android:layout_height="#dimen/walk_list_item_height"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:layout_heightPercent="25%"
app:layout_marginLeftPercent="0%"
app:layout_marginTopPercent="0%"
app:layout_widthPercent="100%"
app:riv_corner_radius="#dimen/corner_radius"
android:id="#+id/walk_iv" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/gradient"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<TextView
android:id="#+id/walk_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_vertical"
android:padding="16dp"
android:text="New Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_duration_icon" />
<TextView
android:id="#+id/duration_tv"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:gravity="center|left"
android:text="TextView"
android:textColor="#fff" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_marker"
android:layout_marginLeft="16dp" />
<TextView
android:id="#+id/stops_tv"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView"
android:textColor="#fff" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
That is because there is a broken build in your earlier build. It is coming from the intermediate files which is because the files are not proper in your xml files. There might be a broken link or a - in the drawables names.
Until you resolve this you cannot proceed to see the layout of your app in the layout-editor.
Moreover Android Studio will not show you any error in the error log or any other terminal.
Start from the styles/themes of the app, it might contain something which is missing from the gradle or resources of the project. Due to the support library still in the project it partially showcases it as missing control of XML files, but it will not let you load the xml editor visually for the project.
You have see that by yourself, start first from drawables and then move to values folder, if not check your gradle and then come back to Java files for the error.
Had to raise
buildToolsVersion to 26.0.0
previous was bugged (25.0.2)
I faced the same problem and, In my case, it was simpler than that. I just received a warning message recommending to remove the explict reference to the BuildToolsVerison from build.gradle file so I just did it, then saved all file, Menu >> Run >> Make a project and it worked fine.

Xamarin Android: How to add android.support.v7.widget.SearchView in xaml

I am trying to use the SearchView in my application. I decided to use android.support.v7.widget.SearchView but the xamarin studio have an error when rendering the layout in the designer.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/lightGray">
<TextView
android:id="#+id/weatherLocation"
android:textStyle="bold"
android:textColor="#color/material_grey_600"
style="#android:style/TextAppearance.Large"
android:layout_marginTop="#dimen/abc_action_bar_subtitle_bottom_margin_material"
android:layout_marginBottom="#dimen/abc_action_bar_subtitle_bottom_margin_material"
android:layout_marginLeft="#dimen/abc_action_bar_subtitle_bottom_margin_material"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<android.support.v7.widget.SearchView
style="#style/SearchViewStyle"
android:id="#+id/search"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/weatherLocation"
android:layout_alignEnd="#+id/weatherLocation"
android:layout_alignBottom="#+id/weatherLocation"
android:layout_alignParentEnd="true" />
Message : Custom controls disabled. There was an internal issue with the rendering process.
Does that mean i have not installed the package? I can't see it on nuget in xamarin studio.
P.S. I can compile and run but will have inflating error.
The packages you installed should be found in 'Installed' tab. If you can not find it, yes, it means you have not installed the package. You should install it on NuGet, search for 'Xamarin.Android.Support.v7.SearchView' and download it.

error: No resource identifier found for attribute 'showOuterShadow' in package

I am Developing an application that consists of a gauge view. I found code from here https://github.com/CodeAndMagic/GaugeView
I am getting an error of No resource identifier found forattribute'showOuterShadow' in package
'org.codeandmagic.android.gauge.demo. I added the library in the java build path of the project but it was still occurring please help me to solve this this is my xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:gauge="http://schemas.android.com/apk/res/org.codeandmagic.android.gauge.demo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="#drawable/background"
android:padding="20dp" >
<org.codeandmagic.android.gauge.GaugeView
android:id="#+id/gauge_view1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<org.codeandmagic.android.gauge.GaugeView <!--Error occurring here-->
android:id="#+id/gauge_view2"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="10dp"
gauge:showOuterShadow="true"
gauge:showOuterRim="false"
gauge:showNeedle="false"
gauge:showRanges="false"
gauge:showText="true"
gauge:textUnit="%" />
</LinearLayout>
This is so ridiculous to answer my own question:
i didn't add the library in my android project that is
YOUR PROJECT->RIGHTCLICK->POPERTIES->ANDROID->CLICK "ADD"->SELECT LIBRARY->CLICK "APPLY"->CLICK "OK"->RUN YOUR PROJECT

Categories

Resources