Hi I would like to know if anyone has managed to g...
# arrow
t
Hi I would like to know if anyone has managed to get arrow optics to work (e.g. generate code) in an Android studio project? i have been trying to achieve this for the last 4 days and failed.
my andriod studio version is
Android Studio Bumblebee | 2021.1.1
Build #AI-211.7628.21.2111.8092744, built on January 19, 2022
Runtime version: 11.0.11+0-b60-7590822 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 12
Registry: external.system.auto.import.disabled=true, <http://debugger.watches.in|debugger.watches.in>.variables=false
Non-Bundled Plugins: org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40)
my project gradle is
Copy code
buildscript {
    ext.kotlin_version = "1.6.10"
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
        maven { url '<https://jitpack.io>' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
and my android sub module gradle file (snippets)
Copy code
plugins {
    id "com.android.library"
    id "com.google.devtools.ksp" version "1.6.10-1.0.2"
    id "kotlin-android"
    id "kotlin-kapt"
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.20'
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdkVersion 32

    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 32

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "<http://consumer-rules.pro|consumer-rules.pro>"
    }
Copy code
compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
        freeCompilerArgs += [
                "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
                "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
                "-Xopt-in=kotlinx.coroutines.InternalCoroutinesApi",
                "-Xopt-in=kotlinx.coroutines.FlowPreview",
                "-Xopt-in=kotlinx.coroutines.ObsoleteCoroutinesApi"]
    }
}
Copy code
dependencies {

    api(platform("io.arrow-kt:arrow-stack:1.0.6-alpha.1"))
    api("io.arrow-kt:arrow-core")
    api("io.arrow-kt:arrow-fx-coroutines")
    api("io.arrow-kt:arrow-fx-stm")
    api("io.arrow-kt:arrow-optics")

    api "com.google.devtools.ksp:symbol-processing-api:1.6.10-1.0.2"
    ksp "io.arrow-kt:arrow-optics-ksp-plugin:1.0.6-alpha.1"
the code i am using to test optics code generation is directly from tht optics docs as shown here
Copy code
@optics
data class Street(val number: Int, val name: String) {
    companion object
}

@optics
data class Address(val city: String, val street: Street) {
    companion object
}

@optics
data class Company(val name: String, val address: Address) {
    companion object
}

@optics
data class Employee(val name: String, val company: Company?) {
    companion object
}
what am i doing wrong? or missing?
I found that by downgrading my sub module gradle arrow deps to these shown below the generation works for optics in android
Copy code
implementation(platform("io.arrow-kt:arrow-stack:1.0.3-alpha.1"))
api("io.arrow-kt:arrow-core")
api("io.arrow-kt:arrow-fx-coroutines")
api("io.arrow-kt:arrow-fx-stm")
ksp 'io.arrow-kt:arrow-optics:1.0.3-alpha.1'
api 'io.arrow-kt:arrow-optics'

api "com.google.devtools.ksp:symbol-processing-api:1.6.10-1.0.2"
ksp "io.arrow-kt:arrow-optics-ksp-plugin:1.0.3-alpha.1"
🙌 1
@Dutch
🙌 1
a
I’ve been investigating and came to the same conclusion, the problem was in the version
arrow-optics-ksp-plugin:1.0.3-alpha.2
would work too
we need to fix our publishing pipeline because wrong artifacts like
1.0.6
have been published 😕
😄 1
👍 1
t
thanks for the insight, i will give
1.0.3-alpha.2
a "run out" 😄 arrow is worth the effort 😉