Does mvvmicro/AutoFindviews supports AndoridX libraries? - xamarin

Currently I am trying to update Android support libraries to AndoridX in our project which is built on Xamarin.Android.
But when I use androidx widgets in layout files. Its throwing an error in autogenerated layout files.
[ex: I used <androidx.recyclerview.widget.RecyclerView> in FirstActivity.xml , I am getting error in FirstActivity.xml.g.cs file - "Error CS0246 The type or namespace name 'Androidx' could not be found (are you missing a using directive or an assembly reference?)" ]
FirstActivity.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:background="#color/backgroundColor">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<include
android:id="#+id/Indicator"
layout="#layout/Indicator" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="#dimen/margin_small"
/>
</FrameLayout>
</LinearLayout>
FirstActivity.xml.g.cs
On further analysis found that in our project, mvvmicro is used. which has a tool AutoFindviews.
Created a sample project without Autofindviews. It works fine with AndroidX.
Any inputs how to solve this? Thanks in Advance.

Related

Android Navigation library doesn't open deeplink

Can't open the deeplink URL.
Here is the code I used
<navigation 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:id="#+id/app_navigation"
app:startDestination="#id/loginActivity">
<activity
android:id="#+id/passwordCreateActivity"
android:name=".PasswordCreateActivity"
android:label="password_create_activity"
tools:layout="#layout/password_create_activity">
<deepLink
app:uri="www.example.com/auth/activate/{token}" />
</activity>
</navigation>
I have used the intent to open the deeplink
adb shell am start -a android.intent.action.VIEW -d "www.example.com/auth/activate/2i8haFs4NqxFdzRUYoYJbq1C0?check-scheme=1" com.example.app
dependency
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha02'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha02'
I have forgotten to register nav_graph in AndroidManifest file.
Here is the full code for the Deep Link.
nav_graph.xml
<navigation 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:id="#+id/app_navigation"
app:startDestination="#id/loginActivity">
<activity
android:id="#+id/passwordCreateActivity"
android:name=".PasswordCreateActivity"
android:label="password_create_activity"
tools:layout="#layout/password_create_activity">
<deepLink app:uri="www.example.com/auth/activate/{token}" />
</activity>
</navigation>
AndroidManifest.xml
<activity android:name=".PasswordCreateActivity">
<nav-graph android:value="#navigation/app_nav" />
</activity>

Xamarin Forms Mediaplugin Fileprovider

I'm trying to implement the MediaPlugin but I am running into a problem. I have done all steps in the setup instructions and get the following error:
Error: No resource found that matches the given name (at 'resource' with value '#xml/file_paths')
As explained in the setup instructions - in my Android project, I have added a folder inside the Resources-folder, called xml - containing a file called file_paths.xml with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-files-path name="my_images" path="Pictures" />
<external-files-path name="my_movies" path="Movies" />
</paths>
I expect this problem to be related to either the above or the AndroidManifest.xml, so I'll include my complete AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.company.Kvitt" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:label="Kvitt.Android">
<provider android:name="android.support.v4.content.FileProvider"
android:authorities="com.company.Kvitt.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths"/>
</provider>
</application>
</manifest>
Any help or ideas on how to solve this error are really appreciated!
The res/xml directory should be in the same sub-folder as other Resources; drawable, layout, mipmap-XXX, etc...
Do a clean all / build all just as a double check
Double-check your xml path in the project: Resources/xml/file_paths.xml
After a build, check the build artifacts for the file in obj/Debug/android/res/xml
If the resource file is not in the build artifacts the likely cause is the build action is wrong
Check that the build action on the file is set to AndroidResource

xamarin.forms Package restore failed

I am using visual studio 15.6.0 version. I have the following SDK Manager installed:
I am trying to use Google maps in my application. Below is my code on main.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App1"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
x:Class="App1.MainPage">
<maps:Map x:Name="MainMap"></maps:Map>
</ContentPage>
I also installed Xamarin.forms.maps. After that I am trying to install Xamarin.playservices.Base ,
Xamarin.playservices.Basement,
Xamarin.playservices.maps and
Xamarin.playservices.taks using nuget. Below is the image for manage nuget pacakges
I keep getting the below error when I tried to install this through nugget
Package restore failed. Rolling back package changes for 'App1.Android'.
Do I need Xamarin.playservices.Base, Basement, Tasks in order to use Google maps? My main.xaml.cs code looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
namespace App1
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
MainMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(36.89, 10.18), Distance.FromKilometers(5)));
}
}
}
when I tried to run the application, I don't see any maps although I can see the icon for app1 and when I double click a blank page comes up. My android manifest file looks like below:
and my android manifest.xml file looks like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.co.App1" android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:label="$safeprojectname$">
<meta-data android:label="com.google.android.maps.geo.API_KEY" android:value="AIzaSyDxhj-n96-YaWHibZU2e5BK02U9UzRCnC0" />
</application>
</manifest>
Below is the compile target version:
below is the image of the references that are added to my project:
Do I need Xamarin.playservices.Base, Basement, Tasks in order to use Google maps?
Actually, with VS 15.6, there is no need to install Xamarin.playservices.Base and other dependencies independently. When you are installing Xamarin.Forms.Maps to the native project, the related dependencies will be referenced into your project, and you will be notified by a pop-up dialog:

Android how to create menu drop down list view?

enter image description here
I find it too beautiful. please help. Thanks very much
You can use spinner here is example
<Spinner
android:id="#+id/planets_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<?xml version="1.0" encoding="utf-8"?>
And resources:
<resources>
<string-array name="planets_array">
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
<item>Jupiter</item>
<item>Saturn</item>
<item>Uranus</item>
<item>Neptune</item>
</string-array>
</resources>

AdMob - You must have AdActivity declared in AndroidManifest.xml with configChanges

I am trying to get admob to work in my Xamarin Android application but I get the following message when trying to display an add:
"You must have AdActivity declared in AndroidManifest.xml with configChanges"
I ave added the Xamarin google play service to my application.
I am set the java heap size to 1G and build with API level 14
I have googled the error message and most answerspoint to the manifest file that needs to include two entries. I have added the entries but still have the problem.
Any idea what I am doing wrong? Here is my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:installLocation="auto" android:versionName="1.0">
<uses-sdk />
<application android:label="Aftermath">
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Thanks

Resources