Unable to build Xamarin solution on Android - xamarin

Please tell me how to fix the problem. I updated Xamarin forms dll.
I get the following error:
Error error: cannot find symbol
private native void n_onInflate (android.support.v7.widget.ViewStubCompat p0, android.view.View p1);
symbol: class ViewStubCompat
location: package android.support.v7.widget
obj\Debug\android\src\mono\android\support\v7\widget\ViewStubCompat_OnInflateListenerImplementor.java
Error error: cannot find symbol
public void onInflate (android.support.v7.widget.ViewStubCompat p0, android.view.View p1)
symbol: class ViewStubCompat
location: package android.support.v7.widget
obj\Debug\android\src\mono\android\support\v7\widget\ViewStubCompat_OnInflateListenerImplementor.java
Error error: package android.support.v7.widget.ContentFrameLayout does not exist
android.support.v7.widget.ContentFrameLayout.OnAttachListener
obj\Debug\android\src\mono\android\support\v7\widget\ContentFrameLayout_OnAttachListenerImplementor.java
Error error: package android.support.v7.widget.FitWindowsViewGroup does not exist
android.support.v7.widget.FitWindowsViewGroup.OnFitSystemWindowsListener
\obj\Debug\android\src\mono\android\support\v7\widget\FitWindowsViewGroup_OnFitSystemWindowsListenerImplementor.java
Error error: package android.support.v7.widget.ViewStubCompat does not exist
android.support.v7.widget.ViewStubCompat.OnInflateListener
\obj\Debug\android\src\mono\android\support\v7\widget\ViewStubCompat_OnInflateListenerImplementor.java

Did you "update all Nuget packages"? This will download the incorrect versions of the Google libs. You will have to update the Forms packages manually, they will then pull in the required dependencies.
Also make sure you update the packages in all of your projects (the actual Forms project and the platform specific ones).
Finally, clean the solution and rebuild.

James Montemagno explains the issue perfectly here:
Xamarin Forums
I suspect you have updated all packages which will require manual intervention as described by #Krumelur above.

Related

Visual Studio Error linking net6.0-android app

I have converted a Xamarin Android App to a net6.0-android app. It compiles fine but when it starts linking, it acts like it is trying to link Android libraries instead of AndroidX libraries. The following is a snippet of the type of linking errors I am getting.
4>obj\Debug\net6.0-android33.0\android\src\mono\android\support\v4\view\ViewPager_OnAdapterChangeListenerImplementor.java:33: error: package android.support.v4.view does not exist
4> private native void n_onAdapterChanged (android.support.v4.view.ViewPager p0, android.support.v4.view.PagerAdapter p1, android.support.v4.view.PagerAdapter p2);
4> ^
4>obj\Debug\net6.0-android33.0\android\src\mono\android\support\v4\view\ViewPager_OnAdapterChangeListenerImplementor.java:33: error: package android.support.v4.view does not exist
4> private native void n_onAdapterChanged (android.support.v4.view.ViewPager p0, android.support.v4.view.PagerAdapter p1, android.support.v4.view.PagerAdapter p2);
4> ^
4>obj\Debug\net6.0-android33.0\android\src\mono\android\support\v4\view\ViewPager_OnPageChangeListenerImplementor.java:8: error: package android.support.v4.view.ViewPager does not exist
4> android.support.v4.view.ViewPager.OnPageChangeListener
4> ^
4>obj\Debug\net6.0-android33.0\android\src\mono\android\support\v4\view\ViewPropertyAnimatorListenerImplementor.java:8: error: package android.support.v4.view does not exist
4> android.support.v4.view.ViewPropertyAnimatorListener
4> ^
4>obj\Debug\net6.0-android33.0\android\src\mono\android\support\v4\view\ViewPropertyAnimatorUpdateListenerImplementor.java:8: error: package android.support.v4.view does not exist
4> android.support.v4.view.ViewPropertyAnimatorUpdateListener
4>
4>obj\Debug\net6.0-android33.0\android\src\android\support\customtabs\CustomTabsClient_CustomTabsCallbackImpl.java(23,7): javac.exe error JAVAC0000: error: cannot find symbol
4>obj\Debug\net6.0-android33.0\android\src\android\support\customtabs\CustomTabsClient_CustomTabsCallbackImpl.java(23,7): javac.exe error JAVAC0000: if (getClass () == CustomTabsClient_CustomTabsCallbackImpl.class)
4>obj\Debug\net6.0-android33.0\android\src\android\support\customtabs\CustomTabsClient_CustomTabsCallbackImpl.java(23,7): javac.exe error JAVAC0000: symbol: method getClass()
4>obj\Debug\net6.0-android33.0\android\src\android\support\customtabs\CustomTabsClient_CustomTabsCallbackImpl.java(23,7): javac.exe error JAVAC0000: location: class CustomTabsClient_CustomTabsCallbackImpl
4>obj\Debug\net6.0-android33.0\android\src\android\support\customtabs\CustomTabsClient_CustomTabsCallbackImpl.java(23,7): javac.exe error JAVAC0000:
4>obj\Debug\net6.0-android33.0\android\src\crc64a98abb514ffad9f1\CustomTabsServiceConnectionImpl.java(23,7): javac.exe error JAVAC0000: error: cannot find symbol
4>obj\Debug\net6.0-android33.0\android\src\crc64a98abb514ffad9f1\CustomTabsServiceConnectionImpl.java(23,7): javac.exe error JAVAC0000: if (getClass () == CustomTabsServiceConnectionImpl.class)
4>obj\Debug\net6.0-android33.0\android\src\crc64a98abb514ffad9f1\CustomTabsServiceConnectionImpl.java(23,7): javac.exe error JAVAC0000: symbol: method getClass()
4>obj\Debug\net6.0-android33.0\android\src\crc64a98abb514ffad9f1\CustomTabsServiceConnectionImpl.java(23,7): javac.exe error JAVAC0000: location: class CustomTabsServiceConnectionImpl
4>obj\Debug\net6.0-android33.0\android\src\crc64a98abb514ffad9f1\CustomTabsServiceConnectionImpl.java(23,7): javac.exe error JAVAC0000:
Does anyone have any ideas of what I can do to fix this?
Thanks,
Jim
Update!
These are the packages I am using. If anyone sees a glaring red flag that they don't support AndroidX, please let me know.
<PackageReference Include="IdentityModel.OidcClient" Version="5.2.0" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="5.0.1" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.1" />
<PackageReference Include="Microsoft.AppCenter.Distribute" Version="5.0.1" />
<PackageReference Include="MvvmCross" Version="9.0.2" />
<PackageReference Include="SByteDev.Serilog.Sinks.AppCenter" Version="1.0.2" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Xamarin" Version="1.0.0" />
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.4.0.3" />
I've been converting a number of Xamarin.Android test apps without too many problems to .Net7. I'm writing a how-to support article at the moment which I hope to publish in the next couple of days with test projects to share. One of the points I intend to mention is not to do what you are attempting to do and that is to attempt to convert an app that is not already an AndroidX migrated app.
I think it would be one hell of a stretch to expect an android app targeted at Android 9 or 10 to be successfully migrated to .Net6 or .Net7. It might be possible, but I'd really doubt it. I would suggest fully migrating to AndroidX targeting Android 13 or at least 12, before even considering migrating to .Net.
You have plenty of time to do it, so there is no need to rush it. You've only got to read the .Net6 documentation, which I presume you have done, to realise that it is not a super simple procedure. I haven't even attempted to use their migration tool as the remarks in the docs give me no confidence that it would be any better than the AndroidX migration tool, which was practically next to useless. Like with AndroidX the best and most efficient way is unfortunately the hard way.
After posting this, I re-read your question more carefully. Sounds like you may have already converted to AndroidX. If you have, then I would suspect that you are using some 3rd party library that is still using the old support libs.
To clarify - as compared to the previous answer. The docs I was referring to https://github.com/xamarin/xamarin-android/wiki/Migrating-Xamarin.Android-Applications-to-.NET-6.
It dawned on me that I was creating some of my own Nuget packages. It turns out that one of them targeted the old android libraries. It was actually an old version of MvvmCross which pulled them in Transitively. Once I updated my Nuget to use the new MvvmCross and used the new version of my package in my app, it started working fine. Thanks to all who helped point me in the right direction, especially those who pointed out that it was trying to reference android.support.v4.view.ViewPager.

Cannot access AutoSizeableTextView public class ButtonRenderer

Visual Studio shows these errors:
error: cannot access AutoSizeableTextView
public class ButtonRenderer
class file for android.support.v4.widget.AutoSizeableTextView not found - file: \obj\Debug\81\android\src\md5f92e0daf340890c9667469657ee2ece8\ButtonRenderer.java
error: cannot access NestedScrollingChild2
public class ItemsViewRenderer
class file for android.support.v4.view.NestedScrollingChild2 not found - file: \obj\Debug\81\android\src\md51558244f76c53b6aeda52c8a337f2c37\ItemsViewRenderer.java
error: cannot access NestedScrollingParent2
public class SwipeDismissBehavior_OnDismissListenerImplementor
class file for android.support.v4.view.NestedScrollingParent2 not found - file: \obj\Debug\81\android\src\mono\android\support\design\widget\SwipeDismissBehavior_OnDismissListenerImplementor.java
error: cannot access TintableImageSourceView
public class ImageButtonRenderer
class file for android.support.v4.widget.TintableImageSourceView not found - file: \obj\Debug\81\android\src\md51558244f76c53b6aeda52c8a337f2c37\ImageButtonRenderer.java
I installed some packages that I think caused the problem: I installed OneSignal, and the AppLinks, that required installing Xamarin.GooglePlayServices.Base and Xamarin.GooglePlayServices.Basement. then had some conflicts between Android specific packages, I removed all packages I installed down to OneSignal. I deleted the bin and obj folder, did clean and build the project, and restarted Visual Studio, but the problem doesn't go away!
It turned out that I installed the package Crosslight.Xamarin.GooglePlayServices.Base by Intersoft Solutions, misled by the package name, while I was trying to download the package by Microsoft, I removed it and now the project works normally

Failed to add reference to 'Microsoft.DiaSymReader.Native.amd64'

I have created a nuget package and published to Azure. When I add the package to another project it fails with the following error:
I followed the same process for every other nuget package without issues. Any tips?

System.Web.Http.GlobalConfiguration does not contain a definition for 'Configure

In global asax cs file i have this line:
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
which causes this error.
I have tried as suggested on other forums:
Open the Package Manager Console for the project with the error.
Type in Install-Package Microsoft.AspNet.WebApi.WebHost and hit Enter
Rebuild your project and all should be right with the world (or at least right with your project)
The output was:
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 5.2.2 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 5.2.2)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.4)'.
'Microsoft.AspNet.WebApi.WebHost 5.2.2' already installed.
SM.EORD.Web already has a reference to 'Microsoft.AspNet.WebApi.WebHost 5.2.2'.
and error is still there. What could be wrong?
br, Simon
After hours of investigating i have found out that after I have installed ASP.NET Web API 2.2, the reference path of all dlls was from some old Web API - it didn't take the new ones.
The new dlls has been installed in packages folder, while the old one were in bin folder inside project.
if you want to update your references as well next time try upgrading from the package manager console you can update all or just specify the package name. Update package will upgrade vs installing a new package and you have manually go update your references.
Update-Package
In my case, the problem was that I renamed the Namespace of my project, and I did not know I needed to manually edit the namespaces section of the Views\Web.Config to match my new namespace.

Appcelerator Titanium - adding a MODULE

I have compiled an Android module for Titanium mobile SDK 2.1.3, but when I try to add it to an empty application I get the following error, when I try to build the app.
[ERROR] Error(s) compiling generated Java code
[ERROR] C:\Users\foobar\My Documents\Titanium Studio Workspace\RT\build\android\gen\com\foobar\FBApplication.java:42: cannot find symbol
symbol : class SpspmoduleBootstrap
location: package com.foobar.spspmodule
runtime.addExternalModule("com.foobar.spspmodule", com.foobar.spspmodule.SpspmoduleBootstrap.class);
Anyone have any ideas?

Resources