jellyfin / jellyfin-android

Android Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
1.33k stars 223 forks source link

Build from source with local jellyfin-sdk-kotlin jar dependencies. #1394

Closed calwi closed 1 month ago

calwi commented 1 month ago

I am trying to build this project using the sdk libraries build from the jellyfin-sdk-kotlin repo.

I have had some success getting these two repos to work locally,

By updating the build.gradle.kts Module file as: (I've needed to include direct references to ktor from Android Studio to fix another unresolved reference error for io.ktor.http.HttpStatusCode in WebViewUtils.kt)

    val sdkVersion = findProperty("sdk.version")?.toString()
    //implementation(libs.jellyfin.sdk) {
    //    // Change version if desired
    //    when (sdkVersion) {
    //        "local" -> version { strictly(JellyfinSdk.LOCAL) }
    //        "snapshot" -> version { strictly(JellyfinSdk.SNAPSHOT) }
    //        "unstable-snapshot" -> version { strictly(JellyfinSdk.SNAPSHOT_UNSTABLE) }
    //    }
    //}
    implementation("io.ktor:ktor-client-core:2.3.11")
    implementation("io.ktor:ktor-client-cio:2.3.11")
    implementation("io.ktor:ktor-client-websockets:2.3.11")
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar", "*.jar"))))

Which branch of the sdk repo best suits which branch from the jellyfin-android repo? I have tried release-1.4.z as the closest match to the version specified in the libs.version.toml file, but receive an error when trying to build, as follows:

Unresolved reference: context on line 13 of ApiModule.kt

This needs to be uncommented for building android as I understand it.

val apiModule = module {
    // Jellyfin API builder and API client instance
    single {
        createJellyfin {
            context = androidContext()
            clientInfo = ClientInfo(name = Constants.APP_INFO_NAME, version = Constants.APP_INFO_VERSION)
        }
    }
    single { get<Jellyfin>().createApi() }
}

What am I missing to get this to build locally so I can work with the sdk at the same time?

Thanks.

nielsvanvelzen commented 1 month ago

Instructions for using a development version of the SDK are in the kotlin-sdk README. In short you need to publish to your local maven repository and then set sdk.version=local in the gradle.properties file.

You should not add other dependencies at all. No need for modifying the gradle build files.

calwi commented 1 month ago

OK. Thanks Niels. I'm not using a local Maven repository, which I no doubt should be! I will look into it.

calwi commented 1 month ago

All good now. Thanks again!