-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicitly using R8 will result in unexpected behavior (while implicitly using R8 works as expected) #6612
Comments
There are 2 linkers in use here: 1) the .NET linker for C# code, 2) r8 for Java code. Unfortunately no. 2 (r8) depends on no. 1 (.NET linker) being enabled, as it uses a custom linker step to generate So if you set any of these when
Then you would probably hit an error that However, what are you actually trying to accomplish? Are you just wanting to enable I think we need to see adb logcat output of the actual crash/stack trace, and we can help further. Thanks! |
@jonathanpeppers Thanks!
I had I was already aware at the time (because I have kind of living inside the android build target files over the last days to figure out how to get my projects to a beta testable state) that R8 is the implicit default (or the only option) in .NET 6. Just didn't think it would hurt to set it explicitly. So the linear progression outlined in my OP is not really how it chronologically happend 😄 While I got everything working with trimming disabled, I want to release a smaller package. So after I have now removed the explicit I am now tracking down an issue connected to trimming with images not being loaded by an This is what I described previously as:
The following exception is thrown internally: Exception
My guess is that the delegate target was trimmed, because it was not discovered by static analysis, and I have to figure out where it is to preserve it. |
Just in case anybody stumbles across this issue here in the future: To figure out the trimmed I then used the workload containing dotnet SDK from In my case, the I then created a <linker>
<assembly fullname="Mono.Android">
<type fullname="Android.Runtime.InputStreamAdapter" />
</assembly>
</linker> Finally, I added the file to my project file: <ItemGroup>
<TrimmerRootDescriptor Include="Roots.xml" />
</ItemGroup> @jonathanpeppers I think tracking down a simple issue like this is way too much effort (at least for the first one, until you got everything setup). The initial Exception should really just include the target type and the missing method, since with |
Two two issues here?
We could |
@jonathanpeppers XamarinAndroidIssue6612.zip will show the Xamarin icon in The Xamarin.Forms |
@lauxjpn I think the two issues here are fixed in:
Are you still hitting this issue using the latest RC 1 builds? |
Closing for now, let us know, thanks! |
Android application type
Android for .NET (net6.0-android, etc.)
Affected platform version
.NET 6.0.100
Description
I have the following basic project definition:
I then build and deploy a
Release
version without explicitly specifying any related properties.The app starts, but at some later point when using the app, some stuff is missing which then leads to the app crashing.
That is not completely unexpected, since the default behavior in .NET 6 is to aggressively link away pretty much everything that wasn't statically detected as being used.
I then set the following property:
The app builds, deploys and now also runs fully as expected.
Great, I could have stopped here, but didn't.
I then explicitly set the following property:
When I now build the app, I get the following warning:
obj\Release\net6.0-android\android-x64\proguard\proguard_project_references.cfg: Warning XA4304 : ProGuard configuration file 'obj\Release\net6.0-android\android-x64\proguard\proguard_project_references.cfg' was not found.
When I run the app, I get the following exception immediately:
java.lang.ClassNotFoundException
It appears, that suddenly R8 has trimmed so aggressively, that even the most basic stuff is missing.
I then disable trimming:
The same exception is still being thrown.
I then try the following combination:
The same exception is still being thrown.
I then disable shrinking via a Proguard configuration option:
Proguard\KeepClasses.cfg:
While the build warning is still being shown, the app now runs fine again.
So it appears that when I explicitly set
<AndroidLinkTool>r8</AndroidLinkTool>
the behavior is different in comparison to when it is implicitly being set. This might be related to theproguard_project_references.cfg
file missing at build time.The behavior should be the same in both cases (the one with the missing
proguard_project_references.cfg
seems to be a bug).Steps to Reproduce
See description.
Did you find any workaround?
Don't explicitly specify
<AndroidLinkTool>r8</AndroidLinkTool>
.Relevant log output
The text was updated successfully, but these errors were encountered: