Harsh Shah
Harsh Shah

Reputation: 2332

Android Adding MSAL to the app gives Username must not be null

I am trying to integrate MSAL into an android project to authenticate the user using Microsoft authenticator.

I am following this link

I added this dependency I tried with the actual version 2.1.0 instead of +:

 implementation 'com.microsoft.identity.client:msal:2.+'

With this, I am able to sync the project with Gradle files successfully but while running the project I am facing the following error:

Execution failed for task ':app:compileDebugAidl'.
> Could not resolve all files for configuration ':app:debugCompileClasspath'.
   > Could not resolve com.cerence:com.cerence.tts:1.0.+.
     Required by:
         project :app
      > Failed to list versions for com.cerence:com.cerence.tts.
         > Unable to load Maven meta-data from https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1/com/cerence/com.cerence.tts/maven-metadata.xml.
            > Could not get resource 'https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1/com/cerence/com.cerence.tts/maven-metadata.xml'.
               > Username must not be null!
   > Could not resolve com.cerence:com.cerence:1.3.+.
     Required by:
         project :app
      > Failed to list versions for com.cerence:com.cerence.
         > Unable to load Maven meta-data from https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1/com/cerence/com.cerence/maven-metadata.xml.
            > Could not get resource 'https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1/com/cerence/com.cerence/maven-metadata.xml'.
               > Username must not be null!

I have tried invalid cache and restart, clean the project but none of them worked for me.

If I remove this dependency then it will work as excepted.

How can I solve this issue? Am I missing anything?

Upvotes: 2

Views: 2005

Answers (1)

Paweł Czarnik
Paweł Czarnik

Reputation: 41

It worked for me after I added

maven {
        url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDKPublic/_packaging/Duo-SDKFeed/maven/v1'
    }

on the repositories of the app build.gradle file.

Reference: https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-android#use-msal

So now It looks like that:

repositories {
    google()
    jcenter()
    maven {
        url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
    }
    maven {
        name "vsts-maven-adal-android"
        url "https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1"
        credentials {
            username System.getenv("ENV_VSTS_MVN_ANDROIDADAL_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_ANDROIDADAL_USERNAME") : project.findProperty("vstsUsername")
            password System.getenv("ENV_VSTS_MVN_ANDROIDADAL_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_ANDROIDADAL_ACCESSTOKEN") : project.findProperty("vstsMavenAccessToken")
        }
    }
}

Upvotes: 2

Related Questions