Skip to main content

Installation (Android)

The Kotlin for Android version of alphaTab can be used to render music notation in native Android Apps.

Grab your Copy​

Maven Central​

We provide Maven packages based on the latest development version via Maven Central and Sonatype OSSRH.

Install packages like usual by adding it as a dependency to your build System

repositories {
google()
mavenCentral() // release versions
// pre-release snapshots: maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

dependencies {
implementation("net.alphatab:alphaTab-android:1.3.0")
// pre-release snapshots: implementation("net.alphatab:alphaTab-android:1.3.0-SNAPSHOT")
}

Initializing alphaTab​

After adding alphaTab as a dependency to your project, you can add the alphaTab control alphaTab.AlphaTabView to any layout.

info

Important: We currently only ship a classical "view" based control. If you have interest in a Jetpack Compose control, vote for this issue on our roadmap or try to wrap the classical control.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="net.alphatab.android.MainActivity"
android:orientation="vertical">

<alphaTab.AlphaTabView
android:id="@+id/alphatab_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

In your activity code you can then interact with alphaTab by obtaining the reference to this control:

class MainActivity : ComponentActivity() {
private lateinit var _alphaTabView: AlphaTabView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.activity_main)
_alphaTabView = findViewById(R.id.alphatab_view)

val api = _alphaTabView.api;
// use alphaTab
}
}

Additional Notes​

You might want to check out the samples at https://github.com/CoderLine/alphaTabSamplesAndroid/ to get a small impression how to hook up things.

Dependencies​

For the Kotlin for Android Version alphaTab needs to rely on some 3rd party libraries to do certain operations.

  1. For rendering, either the built-in Android Canvas can be used or alphaTab comes with a dependency to AlphaSkia for modern cross platform rendering of images. Skia is the graphics engine used in Chrome and is proven to be fast and reliable. We recommend using Skia as rendering engine over Android Canvas.

  2. For asynchronous operations org.jetbrains.kotlinx:kotlinx-coroutines-core is used.

If you want to get support for other UI frameworks or audio libraries feel free to reach out to us.