-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Tasks] Sample for Microsoft Intune is failing - System.NullReferenceException at IntuneMAMSampleAndroid.EntryActivity.OnCreate #721
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
Merged
Merged
Conversation
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
Contributor
|
Is it possible/practical to add a unit test for this? Would doing a (design-time build, Resource.designer.cs content check, normal build, content check) work? |
Contributor
Author
|
I can probably put a test together. Or expand the existing design time test |
…- System.NullReferenceException at IntuneMAMSampleAndroid.EntryActivity.OnCreate Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=57279 The DesignTimeBuilds are causing a bit of a problem. Because they are being run as soon as the project is loaded, it does result in the `_UpdateAndroidResGen` thinking that the resources are up to date. This results in the following find . -iname R.java | xargs grep EntryActivityStartButton ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/com/microsoft/intune/mam/R.java: public static final int EntryActivityStartButton=0x7f070000; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/microsoftintunemamsampleandroid/microsoftintunemamsampleandroid/R.java: public static final int EntryActivityStartButton=0x7f070000; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/src/android/support/v4/R.java: public static int EntryActivityStartButton=0x7f0c0050; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/src/android/support/v7/appcompat/R.java: public static int EntryActivityStartButton=0x7f0c0050; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/src/com/microsoft/intune/mam/R.java: public static final int EntryActivityStartButton=0x7f0c0050; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/src/microsoftintunemamsampleandroid/microsoftintunemamsampleandroid/R.java: public static final int EntryActivityStartButton=0x7f0c0050; Note that the `EntryActivityStartButton` value is different, they should all be the same. This is because the `_UpdateAndroidResGen` target was NOT running. Fortunately commit 1cd582e adds `$(DesignTimeBuild)` to the list of properties in the `@(_PropertyCacheItems)` ItemGroup. So we can now use the `$(_AndroidBuildPropertiesCache)` property to detect when we are moving from a DesignTimeBuild into a normal Build. This means the resources are then generated correctly.
jonpryor
pushed a commit
that referenced
this pull request
Aug 10, 2017
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=57279 The DesignTimeBuilds are causing a bit of a problem. Because they are being run as soon as the project is loaded, it resulted in `_UpdateAndroidResGen` thinking that the resources are up to date. This results in the following $ find . -iname R.java | xargs grep EntryActivityStartButton ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/com/microsoft/intune/mam/R.java: public static final int EntryActivityStartButton=0x7f070000; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/microsoftintunemamsampleandroid/microsoftintunemamsampleandroid/R.java: public static final int EntryActivityStartButton=0x7f070000; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/src/android/support/v4/R.java: public static int EntryActivityStartButton=0x7f0c0050; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/src/android/support/v7/appcompat/R.java: public static int EntryActivityStartButton=0x7f0c0050; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/src/com/microsoft/intune/mam/R.java: public static final int EntryActivityStartButton=0x7f0c0050; ./IntuneMAMSampleAndroid/obj/AnyCPU/Debug/android/src/microsoftintunemamsampleandroid/microsoftintunemamsampleandroid/R.java: public static final int EntryActivityStartButton=0x7f0c0050; Note that the `EntryActivityStartButton` value is different, they should all be the same. This is because the `_UpdateAndroidResGen` target was NOT running. As a result of this, when the app runs a `NullReferenceException` could be thrown when the wrong resource id value is inadvertently used with e.g. `Activity.FindViewById<T>(int)`: // C# var button = FindViewById<Button>(Resource.Id.button); // `button` is actually null, as `Resource.id.button` is wrong button.Click += delegate { /* ... */ }; // throws `NullReferenceException`, as `button` is null Fortunately commit 1cd582e adds `$(DesignTimeBuild)` to the list of properties in the `@(_PropertyCacheItems)` ItemGroup. So we can now use the `$(_AndroidBuildPropertiesCache)` property to detect when we are moving from a DesignTimeBuild into a normal Build. This means the resources are then generated correctly.
jonpryor
pushed a commit
that referenced
this pull request
Oct 20, 2020
Fixes: dotnet/java-interop#461 Fixes: dotnet/java-interop#682 Fixes: dotnet/java-interop#717 Fixes: dotnet/java-interop#719 Fixes: dotnet/java-interop#728 Changes: dotnet/java-interop@ac914ce...b991bb8 * dotnet/java-interop@b991bb86: [generator] Revert change to use auto-properties in EventArgs classes (#736) * dotnet/java-interop@ee50d89b: Bump to xamarin/xamarin-android-tools/master@f2af06f2 (#733) * dotnet/java-interop@a0b895c1: [build] Suppress NuGet warnings (#730) * dotnet/java-interop@8b1b0507: [generator] Fix parsing of complex generic types (#729) * dotnet/java-interop@ee7afeed: [generator] Prevent generating duplicate EventArgs classes (#726) * dotnet/java-interop@1f21f38c: [generator] Use GC.KeepAlive for reference type method parameters. (#725) * dotnet/java-interop@5136ef98: [Xamarin.Android.Tools.Bytecode] Hide Kotlin nested types inside (#723) * dotnet/java-interop@53d60513: [jnimarshalmethod-gen] Fix registration on Windows (#721) * dotnet/java-interop@5a834d42: [jnimarshalmethod-gen] Avoid creating AppDomains (#720) * dotnet/java-interop@a76edb8c: [Xamarin.Android.Tools.ApiXmlAdjuster] Find app.android.IntentService (#718) * dotnet/java-interop@6cde0877: [Java.Interop] Emit a reference assembly for Java.Interop.dll (#716) * dotnet/java-interop@b858dc59: [generator] Provide line/col numbers for api.xml warnings (#715) * dotnet/java-interop@9be92a04: [ci] Don't kick off CI for documentation only changes. (#712) * dotnet/java-interop@03c22722: [jnimarshalmethod-gen] Fix type resolution crash (#706)
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.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=57279
The DesignTimeBuilds are causing a bit of a problem.
Because they are being run as soon as the project is loaded, it
does result in the
_UpdateAndroidResGenthinking that theresources are up to date. This results in the following
Note that the
EntryActivityStartButtonvalue is different, they should allbe the same. This is because the
_UpdateAndroidResGentargetwas NOT running.
Fortunately commit 1cd582e adds
$(DesignTimeBuild)to the listof properties in the
@(_PropertyCacheItems)ItemGroup. So we cannow use the
$(_AndroidBuildPropertiesCache)property to detectwhen we are moving from a DesignTimeBuild into a normal Build.
This means the resources are then generated correctly.