How to Deploy a Codename One App on Android
Tags: android, java, kotlin
Published: 2021-04-06 12:20:28

In my [last post][1] I showed off the new [Codename One initializr online tool][1], generating a Maven project, and opened it in IntelliJ.

In this video I demonstrate how to build an Android app with this project.

{% youtube 9ZK15NicWDQ %}

## TLDW (Too Long Didn't Watch):

Here's the gist of the video. There are two different build options for Android:

1.  Build Server > Android
2.  Local Builds > Android Gradle Project

In this video, I start with option 2, "Android Gradle Project". This option *does NOT* require a Codename One account, and performs all of the build on your local machine. It *does* require that you have Android Studio installed.

I select "Local Builds" > "Android Gradle Project" from the Configuration menu of IntelliJ, and then press "Run".

<img src="https://sjhannah.com/blog/wp-content/uploads/2021/03/Screen-Shot-2021-03-30-at-9.25.41-AM.png" alt="Screen Shot 2021-03-30 at 9.25.41 AM" width="808" height="275" class="aligncenter size-full wp-image-568" />

This generates an Android Studio project, and automatically opens it in Android studio.

<img src="https://sjhannah.com/blog/wp-content/uploads/2021/03/Screen-Shot-2021-03-30-at-9.27.42-AM.png" alt="Screen Shot 2021-03-30 at 9.27.42 AM" width="857" height="464" class="aligncenter size-full wp-image-569" />

I then press "Run" in the Android Studio, and wait while it builds and installs the app on my Android Emulator.

<img src="https://sjhannah.com/blog/wp-content/uploads/2021/03/Screen-Shot-2021-03-30-at-9.29.25-AM.png" alt="Screen Shot 2021-03-30 at 9.29.25 AM" width="324" height="480" class="aligncenter size-full wp-image-570" />

In the second part of this video, I use the "Build Server" > "Android" build option, which is much simpler, and doesn't require you to install Android Studio. All you need is IntelliJ (Actually you don't even need IntelliJ, as you could just build the project using Maven), and it will use the Codename One build server to generate the Android app.

After selecting "Build Server" > "Android" from the configuration menu, I press "Run" to start the build.

<img src="https://sjhannah.com/blog/wp-content/uploads/2021/03/Screen-Shot-2021-03-30-at-9.30.39-AM.png" alt="Screen Shot 2021-03-30 at 9.30.39 AM" width="360" height="160" class="aligncenter size-full wp-image-571" />

It then redirects me to the Codename One dashboard where I can monitor the build progress and, download the app when it's done.

<img src="https://sjhannah.com/blog/wp-content/uploads/2021/03/Screen-Shot-2021-03-30-at-9.31.37-AM-1024x288.png" alt="Screen Shot 2021-03-30 at 9.31.37 AM" width="474" height="133" class="aligncenter size-large wp-image-573" />

## More Background

When we decided to [migrate to Maven][2], we also made the choice to add [official local build targets][3] so that developers are no longer reliant on the build server to build their Android and iOS apps. Building locally has always been an option, but it was difficult, and we didn't provide support for it. By adding an official local build option, we are hoping that developers who balked at Codename One because they didn't want to be reliant on us for their builds will give us another look.

If you haven't heard of [Codename One][4] yet, I encourage you to check us out. In my biased opinion, we are the best game in town, if you're looking to build native mobile apps in Java or Kotlin.

It only takes a minute to create and build your first project using [Codename One initializr][5].

 [1]: https://dev.to/shannah/online-tool-to-generate-ios-android-starter-project-k7h
 [2]: https://www.codenameone.com/blog/moving-to-maven.html
 [3]: https://www.codenameone.com/blog/you-can-now-build-android-and-ios-apps-locally.html
 [4]: https://www.codenameone.com
 [5]: https://start.codenameone.com