public static AndroidApkToolchain GetToolChain()
 {
     if (ToolChain_AndroidArmv7 == null)
     {
         var androidConfig = ReadConfigFromFile();
         var androidNdk    = string.IsNullOrEmpty(androidConfig.NdkPath) ?
                             AndroidNdk.LocatorArmv7.UserDefaultOrDummy:
                             AndroidNdk.LocatorArmv7.UseSpecific(androidConfig.NdkPath);
         ToolChain_AndroidArmv7 = new AndroidApkToolchain(androidNdk, androidConfig.SdkPath, androidConfig.JavaPath, androidConfig.GradlePath);
     }
     return(ToolChain_AndroidArmv7);
 }
        private NPath PackageApp(NPath buildPath, BuiltNativeProgram mainProgram)
        {
            var mainLibPath = mainProgram.Path;

            m_projectFiles.Add(mainLibPath);
            m_projectFiles.AddRange(mainProgram.Deployables.Select(d => d.Path));

            if (m_apkToolchain == null)
            {
                Console.WriteLine($"Error: not Android APK toolchain");
                return(buildPath);
            }
            if (AndroidApkToolchain.ExportProject)
            {
                var deployedPath = buildPath.Combine(m_gameName);
                GenerateGradleProject(deployedPath);

                // stub action to have deployedPath in build tree and set correct dependencies
                Backend.Current.AddAction(
                    actionName: "Gradle project folder",
                    targetFiles: new[] { deployedPath },
                    inputs: m_projectFiles.ToArray(),
                    executableStringFor: $"echo created",
                    commandLineArguments: Array.Empty <string>(),
                    allowUnexpectedOutput: true,
                    allowUnwrittenOutputFiles: true
                    );
                return(deployedPath);
            }
            else
            {
                var deployedPath      = buildPath.Combine(m_gameName + "." + m_apkToolchain.ExecutableFormat.Extension);
                var gradleProjectPath = mainLibPath.Parent.Parent.Parent.Parent.Parent;
                GenerateGradleProject(gradleProjectPath);
                var pathToRoot = new NPath(string.Concat(Enumerable.Repeat("../", gradleProjectPath.Depth)));

                var javaLaunchPath   = new NPath(AndroidApkToolchain.Config.ExternalTools.JavaPath).Combine("bin").Combine("java");
                var gradleLaunchPath = AndroidApkToolchain.GetGradleLaunchJarPath();
                var releaseBuild     = m_config == DotsConfiguration.Release;
                var gradleCommand    = AndroidApkToolchain.BuildAppBundle ?
                                       (releaseBuild ? "bundleRelease" : "bundleDebug") :
                                       (releaseBuild ? "assembleRelease" : "assembleDebug");
                var gradleExecutableString = $"cd {gradleProjectPath.InQuotes()} && {javaLaunchPath.InQuotes()} -classpath {gradleLaunchPath.InQuotes()} org.gradle.launcher.GradleMain {gradleCommand} && cd {pathToRoot.InQuotes()}";

                var config          = releaseBuild ? "release" : "debug";
                var gradleBuildPath = gradleProjectPath.Combine("build/outputs").
                                      Combine(AndroidApkToolchain.BuildAppBundle ? "bundle" : "apk").
                                      Combine($"{config}/gradle-{config}.{(AndroidApkToolchain.BuildAppBundle ? "aab" : "apk")}");

                Backend.Current.AddAction(
                    actionName: "Build Gradle project",
                    targetFiles: new[] { gradleBuildPath },
                    inputs: m_projectFiles.ToArray(),
                    executableStringFor: gradleExecutableString,
                    commandLineArguments: Array.Empty <string>(),
                    allowUnexpectedOutput: false,
                    allowedOutputSubstrings: new[] { ":*", "BUILD SUCCESSFUL in *" }
                    );

                return(CopyTool.Instance().Setup(deployedPath, gradleBuildPath));
            }
        }
 public AndroidMainDynamicLibrary(NPath path, AndroidApkToolchain toolchain, params PrecompiledLibrary[] dynamicLibraryDependencies) : base(path, dynamicLibraryDependencies)
 {
     m_apkToolchain = toolchain;
 }
 public AndroidApkMainModule(NPath path, AndroidApkToolchain toolchain, params PrecompiledLibrary[] dynamicLibraryDependencies) : base(path, dynamicLibraryDependencies)
 {
     m_libPath = toolchain.Architecture is Arm64Architecture ? "arm64-v8a" : "armeabi-v7a";
 }