OneUIProject / oneui-design

Samsung's One UI design components for Android apps.
MIT License
156 stars 18 forks source link

Does this library support kotlin? #11

Closed thewolfprod closed 1 year ago

thewolfprod commented 1 year ago

I would like to create an app with this library - the problem is that I switched from Java to Kotlin and the question is whether this library can work with Kotlin? I ask because in MainActivity.java (which is very simple)

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

}

I get an error during Project Rebuild:

public final class MainActivity extends androidx.appcompat.app.AppCompatActivity {
             ^
  class file for androidx.core.content.OnConfigurationChangedProvider not found

and also errors about duplicated classes from:

AndroidManifest.xml:

android:theme="@style/OneUITheme"

build.gradle:

// Exclude Google AndroidX.
configurations.all {
    exclude group: 'androidx.appcompat', module: 'appcompat'
    exclude group: 'androidx.core', module: 'core'
    exclude group: 'androidx.customview', module: 'customview'
    exclude group: 'androidx.fragment', module: 'fragment'
    exclude group: 'androidx.viewpager', module: 'viewpager'
}

android {
    namespace 'tw.app.sonote'
    compileSdk 33

    defaultConfig {
        applicationId "tw.app.sonote"
        minSdk 23
        targetSdk 33
        versionCode 1
        versionName "1.0"

        vectorDrawables.useSupportLibrary = true
    }

    buildFeatures {
        buildConfig true
        viewBinding true
    }
}

dependencies {
    // OneUI
    implementation 'io.github.oneuiproject.sesl:appcompat:1.3.0'
    implementation 'io.github.oneuiproject.sesl:apppickerview:1.0.0'
    implementation 'io.github.oneuiproject.sesl:material:1.4.0'
    implementation 'io.github.oneuiproject.sesl:indexscroll:1.0.3'
    implementation 'io.github.oneuiproject.sesl:picker-basic:1.1.0'
    implementation 'io.github.oneuiproject.sesl:picker-color:1.0.1'
    implementation 'io.github.oneuiproject.sesl:preference:1.1.0'
    implementation 'io.github.oneuiproject.sesl:recyclerview:1.3.0'
    implementation 'io.github.oneuiproject.sesl:swiperefreshlayout:1.0.0'
    implementation 'io.github.oneuiproject:design:1.2.1'
    implementation 'io.github.oneuiproject:icons:1.0.1'

    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

    // Airbnb
    implementation 'com.airbnb.android:lottie:5.2.0'

    // Dagger - Hilt
    implementation "com.google.dagger:hilt-android:2.44"
    kapt "com.google.dagger:hilt-android-compiler:2.44"
    kapt "androidx.hilt:hilt-compiler:1.0.0"

    // There was more libs but i deleted most of them just to find potential cause
}
salvogiangri commented 1 year ago

This error happens because Samsung libraries are based on a very old version of Google Android Jetpack ones. Try to downgrade the modules you've set in your build.gradle file

Yanndroid commented 1 year ago

I've also made NotiNotes in kotlin and the newer verions of ktx don't work with the library. Try using:

implementation 'androidx.core:core-ktx:1.6.0'
implementation("androidx.annotation:annotation-experimental") { version { strictly("1.1.0") } }

(I'm not sure if the second one is actually needed or if it was a fix to something else)

thewolfprod commented 1 year ago

It works 😃 Thanks for help guys