I have installed the android toolchain and have succeeded in compiling the Hello World example for Android, uploading it using adb and executing it on an actual device.
My next step is to try out the swift-android-examples, particularly the ‘hello-swift-java’.
But I am completely new to Android Studio, and I have not been able to figure out how to set up the ‘Configuration’ correctly.
I am following the guide here:
And I have made it to the ‘Running the example’ step.
I open the ‘swift-android-examples’ directory in Android Studio, and the next step in the guide tells me to select the ‘hashing-app’ gradle target.
However, I can’t find any such target. I think that I need to configure SDK, JDK and NDK paths somewhere, and likely also create a ‘Configuration’ where I am not certain if I should select ‘Gradle’ og ‘Android app’. When I select ‘Gradle’ I can’t select anything for ‘Gradle project’.
I have tried adding an ndk.dir property to a local.properties file, but that didn’t really change anything.
Does anyone have any experience starting from a fresh install of Android Studio on macOS and following the guides for installing the Swift Android toolchain, JDKs and NDKs?
I am not really an Android Studio expert, but yeah you probably need to ensure you have JDK 25 installed and everything is setup etc. Usually, I feel like Android Studio is pretty good at giving you hints, actions etc when there is something missing. Usually in the bottom right of the IDE. Does that not say anything anywhere?
This is all I have in my local.properties: sdk.dir=/Users/mads/Library/Android/sdk
The configurations should appear automatically once everything is set up OK. Can you “Sync Gradle Project” if you open the Gradle pane in the right navigation bar, and right click on the “Swift Android Examples”?
Thanks a lot. I think that the issue was that the gradle stuff was not recognized properly. I deleted Android Studio and installed through homebrew and when opening the project again it started doing the gradle sync.
Now I can run the project, but currently it crashes when I tap ‘Hash’ button in the app. I’ll go through the steps again and see if I missed something.
I am using main-snapshot-2025-11-03 rather than 10-16, since I could make the latter work and I found references to the former in a thread in here, and that worked for the basic Android examples.
Where did you get the Nov. 3 trunk snapshot you are using? The official swift.org builds skipped that one for the Swift SDK for Android.
Are you using the new #available(Android API, *) checking feature and which Android NDK version are you building with?
If I understand you right, you are able to build the example app, but not run it properly. That seems fairly unusual, but I suppose it's certainly possible with these trunk snapshots.