Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidBundleException: File uses reserved file or directory name 'lib'. #1438

Open
Martmists-GH opened this issue Nov 19, 2023 · 2 comments

Comments

@Martmists-GH
Copy link
Contributor

Martmists-GH commented Nov 19, 2023

When trying to target android with ffmpeg, I get the following error:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':packageDebugBundle'.
	at ...
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.PackageBundleTask$BundleToolWorkAction
	at ...
Caused by: com.android.tools.build.bundletool.model.exceptions.InvalidBundleException: File 'root/lib/arm64-v8a/ffmpeg' uses reserved file or directory name 'lib'.

build.gradle.kts:

import org.jetbrains.compose.ComposeBuildConfig.composeVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("multiplatform")
    id("com.android.application")
    id("org.jetbrains.compose")
    id("com.github.ben-manes.versions")
}

repositories {
    mavenCentral()
    google()
    gradlePluginPortal()
}

kotlin {
    androidTarget()
    jvm("desktop")

    sourceSets {
        commonMain {
            dependencies {
                implementation(compose.ui)
                implementation(compose.animation)
                implementation(compose.foundation)
                implementation(compose.material3)
                implementation(compose.runtime)
                implementation(compose.uiTooling) {
                    exclude("org.jetbrains.compose.material", "material")
                }

                implementation("com.github.skydoves:orbital:${Versions.orbital}")

                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}")

                implementation("io.ktor:ktor-client-core:${Versions.ktor}")
                implementation("io.ktor:ktor-serialization-kotlinx-json:${Versions.ktor}")
                implementation("org.bytedeco:ffmpeg:${Versions.ffmpeg}")
            }
        }

        androidMain {
            dependencies {
                implementation("androidx.activity:activity-compose:${Versions.activityCompose}")

                // TODO: Figure out how to do a split APK with this?
                runtimeOnly("org.bytedeco:ffmpeg:${Versions.ffmpeg}:android-arm")
                runtimeOnly("org.bytedeco:ffmpeg:${Versions.ffmpeg}:android-arm64")
                runtimeOnly("org.bytedeco:ffmpeg:${Versions.ffmpeg}:android-x86")
                runtimeOnly("org.bytedeco:ffmpeg:${Versions.ffmpeg}:android-x86_64")
            }
        }

        val desktopMain by getting {
            dependencies {
                runtimeOnly(compose.desktop.currentOs)

                when (compose.desktop.currentOs) {
                    "org.jetbrains.compose.desktop:desktop-jvm-linux-x64:${Versions.compose}" -> {
                        runtimeOnly("org.bytedeco:ffmpeg:${Versions.ffmpeg}:linux-x86_64")
                    }
                    "org.jetbrains.compose.desktop:desktop-jvm-macos-x64:${Versions.compose}" -> {
                        runtimeOnly("org.bytedeco:ffmpeg:${Versions.ffmpeg}:macosx-x86_64")
                    }
                    "org.jetbrains.compose.desktop:desktop-jvm-windows-x64:${Versions.compose}" -> {
                        runtimeOnly("org.bytedeco:ffmpeg:${Versions.ffmpeg}:windows-x86_64")
                    }
                }
            }
        }
    }
}

android {
    compileSdk = 34
    namespace = "org.mewsic.app"
    ndkVersion = "21.4.7075529"

    defaultConfig {
        applicationId = "org.mewsic.app"
        minSdk = 23
        targetSdk = 34
        versionCode = 0x000001
        versionName = versionCode!!.toString(16).padStart(6, '0').chunked(2).joinToString(".")
    }

    signingConfigs {
        create("release") {
            storeFile = file(System.getenv("KEYSTORE_FILE") ?: "keystore.jks")
            storePassword = System.getenv("KEYSTORE_PASSWORD")
            keyAlias = System.getenv("KEY_ALIAS")
            keyPassword = System.getenv("KEY_PASSWORD")
        }
    }

    lint {
        disable += "AccidentalOctal"
    }

    compileOptions {
        sourceCompatibility = Versions.jvmTarget
        targetCompatibility = Versions.jvmTarget
    }

    composeOptions {
        kotlinCompilerExtensionVersion = composeVersion
    }
}

compose.desktop {
    application {
        mainClass = "org.mewsic.app.MainKt"
    }
}

tasks {
    withType<JavaCompile> {
        sourceCompatibility = Versions.jvmTarget.toString()
        targetCompatibility = Versions.jvmTarget.toString()
    }

    withType<KotlinCompile> {
        kotlinOptions {
            jvmTarget = Versions.jvmTarget.toString()
        }
    }
}
@saudet
Copy link
Member

saudet commented Nov 20, 2023

Please follow the instructions here:
https://github.com/bytedeco/gradle-javacpp#the-platform-plugin

@Martmists-GH
Copy link
Contributor Author

Unfortunately that solution does not cover kotlin build scripts. Additionally, the kotlin multiplatform plugin is unable to use custom configurations (such as javacpp) even if they are defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants