ajalt / colormath

Multiplatform Kotlin color conversion and manipulation
https://ajalt.github.io/colormath/
MIT License
308 stars 21 forks source link

Unable to use Jetpack Compose extension #32

Closed sivansundar closed 1 year ago

sivansundar commented 1 year ago

Hello @ajalt. Came across this interesting project of yours and this might just help me with my requirement.

I am trying to use the Jetpack Compose extension to generate a Color() object for compose by feeding in a hex value. I was able to pull the colormath library into my multiplatform project but while importing the jetpack compose extension, gradle throws an error saying :

Could not resolve com.github.ajalt.colormath.extensions:colormath-ext-jetpack-compose:3.2.0. Possible solution:

This is my build.gradle.kts file :

repositories {
     mavenCentral()
     maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
 implementation("com.github.ajalt.colormath:colormath:3.2.1")
 implementation("com.github.ajalt.colormath.extensions:colormath-ext-jetpack-compose:3.2.0")

Am I missing anything? Btw, this is my first attempt to play around with multiplatform so excuse me if I didn't know the obvious :)

ajalt commented 1 year ago

It seems to work for me. In Android Studio, I created a new project with a Compose Activity, then added the colormath dependencies. I didn't need to change any repository settings.

The artifacts are available on Maven Central: https://repo1.maven.org/maven2/com/github/ajalt/colormath/extensions/colormath-ext-jetpack-compose/3.2.1/

If it helps here's the entire app/build.gradle file, but it's just the one generated by Android Studio:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.example.myapplication'
    compileSdk 32

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 31
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.1.1'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {
    implementation("com.github.ajalt.colormath:colormath:3.2.1")
    implementation("com.github.ajalt.colormath.extensions:colormath-ext-jetpack-compose:3.2.1")

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'
    implementation "androidx.compose.ui:ui:$compose_ui_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
    implementation 'androidx.compose.material:material:1.1.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
}