Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
NOTICE

This project includes a compiled version of the TagLib library for Android.

Built from:
- Android wrapper: https://github.com/Kyant0/taglib (Apache License 2.0)
- Core library: https://github.com/taglib/taglib (LGPL 2.1 / MPL 1.1)

Some build configurations (e.g. Gradle, CMake, NDK) have been modified for compatibility.

You are free to use, link, and distribute this binary under the respective open-source licenses.
Refer to LICENSE files or the links below for full license details:

- Apache License 2.0: https://www.apache.org/licenses/LICENSE-2.0
- LGPL 2.1: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
- MPL 1.1: https://www.mozilla.org/MPL/1.1/

No changes have been made to the core TagLib source code.
102 changes: 92 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,102 @@
# TagLib
# TagLib for Android

An Android library which can read and write tags of audio files, using [TagLib](https://github.com/taglib/taglib).
An Android native library for reading and writing metadata tags in audio files — powered by TagLib.

## Add to project
# Add to Project

Download the [aar](https://github.com/Kyant0/taglib/releases) and copy it to your module's `libs` directory.
1. Download the prebuilt .aar from the build/outputs/aar/ directory after building the project manually.

```kotlin

2. Place the `.aar` file in your app module's `libs/ directory (e.g., yourproject/app/libs/)`


3. Then add the dependency in your build.gradle file based on your build script:


```Groovy DSL
implementation files("libs/taglib-release.aar")
```


```Kotlin DSL
implementation(files("libs/taglib-release.aar"))
```

## Functions

* Get and save audio properties and all metadata of audio files.
* Get and save cover art of audio files, support multiple cover arts.

## Example
4. Make sure to declare the flatDir repository in your build.gradle:


```Groovy DSL
repositories { flatDir { dirs 'libs' } }
```


```Kotlin DSL
repositories { flatDir { dirs("libs") } }
```


# Without DSL (direct manual import in IDE):

• Open your module settings

• Click "+" → "Import .JAR/.AAR Package"

• Select the .aar from libs/

• Confirm and sync project




# Features

Read & write audio metadata (title, artist, album, year, etc.)

Get & save cover art (supports multiple embedded artworks)

Read audio file properties (bitrate, duration, sample rate, etc.)


# Example Usage

See `Tests.kt` for usage examples.

# Build from Source

To build the library manually:

1. Clone the repository


2. Make sure you have `Android NDK (tested with r29+)` and `CMake (4.0.2)` installed


3. Run the following Gradle command:

```Bash
./gradlew :library:assembleRelease
```

or

```Bash
./gradlew assembleRelease
```



The resulting AAR will be located at: `.../build/outputs/aar/taglib-release.aar`

You can now include this AAR in your app's libs/ directory as shown above.

# Based on

TagLib `(https://taglib.org/)` — C++ library for audio metadata. This version is wrapped for Android with CMake + NDK + JNI. `Forked and modified from kyant0/taglib (Apache License 2.0).`

# Note:

This repository is a fork of `kyant0/taglib`, originally licensed under `Apache License 2.0`.

See [Tests.kt](/src/androidTest/kotlin/Tests.kt).
This fork `maintains` the Android integration from the original project, while providing additional build configurations, usage documentation, and packaged artifacts (.aar) for easier adoption in Android projects.
63 changes: 50 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,42 +1,79 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
id("maven-publish")
}

android {
namespace = "com.kyant.taglib"
compileSdk = 36
buildToolsVersion = "36.0.0"
ndkVersion = "29.0.13599879"
compileSdk = 34
buildToolsVersion = "34.0.0"
ndkVersion = "29.0.13846066"

defaultConfig {
minSdk = 23
consumerProguardFiles("consumer-rules.pro")
ndk {
abiFilters += arrayOf("arm64-v8a", "armeabi-v7a", "x86_64", "x86")
abiFilters += listOf("arm64-v8a", "armeabi-v7a")
}

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

externalNativeBuild {
cmake {
path("src/main/cpp/CMakeLists.txt")
path = file("src/main/cpp/CMakeLists.txt")
version = "4.0.2"
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_18
targetCompatibility = JavaVersion.VERSION_18
}

kotlinOptions {
apiVersion = "1.8"
languageVersion = "1.8"
jvmTarget = "18"
}

lint {
checkReleaseBuilds = false
}
}

kotlin {
explicitApi()
}

dependencies {
androidTestImplementation(libs.androidx.runner)
androidTestImplementation(libs.androidx.rules)
}

afterEvaluate {
publishing {
publications {
create<MavenPublication>("release") {
from(components["release"])

groupId = "com.github.evnzy"
artifactId = "taglib-native"
version = "1.0.3"
}
}
}
} targetCompatibility = JavaVersion.VERSION_21
}
kotlin {
compilerOptions {
Expand Down
10 changes: 7 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
kotlin.code.style=official
lin.code.style=official
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.parallel=false
org.gradle.workers.max=2
org.gradle.jvmargs=-Xmx1024M -Dfile.encoding=UTF-8
org.gradle.configuration-cache=true
#Android
android.useAndroidX=true
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
android.experimental.dependency.excludeLibraryComponentsFromConstraints=true
org.gradle.configureondemand=true
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
agp = "8.11.0"
kotlin = "2.2.0"
agp = "8.4.1"
kotlin = "1.9.23"
rules = "1.6.1"
runner = "1.6.2"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
11 changes: 11 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
jdk:
- 17

install:
- ./gradle





Add jitpack.yml for Java 17 compatibility
4 changes: 4 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
# header note.
#Fri Nov 10 13:16:04 CST 2023
sdk.dir=C\:\\Users\\Kyant\\AppData\\Local\\Android\\Sdk

#sdk.dir=/data/data/com.itsaky.androidide/files/home/android-sdk

#sdk.dir=/data/data/com.termux/files/home/android-sdk
4 changes: 4 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ pluginManagement {
gradlePluginPortal()
}
}

enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
repositories {
Expand Down
13 changes: 13 additions & 0 deletions src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
target_link_libraries(${CMAKE_PROJECT_NAME}
android
tag)
add_library(${CMAKE_PROJECT_NAME} SHARED
taglib.cpp
fileref_ext.cpp)

add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_OBJCOPY}
--remove-section .comment
--remove-section .note
--strip-debug $<TARGET_FILE:${CMAKE_PROJECT_NAME}>)

target_link_libraries(${CMAKE_PROJECT_NAME}
android
tag)