Azure-Samples / azure-ai-vision-sdk

SDK for Microsoft's Azure AI Vision
MIT License
84 stars 50 forks source link

Android/Flutter integration AzureAI #102

Closed AlejandroBM-Dev closed 3 months ago

AlejandroBM-Dev commented 3 months ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ * ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

I encountered an issue while trying to integrate the azure-ai-vision-common and azure-ai-vision-faceanalyzer dependencies into my Kotlin/Android project within a Flutter application. Following the integration steps from the Azure AI Vision SDK - Face Analyzer Sample, I received a build failure related to the inability to resolve these dependencies.

Any log messages given by the failure


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.azure.ai:azure-ai-vision-common:0.16.2-beta.2.
     Required by:
         project :app
      > Could not resolve com.azure.ai:azure-ai-vision-common:0.16.2-beta.2.
         > Could not get resource 'https://jitpack.io/com/azure/ai/azure-ai-vision-common/0.16.2-beta.2/azure-ai-vision-common-0.16.2-beta.2.pom'.
            > Could not GET 'https://jitpack.io/com/azure/ai/azure-ai-vision-common/0.16.2-beta.2/azure-ai-vision-common-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized
      > Could not resolve com.azure.ai:azure-ai-vision-common:0.16.2-beta.2.
         > Could not get resource 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-common/0.16.2-beta.2/azure-ai-vision-common-0.16.2-beta.2.pom'.
            > Could not GET 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-common/0.16.2-beta.2/azure-ai-vision-common-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized
   > Could not resolve com.azure.ai:azure-ai-vision-faceanalyzer:0.16.2-beta.2.
     Required by:
         project :app
      > Could not resolve com.azure.ai:azure-ai-vision-faceanalyzer:0.16.2-beta.2.
         > Could not get resource 'https://jitpack.io/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'.
            > Could not GET 'https://jitpack.io/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized
      > Could not resolve com.azure.ai:azure-ai-vision-faceanalyzer:0.16.2-beta.2.
         > Could not get resource 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'.
            > Could not GET 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
Retrying Gradle Build: #1, wait time: 100ms
[!] Gradle threw an error while downloading artifacts from the network.
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve com.azure.ai:azure-ai-vision-common:0.16.2-beta.2.
     Required by:
         project :app
      > Could not resolve com.azure.ai:azure-ai-vision-common:0.16.2-beta.2.
         > Could not get resource 'https://jitpack.io/com/azure/ai/azure-ai-vision-common/0.16.2-beta.2/azure-ai-vision-common-0.16.2-beta.2.pom'.
            > Could not GET 'https://jitpack.io/com/azure/ai/azure-ai-vision-common/0.16.2-beta.2/azure-ai-vision-common-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized
      > Could not resolve com.azure.ai:azure-ai-vision-common:0.16.2-beta.2.
         > Could not get resource 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-common/0.16.2-beta.2/azure-ai-vision-common-0.16.2-beta.2.pom'.
            > Could not GET 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-common/0.16.2-beta.2/azure-ai-vision-common-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized
   > Could not resolve com.azure.ai:azure-ai-vision-faceanalyzer:0.16.2-beta.2.
     Required by:
         project :app
      > Could not resolve com.azure.ai:azure-ai-vision-faceanalyzer:0.16.2-beta.2.
         > Could not get resource 'https://jitpack.io/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'.
            > Could not GET 'https://jitpack.io/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized
      > Could not resolve com.azure.ai:azure-ai-vision-faceanalyzer:0.16.2-beta.2.
         > Could not get resource 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'.
            > Could not GET 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
[!] Gradle threw an error while downloading artifacts from the network.
Error: Gradle task assembleDebug failed with exit code 1

Expected/desired behavior

For now, I just want to download implementation "com.azure.ai:azure-ai-vision-common:0.16.2-beta.2" and implementation "com.azure.ai:azure-ai-vision-faceanalyzer:0.16.2-beta.2" and integrate them into my project.

OS and Version?

MacOs Sonoma 14.5

Versions

Mention any other details that might be useful

:: FLUTTER:: android/app/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    id 'kotlin-parcelize'
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader("UTF-8") { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
    flutterVersionCode = "1"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
    flutterVersionName = "1.0"
}

android {
    namespace = "com.example.faceliveness_example_new"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.faceliveness_example_new"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        versionCode = flutterVersionCode.toInteger()
        versionName = flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.debug
        }
    }
}

dependencies {
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.compose.material3:material3:1.2.1'

    implementation "com.azure.ai:azure-ai-vision-common:0.16.2-beta.2"
    implementation "com.azure.ai:azure-ai-vision-faceanalyzer:0.16.2-beta.2"
}

flutter {
    source = "../.."
}

:: FLUTTER:: android/build.gradle

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url = URI.create("https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1")
            name = "AzureAIVision"
            credentials {
                username = "a****"
                password = "4lc*****************************************"
            }
        }
    }
}

Thanks! We'll be in touch soon.

diljale commented 3 months ago

Hello, Can you please confirm if you executed these instructions to fetch maven password to pull the artifacts for azure-ai-vision-faceanalyzer ? https://github.com/Azure-Samples/azure-ai-vision-sdk/blob/main/GET_FACE_ARTIFACTS_ACCESS.md

Thanks.

AlejandroBM-Dev commented 3 months ago

Yes @diljale, indeed, the credentials I use are the same ones I have for two other projects that I have as face liveness demos. However, these are in native Android.

diljale commented 3 months ago

It seems that the access token is expired, can you re-generate new one ? Could not GET 'https://pkgs.dev.azure.com/msface/SDK/_packaging/AzureAIVision/maven/v1/com/azure/ai/azure-ai-vision-faceanalyzer/0.16.2-beta.2/azure-ai-vision-faceanalyzer-0.16.2-beta.2.pom'. Received status code 401 from server: Unauthorized

AlejandroBM-Dev commented 3 months ago

I have checked and updated the access token. Everything is now compiling correctly. Thank you! @diljale

I have a question: When creating my APK for distribution, could it be affected by the token's lifetime? For instance, if the face liveness functionality stops working, would I need to create a new token for it to continue functioning?

diljale commented 3 months ago

Hello, The maven access token is needed to compile the application, it is not needed for runtime. So once you create the APK, you don't need access token.

There is different "session" tokens which are needed to for each session during runtime, those are created at runtime to run a Liveness session.

Thanks.

Bestfastfire commented 2 months ago

I create a package to integrate it: https://pub.dev/packages/liveness_azure_flutter