xamarin net7-android app crashing on startup with error Unable to get provider androidx.startup.InitializationProvider

41ik7eoe  于 11个月前  发布在  Android
关注(0)|答案(1)|浏览(169)

我有一个在net 6-android下工作的应用程序.这显然不再支持,所以我升级到net 7-android.我更新了所有的Nuget包.它编译没有和错误.当我尝试运行它,我得到以下在我的日志:

Start debugging Android application ...
Forwarding debugger port 8807
Detecting existing process
> am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "MyApp.Droid/crc6469fa8dc12c3039f6.SplashScreen"
> Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=MyApp.Droid/crc6469fa8dc12c3039f6.SplashScreen }
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/MyApp.Droid.dll
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/Mono.Android.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Runtime.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/Java.Interop.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Runtime.InteropServices.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Collections.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Threading.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Threading.Thread.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Diagnostics.StackTrace.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/MvvmCross.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/MyApp.Core.dll
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Memory.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Reflection.Emit.Lightweight.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Reflection.Emit.ILGeneration.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Reflection.Primitives.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/System.Console.dll [External]
Loaded assembly: /data/data/MyApp.Droid/files/.__override__/Xamarin.AndroidX.Startup.StartupRuntime.dll [External]
**Java.Lang.RuntimeException:** 'Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/collection/ArraySet;'

[Zygote] isWhitelistProcess - Process is Whitelisted
[Zygote] accessInfo : 1
[PSCOMData.Droi] Late-enabling -Xcheck:jni
[PSCOMData.Droi] Unknown bits set in runtime_flags: 0x8000
[debug-app-helper] Checking if libmonodroid was unpacked to /data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/lib/arm64/libmonodroid.so
[debug-app-helper] Native libs extracted to /data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/lib/arm64, assuming application/android:extractNativeLibs == true
[debug-app-helper] Setting up for DSO lookup in app data directories
[debug-app-helper] Added filesystem DSO lookup location: /data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/lib/arm64
[debug-app-helper] Using runtime path: /data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/lib/arm64
[debug-app-helper] checking directory: `/data/user/0/MyApp.Droid/files/.__override__/lib`
[debug-app-helper] directory does not exist: `/data/user/0/MyApp.Droid/files/.__override__/lib`
[debug-app-helper] Checking whether Mono runtime exists at: /data/user/0/MyApp.Droid/files/.__override__/libmonosgen-2.0.so
[debug-app-helper] Checking whether Mono runtime exists at: /data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/lib/arm64/libmonosgen-2.0.so
[debug-app-helper] Mono runtime found at: /data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/lib/arm64/libmonosgen-2.0.so
[PSCOMData.Droi] Attempt to remove non-JNI local reference, dumping thread
[DOTNET] JNI_OnLoad: JNI_OnLoad in pal_jni.c
[DOTNET] GetOptionalClassGRef: optional class com/android/org/conscrypt/OpenSSLEngineImpl was not found
[monodroid] Creating public update directory: `/data/user/0/MyApp.Droid/files/.__override__`
[PSCOMData.Droi] Attempt to remove non-JNI local reference, dumping thread
[monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8807,server=y,embedding=1,timeout=1700164891
[TcpOptimizer] TcpOptimizer-ON
[monodroid-assembly] open_from_bundles: failed to load assembly MyApp.Droid.dll
[monodroid-gc] GREF GC Threshold: 46080
[monodroid-assembly] open_from_bundles: failed to load assembly Mono.Android.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Java.Interop.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Runtime.InteropServices.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Collections.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Threading.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Threading.Thread.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Diagnostics.StackTrace.dll
[PSCOMData.Droi] Attempt to remove non-JNI local reference, dumping thread
[monodroid-assembly] open_from_bundles: failed to load assembly MvvmCross.dll
[monodroid-assembly] open_from_bundles: failed to load assembly MyApp.Core.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Memory.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Reflection.Emit.Lightweight.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Reflection.Emit.ILGeneration.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Reflection.Primitives.dll
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: MyApp.Droid, PID: 15913
[AndroidRuntime] java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/collection/ArraySet;
[AndroidRuntime]    at android.app.ActivityThread.installProvider(ActivityThread.java:7769)
[AndroidRuntime]    at android.app.ActivityThread.installContentProviders(ActivityThread.java:7309)
[AndroidRuntime]    at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7166)
[AndroidRuntime]    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7134)
[AndroidRuntime]    at android.app.ActivityThread.access$1600(ActivityThread.java:274)
[AndroidRuntime]    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2102)
[AndroidRuntime]    at android.os.Handler.dispatchMessage(Handler.java:107)
[AndroidRuntime]    at android.os.Looper.loop(Looper.java:237)
[AndroidRuntime]    at android.app.ActivityThread.main(ActivityThread.java:8167)
[AndroidRuntime]    at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime]    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
[AndroidRuntime]    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
[AndroidRuntime] Caused by: androidx.startup.StartupException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/collection/ArraySet;
[AndroidRuntime]    at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:187)
[AndroidRuntime]    at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
[AndroidRuntime]    at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
[AndroidRuntime]    at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
[AndroidRuntime]    at android.content.ContentProvider.attachInfo(ContentProvider.java:2113)
[AndroidRuntime]    at android.content.ContentProvider.attachInfo(ContentProvider.java:2087)
[AndroidRuntime]    at android.app.ActivityThread.installProvider(ActivityThread.java:7764)
[AndroidRuntime]    ... 11 more
[AndroidRuntime] Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/collection/ArraySet;
[AndroidRuntime]    at androidx.emoji2.text.EmojiCompat.<init>(EmojiCompat.java:473)
[AndroidRuntime]    at androidx.emoji2.text.EmojiCompat.init(EmojiCompat.java:558)
[AndroidRuntime]    at androidx.emoji2.text.EmojiCompatInitializer.create(EmojiCompatInitializer.java:88)
[AndroidRuntime]    at androidx.emoji2.text.EmojiCompatInitializer.create(EmojiCompatInitializer.java:73)
[AndroidRuntime]    at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:180)
[AndroidRuntime]    ... 17 more
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.collection.ArraySet" on path: DexPathList[[zip file "/data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/base.apk"],nativeLibraryDirectories=[/data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/lib/arm64, /data/app/MyApp.Droid-yqf3peJOUcn7MVs7DLzQ7g==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
[AndroidRuntime]    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
[AndroidRuntime]    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
[AndroidRuntime]    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[AndroidRuntime]    ... 22 more
[monodroid-assembly] open_from_bundles: failed to load assembly System.Console.dll
[monodroid-assembly] open_from_bundles: failed to load assembly Xamarin.AndroidX.Startup.StartupRuntime.dll

字符串
我的Projectd看起来像这样:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net7.0-android</TargetFramework>
    <SupportedOSPlatformVersion>29.0</SupportedOSPlatformVersion>
    <OutputType>Exe</OutputType>
    <Nullable>disable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ApplicationId>MyApp.Droid</ApplicationId>
    <RootNamespace>MyApp.Droid</RootNamespace>
    <AndroidSigningKeyStore>KeyStore</AndroidSigningKeyStore>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <Optimize>True</Optimize>
    <DebugSymbols>True</DebugSymbols>
    <EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
    <AndroidUseAapt2>True</AndroidUseAapt2>
    <AndroidEnableMultiDex>False</AndroidEnableMultiDex>
    <AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
    <AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
    <AndroidPackageFormat>apk</AndroidPackageFormat>
    <GenerateAssemblyInfo>True</GenerateAssemblyInfo>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
    <AndroidUseAapt2>True</AndroidUseAapt2>
    <AndroidPackageFormat>apk</AndroidPackageFormat>
    <AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
    <AndroidEnableMultiDex>False</AndroidEnableMultiDex>
    <GenerateAssemblyInfo>True</GenerateAssemblyInfo>
    <Optimize>True</Optimize>
  </PropertyGroup>
  <ItemGroup>
    <Compile Remove="LinkerPleaseInclude.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Remove="KeyStore" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AppCenter.Analytics" Version="5.0.3" />
    <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.3" />
    <PackageReference Include="Microsoft.AppCenter.Distribute" Version="5.0.3" />
    <PackageReference Include="MvvmCross" Version="9.1.1" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
    <PackageReference Include="Serilog.Sinks.Xamarin" Version="1.0.0" />
    <PackageReference Include="Xamarin.AndroidX.Browser" Version="1.6.0.2" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\MyApp.Core\MyApp.Core.csproj" />
    <ProjectReference Include="..\MPSMobileCommon.Droid\MPSMobileCommon.Droid.csproj" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Assets\appsettings.bin" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Properties\" />
  </ItemGroup>
</Project>


我也试过回滚Nuget包。似乎没有什么工作。有人能帮忙吗?

4xy9mtcn

4xy9mtcn1#

你在项目中使用了Xamarin.AndroidX.Startup.StartupRuntime包吗?
根据这个案例:Unable to get provider androidx.startup.InitializationProvider,您可以尝试在AndroidManifest.xml中添加以下代码,以禁用应用自动初始化:

<provider
        android:name="androidx.startup.InitializationProvider"
        android:authorities="${applicationId}.androidx-startup"
        tools:node="remove" />

字符串
另外,我检查了你使用的nuget包,MvvmCross" Version="9.1.1Serilog.Sinks.Xamarin Version="1.0.0"没有显示对.net 7.0的依赖。
Xamarin.AndroidX.Browser Version="1.4.0.3"则被.net 7 android sdk引用。

相关问题