Repository navigation
[proguard] Preserve ManagedPeer class - #1351
Merged
jonpryor merged 1 commit intoFeb 28, 2018
Merged
Conversation
After XA stopped using Java.Interop built in XAIntegration configuration, we need com.xamarin.java_interop.ManagedPeer to be present in the mono.android.jar file, as managed ManagedPeer type requires it. Thus we need to preserve that class when using proguard. Fixes dotnet#1331
jonpryor
pushed a commit
that referenced
this pull request
Feb 28, 2018
Fixes: #1331 Apps built with ProGuard enabled crash on startup: $ msbuild /t:Install /p:Configuration=Release /p:EnableProguard=true *.csproj # launch the app, and `adb logcat` contains: Unhandled Exception: System.TypeInitializationException: The type initializer for 'Java.Interop.ManagedPeer' threw an exception. ---> System.ArgumentException: Handle must be valid. Parameter name: type at Java.Interop.JniEnvironment+Types.IsInstanceOf (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type) at Android.Runtime.JNIEnv.IsInstanceOf (System.IntPtr obj, System.IntPtr clazz) at Java.Interop.Runtime.IsGCUserPeer (System.IntPtr value) at Java.Interop.Runtime.IsGCUserPeer (Android.Runtime.IJavaObject value) at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) at Android.Runtime.AndroidRuntime.GetExceptionForThrowable (Java.Interop.JniObjectReference& value, Java.Interop.JniObjectReferenceOptions transfer) at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) at Java.Interop.JniType..ctor (System.String classname) at Java.Interop.JniType.GetCachedJniType (Java.Interop.JniType& cachedType, System.String classname) at Java.Interop.JniPeerMembers.get_JniPeerType () at Java.Interop.ManagedPeer..cctor () --- End of inner exception stack trace --- at Java.Interop.JniRuntime..ctor (Java.Interop.JniRuntime+CreationOptions options) at Android.Runtime.AndroidRuntime..ctor (System.IntPtr jnienv, System.IntPtr vm, System.Boolean allocNewObjectSupported, System.IntPtr classLoader, System.IntPtr classLoader_loadClass) at Android.Runtime.JNIEnv.Initialize (Android.Runtime.JnienvInitializeArgs* args) After Xamarin.Android stopped using Java.Interop built against the `XAIntegration*` configuration (7d32ef3), we need to ensure that the type `com.xamarin.java_interop.ManagedPeer` -- found within `mono.android.jar` -- is preserved within the final `classes.dex`, as `Java.Interop.ManagedPeer` requires it. Thus we need to preserve that class when using ProGuard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After XA stopped using Java.Interop built in XAIntegration
configuration, we need com.xamarin.java_interop.ManagedPeer to be
present in the mono.android.jar file, as managed ManagedPeer type
requires it.
Thus we need to preserve that class when using proguard.
Fixes #1331