简体   繁体   English

Visual Studio 错误 linking.net6.0-android 应用程序

[英]Visual Studio Error linking net6.0-android app

I have converted a Xamarin Android App to a.net6.0-android app.我已经将 Xamarin Android 应用程序转换为.net6.0-android 应用程序。 It compiles fine but when it starts linking, it acts like it is trying to link Android libraries instead of AndroidX libraries.它编译得很好,但是当它开始链接时,它的行为就像是在尝试链接 Android 库而不是 AndroidX 库。 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.如果有人看到不支持 AndroidX 的明显红旗,请告诉我。

<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.我一直在将许多 Xamarin.Android 测试应用程序毫无问题地转换为 .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.我打算提到的一点是不要做你想做的事情,那就是尝试转换一个还不是 AndroidX 迁移应用程序的应用程序。

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.我认为期望将针对 Android 9 或 10 的 Android 应用程序成功迁移到 .Net6 或 .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.我建议在考虑迁移到 .Net 之前完全迁移到针对 Android 13 或至少 12 的 AndroidX。

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.您只需阅读 .Net6 文档,我想您已经阅读过,就会意识到这不是一个超级简单的过程。 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.我什至没有尝试使用他们的迁移工具,因为文档中的评论让我没有信心它会比 AndroidX 迁移工具更好,后者几乎几乎没用。 Like with AndroidX the best and most efficient way is unfortunately the hard way.不幸的是,与 AndroidX 一样,最好和最有效的方法是困难的方法。

After posting this, I re-read your question more carefully.发布后,我更仔细地重新阅读了您的问题。 Sounds like you may have already converted to AndroidX.听起来您可能已经转换为 AndroidX。 If you have, then I would suspect that you are using some 3rd party library that is still using the old support libs.如果你有,那么我会怀疑你正在使用一些仍在使用旧支持库的第 3 方库。

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 .我指的是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.我突然意识到我正在创建一些我自己的 Nuget 包。 It turns out that one of them targeted the old android libraries.事实证明,其中一个针对的是旧的 android 库。 It was actually an old version of MvvmCross which pulled them in Transitively.它实际上是一个旧版本的 MvvmCross 将它们以 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.一旦我更新我的 Nuget 以使用新的 MvvmCross 并在我的应用程序中使用我的 package 的新版本,它开始正常工作。 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.感谢所有帮助我指出正确方向的人,尤其是那些指出它试图引用 android.support.v4.view.ViewPager 的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM