Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add android support #1231

Merged
merged 17 commits into from
Jun 20, 2024
Merged

Add android support #1231

merged 17 commits into from
Jun 20, 2024

Conversation

k3yss
Copy link
Collaborator

@k3yss k3yss commented May 26, 2024

This PR adds Android support to devenv.

This integration works with the latest channel, but creating an AVD through android studio is not possible (Use CLI for this). To try out this PR, you need to change the devenv input to github:k3yss/work/keys/android-support?dir=src/modules in your devenv.yaml file.

devenv.yaml

inputs:
  devenv:
    url: path: github:k3yss/work/keys/android-support?dir=src/modules
allowUnfree: true

After enabling the input, you can add android.enable=true in your devenv.nix file.

devenv.nix

{ ... }:

{
  android.enable = true;
 
 #to use flutter we can do:
 android.flutter.enable = true;

 #to use react-native we can do:
 android.reactNative.enable = true; 
}

You should have an base working Android environment ready.

Below are a few working screenshots:

Android Emulator working:
image

React Native working:
image

Flutter on android working:
image

Flutter on linux working:
image

TODO

  • Test with React Native
  • Test with flutter
  • Add example
  • Make options modular
  • Make sure emulator works

Fixes #310

@k3yss k3yss marked this pull request as draft May 26, 2024 17:31
@k3yss k3yss force-pushed the work/keys/android-support branch from b970b72 to acff47f Compare June 5, 2024 09:02
@k3yss k3yss force-pushed the work/keys/android-support branch from acff47f to 0184d63 Compare June 5, 2024 09:06
@k3yss k3yss force-pushed the work/keys/android-support branch from 904bbb5 to 0c90213 Compare June 5, 2024 10:29
@k3yss k3yss marked this pull request as ready for review June 5, 2024 10:38
@k3yss
Copy link
Collaborator Author

k3yss commented Jun 5, 2024

Ready for review : )
cc @domenkozar @sandydoo

src/modules/integrations/android.nix Show resolved Hide resolved
src/modules/integrations/android.nix Outdated Show resolved Hide resolved
src/modules/integrations/android.nix Outdated Show resolved Hide resolved
src/modules/integrations/android.nix Outdated Show resolved Hide resolved
@numinit
Copy link

numinit commented Jun 9, 2024

We are about to get better AVD support with android studio: NixOS/nixpkgs#315233

Edit: Howdy from nixpkgs! 👋 I was responsible for the refactor of androidenv in nixpkgs to make my life at work on a professional Android product easier. If anything is amiss, I can try to solve it.

@k3yss
Copy link
Collaborator Author

k3yss commented Jun 10, 2024

Hey @numinit , thanks for the information, I have been patiently following the PR. One issue that users currently face is the creation of an emulator from Android Studio, I tried playing around with various env variables to come up with a potential fix for it but was unsuccessful. Did you manage to come up with a solution for it or do we expect the user to create emulators via avdmanager tool?

@numinit
Copy link

numinit commented Jun 10, 2024

@k3yss The trick I've found is twofold: the wrapper makes new projects default their sdk.dir to the androidenv composition, but you still need the sdk.dir (and possibly ndk.dir) in your local.properties. Any new AVDs created with Android Studio work fine if this is true.

@k3yss
Copy link
Collaborator Author

k3yss commented Jun 10, 2024

@numinit What worked for me is:
1: Create a AVD using the CLI command.
2: Open the project in android studio.
3: Run the start command.

  • In case of react-native I did npm run android from the terminal which worked!

What I wanted to ask if it was possible to do step 1 using android studio.

@numinit
Copy link

numinit commented Jun 10, 2024

It is possible to do step 1 in Android Studio. It's a little counterintuitive though, you need a project open with sdk.dir set properly for it to work right.

@k3yss
Copy link
Collaborator Author

k3yss commented Jun 12, 2024

@numinit I think I already have that configured, let's do a merge in the current state and wait for reviews.

@k3yss k3yss requested a review from domenkozar June 12, 2024 22:31
@k3yss k3yss force-pushed the work/keys/android-support branch from 46890e3 to bc950a6 Compare June 12, 2024 23:14
@k3yss
Copy link
Collaborator Author

k3yss commented Jun 12, 2024

@domenkozar can you try the flutter configuration. I have some configuration issues with home manager.

@k3yss
Copy link
Collaborator Author

k3yss commented Jun 18, 2024

flutter seems to be broken, investigating.

@k3yss
Copy link
Collaborator Author

k3yss commented Jun 18, 2024

Everything works as expected for now, hope I didn't miss something 🤞

@k3yss k3yss force-pushed the work/keys/android-support branch from 5280798 to ceb9a89 Compare June 19, 2024 12:12
@domenkozar domenkozar merged commit c23a9e6 into cachix:main Jun 20, 2024
247 of 271 checks passed
@k3yss k3yss deleted the work/keys/android-support branch June 20, 2024 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Android development support
3 participants