Packaging TurboWarp projects to APK

This page (everything below that divider line) was mostly written by GarboMuffin (who is also the TurboWarp Packager's creator) in a packager pull request, credit goes to him.

The styles are also taken from the packager's source code, which is licensed under Apache-2.0.

I just put this on its own webpage, with some modifications to account for this not being part of the packager (and thus not being able to generate some parts), for convienience so an easily readable version can be linked to.

-CST1229


Unlike the other environments, Android support is not fully automated. You must manually create an app. This section will try to guide you through the process.

This section assumes you have full access (including adminstrator/root) to a Windows, macOS, or Linux computer.

Install Android Studio

Install Android Studio.

This is quite large and may take a while.

Create a new project

Create a new project in Android Studio.

Create assets folder

In the sidebar on the left, right click on "app", then select "New" > "Folder" > "Assets folder". Use the default settings.

Prepare project

Package the project as a zip normally.

Extract the zip and drag its files into "assets" folder you created. (You can directly drag and drop files over the assets folder in Android Studio)

Making the app

In the sidebar on the left, navigate to app > src > main > MainActivity. This will open a short Kotlin file.

Replace everything after line 2 with the following:

import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebView

class MainActivity : AppCompatActivity() {
    private lateinit var web: WebView

    @SuppressLint("SetJavaScriptEnabled")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        web = WebView(this)
        web.settings.javaScriptEnabled = true
        web.loadUrl("file:///android_asset/index.html")
        setContentView(web)
        actionBar?.hide()
        supportActionBar?.hide()
    }

    override fun onDestroy() {
        super.onDestroy()
        web.destroy()
    }
}

Make sure to leave the first line that says package ...

At this point, you have a functional Android app. However, there are still a few more things you should change.

Fixing screen orientation issues

In the sidebar on the left, open app > main > AndroidManifest.xml

Find the section that looks like this:

        <activity
            android:name=".MainActivity"
            android:exported="true">

And replace it with this:

        <activity
            android:configChanges="orientation|screenSize"
            android:screenOrientation="sensor"
            android:name=".MainActivity"
            android:exported="true">

Updating colors

Currently the app has a purple color scheme, which may not be what you want. This can be changed.

In the sidebar on the left, open app > main > res > values > color.xml.

You will see these lines:

    <color name="purple_200">#FFBB86FC</color>
    <color name="purple_500">#FF6200EE</color>
    <color name="purple_700">#FF3700B3</color>

Replace the colors (the parts after #FF) with your background hex color, for example:

    <color name="purple_200">#FF4D97FF</color>
    <color name="purple_500">#FF4D97FF</color>
    <color name="purple_700">#FF4D97FF</color>

Do not change the other lines.

For advanced users, note that these color codes are a bit unusual in that the "alpha" or "transparency" byte (typically 255 or FF) goes first instead of last.

Ignore the bits about purple_yyy; just leave them as is. It would typically be a good idea to rename these colors, but you will be making more work for yourself because you'll have to update some other files to reflect the new names.

Updating the project

It's likely that at some point you will want to update the project without redoing this entire guide. Updating a project is much simpler:

  1. Open Android Studio and open the project
  2. Delete everything inside the assets folder
  3. Re-run the packager
  4. Extract the zip and put all of its files into the assets folder