Closed anasonov1992 closed 1 year ago
https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetEmbeddedResources.md isn't very explicit about it, but in .NET 6+ binding projects the .aar
is not embedded into the resulting .dll
like it was in Xamarin.Android classic. This means that the user is responsible for providing both the .aar
and the .dll
to the consuming application.
For a <ProjectReference>
and a <PackageReference>
this is done for you, however for a regular <Reference>
, you are just specifying an arbitrary file location and there is no way to automatically find the .aar
unless it is next to the .dll
.
That is, your file system should look like this:
- \Dependencies
- YandexMetricaBinding.Android.dll
- mobmetricalib-5.3.0.aar
When it pulls in the .dll
, it will pull in any .aar
files that are in the same directory.
Hi @anasonov1992. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@jpobst thank you very much! Your solution is working.
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS 2022 17.4.5, .NET 7.0.103
Description
We created Android Binding Library project over native third-party .aar file (mobmetricalib-5.3.0.aar), successfully build it in Release configuration and get library DLL (YandexMetrica.Binding.Android.DLL). Here is library .csproj file
Then we added YandexMetrica.Binding.Android.DLL to our .NET Android app project.
We run the app project and get runtime crash on app startup when trying to create class instance "com.yandex.metrica.YandexMetricaConfig":
Didn't find class "com.yandex.metrica.YandexMetricaConfig" on path: DexPathList[[zip file "/data/app/~~Lm0T2DYjFpZvzfbMp2z1tw==/com.ILive.Droid-RGemdbm_9-rKS9r5P4-XGQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~Lm0T2DYjFpZvzfbMp2z1tw==/com.ILive.Droid-RGemdbm_9-rKS9r5P4-XGQ==/lib/arm64, /data/app/~~Lm0T2DYjFpZvzfbMp2z1tw==/com.ILive.Droid-RGemdbm_9-rKS9r5P4-XGQ==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
YandexMetricaConfig is a class from the library DLL and as decompiler shows the DLL contains it.
But it seems this class is not presented in resulting Dex files.
We try to turn on MultiDex option in the app project but it doesn't help. Also we don't use Code Shrinker or any Proguard configurations.
We suppose it may be some packing problem of Android Binding Library based on .NET 7. We attached an archive with our Android Binding Library project as well. YandexMetricaBinding.Android.zip
Steps to Reproduce
Did you find any workaround?
No workaround for now
Relevant log output