-
Notifications
You must be signed in to change notification settings - Fork 537
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
R8 linking causes runtime crashes on new IDE installations due to missing proguard rules file #8397
Comments
This is likely the same as: |
Context dotnet#8337 dotnet#8397 The latest Android sdk no longer ships with `proguard` as a result the file in proguard-android.txt [1] is missing. As a result customers are reporting errors such as ``` Unhandled Exception from source=AndroidEnvironment Java.Lang.Exception: android.view.View_IOnClickListenerImplementor at Java.Interop.JniEnvironment.Types.TryFindClass(String , Boolean ) at Java.Interop.JniEnvironment.Types.FindClass(String ) at Java.Interop.JniType..ctor(String ) at Java.Interop.JniPeerMembers.JniInstanceMethods..ctor(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.GetConstructorsForType(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String , Type , JniArgumentValue* ) at Android.Views.View.IOnClickListenerImplementor..ctor() at Android.Views.View.__CreateIOnClickListenerImplementor() at Java.Interop.EventHelper.AddEventHandler[IOnClickListener,IOnClickListenerImplementor](WeakReference& , Func`1 , Action`1 , Action`1 ) at Android.Views.View.add_Click(EventHandler ) at com.glmsoftware.obdnowpros.Fragments.SubscriptionFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) --- End of managed Java.Lang.Exception stack trace --- ``` This is probably because certain code is removed that in the latest version of R8 that used to be left in place. We should include the contents of this removed file in our own proguard_xamarin.cfg file. [1] https://android.googlesource.com/platform/sdk/+/refs/heads/main/files/proguard-android.txt
The runtime crash related to Maybe we keep this open to address the warning, though:
|
Context dotnet#8337 dotnet#8397 The latest Android sdk no longer ships with `proguard` as a result the file in proguard-android.txt [1] is missing. As a result customers are reporting errors such as ``` Unhandled Exception from source=AndroidEnvironment Java.Lang.Exception: android.view.View_IOnClickListenerImplementor at Java.Interop.JniEnvironment.Types.TryFindClass(String , Boolean ) at Java.Interop.JniEnvironment.Types.FindClass(String ) at Java.Interop.JniType..ctor(String ) at Java.Interop.JniPeerMembers.JniInstanceMethods..ctor(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.GetConstructorsForType(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String , Type , JniArgumentValue* ) at Android.Views.View.IOnClickListenerImplementor..ctor() at Android.Views.View.__CreateIOnClickListenerImplementor() at Java.Interop.EventHelper.AddEventHandler[IOnClickListener,IOnClickListenerImplementor](WeakReference& , Func`1 , Action`1 , Action`1 ) at Android.Views.View.add_Click(EventHandler ) at com.glmsoftware.obdnowpros.Fragments.SubscriptionFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) --- End of managed Java.Lang.Exception stack trace --- ``` This is probably because certain code is removed that in the latest version of R8 that used to be left in place. We should include the contents of this removed file in our own proguard_xamarin.cfg file. [1] https://android.googlesource.com/platform/sdk/+/refs/heads/main/files/proguard-android.txt
Context dotnet#8337 dotnet#8397 The latest Android sdk no longer ships with `proguard` as a result the file in proguard-android.txt [1] is missing. As a result customers are reporting errors such as ``` Unhandled Exception from source=AndroidEnvironment Java.Lang.Exception: android.view.View_IOnClickListenerImplementor at Java.Interop.JniEnvironment.Types.TryFindClass(String , Boolean ) at Java.Interop.JniEnvironment.Types.FindClass(String ) at Java.Interop.JniType..ctor(String ) at Java.Interop.JniPeerMembers.JniInstanceMethods..ctor(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.GetConstructorsForType(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String , Type , JniArgumentValue* ) at Android.Views.View.IOnClickListenerImplementor..ctor() at Android.Views.View.__CreateIOnClickListenerImplementor() at Java.Interop.EventHelper.AddEventHandler[IOnClickListener,IOnClickListenerImplementor](WeakReference& , Func`1 , Action`1 , Action`1 ) at Android.Views.View.add_Click(EventHandler ) at com.glmsoftware.obdnowpros.Fragments.SubscriptionFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) --- End of managed Java.Lang.Exception stack trace --- ``` This is probably because certain code is removed that in the latest version of R8 that used to be left in place. We should include the contents of this removed file in our own proguard_xamarin.cfg file. [1] https://android.googlesource.com/platform/sdk/+/refs/heads/main/files/proguard-android.txt
Context dotnet#8337 dotnet#8397 The latest Android sdk no longer ships with `proguard` as a result the file in proguard-android.txt [1] is missing. As a result customers are reporting errors such as ``` Unhandled Exception from source=AndroidEnvironment Java.Lang.Exception: android.view.View_IOnClickListenerImplementor at Java.Interop.JniEnvironment.Types.TryFindClass(String , Boolean ) at Java.Interop.JniEnvironment.Types.FindClass(String ) at Java.Interop.JniType..ctor(String ) at Java.Interop.JniPeerMembers.JniInstanceMethods..ctor(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.GetConstructorsForType(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String , Type , JniArgumentValue* ) at Android.Views.View.IOnClickListenerImplementor..ctor() at Android.Views.View.__CreateIOnClickListenerImplementor() at Java.Interop.EventHelper.AddEventHandler[IOnClickListener,IOnClickListenerImplementor](WeakReference& , Func`1 , Action`1 , Action`1 ) at Android.Views.View.add_Click(EventHandler ) at com.glmsoftware.obdnowpros.Fragments.SubscriptionFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) --- End of managed Java.Lang.Exception stack trace --- ``` This is probably because certain code is removed that in the latest version of R8 that used to be left in place. We should include the contents of this removed file in our own proguard_xamarin.cfg file. [1] https://android.googlesource.com/platform/sdk/+/refs/heads/main/files/proguard-android.txt
Context dotnet#8337 dotnet#8397 The latest Android sdk no longer ships with `proguard` as a result the file in proguard-android.txt [1] is missing. As a result customers are reporting errors such as ``` Unhandled Exception from source=AndroidEnvironment Java.Lang.Exception: android.view.View_IOnClickListenerImplementor at Java.Interop.JniEnvironment.Types.TryFindClass(String , Boolean ) at Java.Interop.JniEnvironment.Types.FindClass(String ) at Java.Interop.JniType..ctor(String ) at Java.Interop.JniPeerMembers.JniInstanceMethods..ctor(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.GetConstructorsForType(Type ) at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String , Type , JniArgumentValue* ) at Android.Views.View.IOnClickListenerImplementor..ctor() at Android.Views.View.__CreateIOnClickListenerImplementor() at Java.Interop.EventHelper.AddEventHandler[IOnClickListener,IOnClickListenerImplementor](WeakReference& , Func`1 , Action`1 , Action`1 ) at Android.Views.View.add_Click(EventHandler ) at com.glmsoftware.obdnowpros.Fragments.SubscriptionFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) --- End of managed Java.Lang.Exception stack trace --- ``` This is probably because certain code is removed that in the latest version of R8 that used to be left in place. We should include the contents of this removed file in our own proguard_xamarin.cfg file. [1] https://android.googlesource.com/platform/sdk/+/refs/heads/main/files/proguard-android.txt
This update to Azure Devops and Github default window's images has removed the proguard directory as well. Is their a way to config where xamarin grabs the proguard-android.txt file from? Because then I can just commit the .txt file into my repo to fix it. This is resulting in a run-time crash when using the AirBnb lottie animations in my Xamarin App.
|
@Blue101black a fix for the warning is: #8641 On the original issue above there are links to |
@jonathanpeppers I managed to fix by committing the file to our repo, then as a PowerShell script before the Xamarin Build task I move the file to the directory specified above and that has fixed the issue. Azure DevOps Windows 2022 pipeline. Glad to see a fix was put out. What needs to be done to get that official fix? |
It will be in the next .NET 8 servicing release. |
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS 2022 17.7.4
Description
I am using R8 linking in Release mode as it produces much smaller APK files:
On fresh installations of Visual Studio + the Android SDK, the
tools/proguard/
folder is missing, causing runtime crashes, because too much is being linked out (e.g.android.view.View_IOnClickListenerImplementor
)Even if it is opt-in, I would expect the R8 linking to work, as it is also documented here: https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/D8andR8.md
Steps to Reproduce
C:\Program Files (x86)\Android\android-sdk\tools\proguard
folder)AndroidLinkTool
propertyDid you find any workaround?
It is possible to workaround the problem by copying one of those files into the
C:\Program Files (x86)\Android\android-sdk\tools\proguard
folder and rename it toproguard-android.txt
:https://android.googlesource.com/platform/sdk/+/refs/heads/main/files/proguard-android.txt
https://android.googlesource.com/platform/sdk/+/refs/heads/main/files/proguard-android-optimize.txt
However, this workaround only seems to work when building with .NET7 - when using .NET8, the app crashes regardless
Relevant log output
Possibly related bug report: #3789
The text was updated successfully, but these errors were encountered: