tadfisher / android-nixpkgs

Nix-packaged Android SDK
MIT License
270 stars 41 forks source link

The SDK directory is not writable #106

Open orhnk opened 1 month ago

orhnk commented 1 month ago
{
  description = "Flutter 3.13.x";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    android-nixpkgs = {
      url = "github:tadfisher/android-nixpkgs";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    flake-utils.url = "github:numtide/flake-utils";
  };
  outputs = {
    self,
    android-nixpkgs,
    nixpkgs,
    flake-utils,
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      pkgs = import nixpkgs {
        inherit system;
        # config = {
        #   android_sdk.accept_license = true;
        #   allowUnfree = true;
        # };
      };

      android-pkgs = import android-nixpkgs {
        inherit system;
      };

      jdk-custom = pkgs.jdk17;
      android-sdk-custom = android-pkgs.sdk (sdkPkgs:
        with sdkPkgs; [
          # List options: `nix flake show github:tadfisher/android-nixpkgs`
          cmdline-tools-latest
          build-tools-34-0-0
          platform-tools
          platforms-android-34
          system-images-android-24-google-apis-x86
          emulator
        ]);
    in {
      devShell = with pkgs;
        mkShell rec {
          JAVA_HOME = jdk-custom;
          # ANDROID_HOME = "${android-sdk-custom}/share/android-sdk";
          # ANDROID_SDK_HOME = "${android-sdk-custom}/share/android-sdk"; # Deprecated Use ANDROID_HOME instead
          # ANDROID_SDK_ROOT = "${android-sdk-custom}/share/android-sdk";
          # ANDROID_SDK_ROOT = "${android-sdk-custom}/libexec/android-sdk";
          CHROME_EXECUTABLE = "${pkgs.chromium}/bin/chromium";
          buildInputs = [
            flutter
            android-sdk-custom
            jdk-custom
            gradle
          ];
        };
    });
}
[nixos@enka:~/src/sanri]$  flutter run
Launching lib/main.dart on Android SDK built for x86 in debug mode...
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply

Checking the license for package Android SDK Tools in /nix/store/kka24f9gjg4v3m3mr06lm2ynk3ns6pwv-android-sdk-env/share/android-sdk/licenses
License for package Android SDK Tools accepted.
Preparing "Install Android SDK Tools (revision: 26.1.1)".
Warning: Failed to read or create install properties file.
Checking the license for package Android SDK Build-Tools 30.0.3 in /nix/store/kka24f9gjg4v3m3mr06lm2ynk3ns6pwv-android-sdk-env/share/android-sdk/licenses
License for package Android SDK Build-Tools 30.0.3 accepted.
Preparing "Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)".
Warning: Failed to read or create install properties file.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following SDK components:
      tools Android SDK Tools
      build-tools;30.0.3 Android SDK Build-Tools 30.0.3
-  The SDK directory is not writable (/nix/store/kka24f9gjg4v3m3mr06lm2ynk3ns6pwv-android-sdk-env/share/android-sdk)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Running Gradle task 'assembleDebug'...                           1,587ms
Error: Gradle task assembleDebug failed with exit code 1
orhnk commented 1 month ago

The issue happens whenever I build my program to an android target. So by default, I can build the app for both Linux and Web targets. But when I start up an Android device emulator. Just running the app using flutter run (somehow it automatically selects the android target [may be a vscode flutter extension build feature though]) will puke out an error message given above.

mattyg commented 4 weeks ago

I'm having this issue as well