Android setup
Five steps, in order. The Gradle plugin rewrites bytecode across your whole app, which is why it belongs in your app module and why a previously working third-party library is the first thing to suspect if something breaks after this.
The MAM Gradle plugin belongs in your app module, never in this library. Applied to the library it rewrites only the library, builds cleanly, and protects nothing.
-
Apply the MAM Gradle plugin to your app module — not to this library.
// android/build.gradlebuildscript {repositories { mavenCentral() }dependencies {classpath "org.javassist:javassist:3.29.2-GA"classpath files("../node_modules/react-native-intune/vendor/android/GradlePlugin/com.microsoft.intune.mam.build.jar")}}// android/app/build.gradleapply plugin: 'com.microsoft.intune.mam'intunemam {report = true // HTML report → app/build/outputs/intune/<variant>/logsverify = true // catches plugin-induced runtime failuresincremental = true}The plugin rewrites bytecode across your whole app and all its dependencies. Applying it inside this library instead would build successfully and protect nothing.
-
Application class. If you subclass
android.app.Application, the plugin transforms it for you. If you don't, set it explicitly:<application android:name="com.microsoft.intune.mam.client.app.MAMApplication" ... > -
Register the auth callback from your Application class. This must happen in
onMAMCreate, before JavaScript exists — so it cannot be done fromconfigure():class MainApplication : MAMApplication(), ReactApplication {override fun onMAMCreate() {super.onMAMCreate()RNIntune.registerAuthCallback(this)}} -
Broker queries and redirect activity. Without the
<queries>block, Android 11+ prevents your app from even detecting the broker, and MSAL silently falls back to a browser instead — brokered auth then "just doesn't work" with no error:<queries><package android:name="com.azure.authenticator" /><package android:name="com.microsoft.windowsintune.companyportal" /></queries><activity android:name="com.microsoft.identity.client.BrowserTabActivity" android:exported="true"><intent-filter><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="msauth"android:host="${applicationId}"android:path="/YOUR_URL_ENCODED_SIGNATURE_HASH" /></intent-filter></activity>