androidandroid-studiobuild.gradleintuneintunemam

Android studio produces a release apk which is not MAM-handled but my debug-apk is MAM-handled


I am trying to implement Intune SDK to an existing LOB-app and Azure seems to accept my debug-apk as MAM-handled but not my release-apk. I am not super familiar with Android studio but from what I can tell my build.gradle looks correct. I also consider that perhaps the code I added perhaps needs to be written differently in order for the release apk to work but I wanted to rule out the simplest errors if possible first.

my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.microsoft.intune.mam'

def versionMajor = 22
def versionMinor = 1
def versionPatch = 999
def versionBuild = 7

android {
    signingConfigs {
        debug {
            storeFile file('**.jks')
            storePassword '****'
            keyAlias '***'
            keyPassword '****'
        }
        config {
            keyAlias '****'
            keyPassword '****'
            storeFile file('****.jks')
            storePassword '****'
        }
    }
    compileSdkVersion 31
    defaultConfig {
        applicationId "a.client"
        minSdkVersion 18
        targetSdkVersion 31
        multiDexEnabled true
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
        versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
        versionName "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"
        manifestPlaceholders = [
                'appAuthRedirectScheme': 'com.onmicrosoft.demo.exampleapp'
        ]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.config
        }
    }
    lintOptions {
        checkReleaseBuilds false
    }
    productFlavors {
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation files('libs/IntermecDataCollection.jar')
    implementation project(':HoneywellDataCollection')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'org.apache.commons:commons-text:1.6'
    implementation 'de.proglove:connect-sdk:1.5.0'
    implementation 'net.openid:appauth:0.8.1'
    implementation 'com.squareup.okio:okio:2.10.0'

    // Include the MAM SDK
    implementation files('libs/Microsoft.Intune.MAM.SDK.aar')

    // Include MSAL
    implementation 'com.microsoft.identity.client:msal:2.0.8'
}

I have tried adding a seperate buildType with debuggable true and set debuggable to false in the release buildType. I also tried changing the active build variant and rebuild and then build signed apk.


Solution

  • Seems this could be some bug in the AGP versions 4.2 and above. https://github.com/msintuneappsdk/ms-intune-app-sdk-android/issues/117

    Adding this to the gradle.properties seemed to help. android.enableResourceOptimizations=false