smileidentity / flutter

The Official Smile ID Flutter SDK
https://docs.smileidentity.com/integration-options/mobile
MIT License
2 stars 10 forks source link

Unable to run application on android #61

Open adtoba opened 5 months ago

adtoba commented 5 months ago

I have integrated the package into my application and it works well on ios.

However i have not been able to get it to work for android. I get this error whenever i try to run the app.

java.lang.Error: Something went wrong while checking for version compatibility between the Compose Compiler and the Kotlin Compiler.  It is possible that the versions are incompatible.  Please verify your kotlin version  and consult the Compose-Kotlin compatibility map located at https://developer.android.com/jetpack/androidx/releases/compose-kotlin
    at androidx.compose.compiler.plugins.kotlin.ComposePluginRegistrar$Companion.checkCompilerVersion(ComposePlugin.kt:286)
    at androidx.compose.compiler.plugins.kotlin.ComposePluginRegistrar.registerProjectComponents(ComposePlugin.kt:211)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:655)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:169)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.configureProjectEnvironment(KotlinCoreEnvironment.kt:566)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:199)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:108)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:445)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:191)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:142)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:94)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:477)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:127)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:366)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:311)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.rebuild(IncrementalCompilerRunner.kt:110)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:200)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:75)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1739)
    at jdk.internal.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
    at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.common.messages.MessageCollector.report$default(org.jetbrains.kotlin.cli.common.messages.MessageCollector, org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity, java.lang.String, org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation, int, java.lang.Object)'
    at androidx.compose.compiler.plugins.kotlin.ComposePluginRegistrar$Companion.checkCompilerVersion(ComposePlugin.kt:264)
    ... 39 more
vanshg commented 5 months ago

Very likely that you need to update either your Kotlin version or SDK version.

What version of the SDK are you using? What are the Gradle and Kotlin versions?

adtoba commented 5 months ago

Kotlin version: 1.9.23 smile_id: ^10.0.8

I have tried a lot of things to get it to work but it didn't.

Very likely that you need to update either your Kotlin version or SDK version.

What version of the SDK are you using?

What are the Gradle and Kotlin versions?

vanshg commented 5 months ago

Please try Kotlin 1.9.22. Jetpack Compose only just added support for Kotlin 1.9.23 last week in Compiler version 1.5.11 (https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.11)

We will support Kotlin 1.9.23 in the next release

adtoba commented 5 months ago

I just tried it.

This is the new error i am getting.

This version (1.5.3) of the Compose Compiler requires Kotlin version 1.9.10 but you appear to be using Kotlin version 1.9.22 which is not known to be compatible. Please consult the Compose-Kotlin compatibility map located at https://developer.android.com/jetpack/androidx/releases/compose-kotlin to choose a compatible version pair (or suppressKotlinVersionCompatibilityCheck but don't say I didn't warn you!).

This is my app build.gradle file

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

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

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

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

apply plugin: 'com.android.application'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
//apply plugin: 'com.smileidentity.smile-id-android'

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 34

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        checkReleaseBuilds false
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.greach.greachapp"
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
        manifestPlaceholders += [
                'appAuthRedirectScheme': 'com.greach.greachapp'
        ]
        ndk { 
            abiFilters 'armeabi', 'x86', 'armeabi-v7a', 'arm64-v8a', 'x86_64', 'mips', 'mips64'
        }
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

    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
            signingConfig signingConfigs.release
        }
    }

    packagingOptions {
        exclude 'META-INF/androidx.*'
        exclude 'androidx.*'
        exclude 'META-INF/DEPENDENCIES'
    }
}

flutter {
    source '../..'
}

dependencies { 
//    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//    implementation 'com.smileidentity:smile-id-ui:0.1.45-SNAPSHOT'
//    implementation 'com.smileidentity:smile-id-sdk:7.2.49-SNAPSHOT'
//    implementation 'com.android.support:multidex:1.0.3'
//  implementation 'com.smileidentity:smile-id-ui:<latest_version>'
// implementation 'com.smileidentity:smile-id-sdk:<latest_version>'
// implementation 'com.smileidentity:netjava:<latest_version>'// currently (0.0.8)
}

This is my android build.gradle file

buildscript {
    //ext.kotlin_version = '1.6.10'
    ext.kotlin_version = '1.9.22'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
        // START: FlutterFire Configuration
        classpath 'com.google.gms:google-services:4.4.0'
        // END: FlutterFire Configuration
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//        classpath group: 'com.smileidentity', name: 'smile-id-android', version: '1.0.1'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}
vanshg commented 5 months ago

We ship 1.5.8 with the latest version of the SDK, so it's possible some other library is overriding it to 1.5.3.

Can you try setting it explicitly in your app build.gradle in the android block?

android {
    // your existing gradle config
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion = "1.5.10"
    }
    // your existing gradle config
}
adtoba commented 5 months ago

We ship 1.5.8 with the latest version of the SDK, so it's possible some other library is overriding it to 1.5.3.

Can you try setting it explicitly in your app build.gradle in the android block?


android {

    // your existing gradle config

    buildFeatures {

        compose true

    }

    composeOptions {

        kotlinCompilerExtensionVersion compose_version

        kotlinCompilerVersion = "1.5.10"

    }

    // your existing gradle config

}

Yes this worked. I was able to build after i did this.

vanshg commented 5 months ago

Great! We've also updated our Flutter docs to hopefully make this setup process a bit clearer for others: https://docs.usesmileid.com/integration-options/mobile/flutter-v10/getting-started#android-specific-setup

akwa-peter commented 3 weeks ago

We ship 1.5.8 with the latest version of the SDK, so it's possible some other library is overriding it to 1.5.3.

Can you try setting it explicitly in your app build.gradle in the android block?

android {
    // your existing gradle config
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion = "1.5.10"
    }
    // your existing gradle config
}

Did this but the error still persist, please is there any other way to go about this? I am on the latest version of smile_id ^10.1.7 but still get the error below

e: This version (1.5.3) of the Compose Compiler requires Kotlin version 1.9.10 but you appear to be using Kotlin version 1.9.22 which is not known to be compatible. Please consult the Compose-Kotlin compatibility map located at https://developer.android.com/jetpack/androidx/releases/compose-kotlin to choose a compatible version pair (or suppressKotlinVersionCompatibilityCheck but don't say I didn't warn you!).

FAILURE: Build failed with an exception.

BUILD FAILED in 25s Error: Gradle task assembleDebug failed with exit code 1

jumaallan commented 3 weeks ago

@akwa-peter Can you share the Gradle and Kotlin versions you are using? Also, have you specified a kotlinCompilerExtensionVersion?

akwa-peter commented 3 weeks ago

@akwa-peter Can you share the Gradle and Kotlin versions you are using? Also, have you specified a kotlinCompilerExtensionVersion?

Yes see my plugin kotlin version plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.1" apply false id "org.jetbrains.kotlin.android" version "1.9.22" apply false id "com.google.gms.google-services" version "4.4.1" apply false //4.3.15 }

And here is my gradle version distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip

Also see my set kotlin compiler version `buildFeatures { compose true } composeOptions { kotlinCompilerExtensionVersion "1.9.22"

    kotlinCompilerVersion = "1.5.10"
}`
jumaallan commented 2 weeks ago

@akwa-peter

You are using Kotlin 1.9.22 and our sdk uses 1.9.10. We use the kotlin compiler version 1.5.3 which is compatible with version 1.9.10

to fix your build issue, you need to specify your config like this

buildFeatures.compose = true
composeOptions {
   kotlinCompilerExtensionVersion = "1.5.10"
}

this is the compatibility mapping - https://developer.android.com/jetpack/androidx/releases/compose-kotlin

jumaallan commented 2 weeks ago

You shared this in your snippet

composeOptions {
kotlinCompilerExtensionVersion "1.9.22"

    kotlinCompilerVersion = "1.5.10"
}`

replace this with the code I shared