diff --git a/.github/workflows/update-libs.yml b/.github/workflows/update-libs.yml
index 2fec31ee..09fa0e2e 100644
--- a/.github/workflows/update-libs.yml
+++ b/.github/workflows/update-libs.yml
@@ -71,6 +71,13 @@ jobs:
path: snippets/build/plugin/*.cgp
if-no-files-found: error
+ - name: Upload ndk-installer CGP
+ uses: actions/upload-artifact@v4
+ with:
+ name: ndk-installer
+ path: ndk-installer-plugin/build/plugin/*.cgp
+ if-no-files-found: error
+
- name: Commit updated jars
run: |
sha=$(git -C .cache/CodeOnTheGo rev-parse --short HEAD)
diff --git a/ndk-installer-plugin/.gitignore b/ndk-installer-plugin/.gitignore
new file mode 100644
index 00000000..6af499b7
--- /dev/null
+++ b/ndk-installer-plugin/.gitignore
@@ -0,0 +1,29 @@
+# Gradle
+.gradle/
+build/
+gradle-app.setting
+!gradle-wrapper.jar
+.gradletasknamecache
+
+# IDE
+.idea/
+*.iml
+*.ipr
+*.iws
+.project
+.classpath
+.settings/
+.kotlin/
+
+# Local configuration
+local.properties
+
+# OS
+.DS_Store
+Thumbs.db
+
+# Logs
+*.log
+
+# Test outputs
+test-results/
diff --git a/ndk-installer-plugin/build.gradle.kts b/ndk-installer-plugin/build.gradle.kts
new file mode 100644
index 00000000..4ef36565
--- /dev/null
+++ b/ndk-installer-plugin/build.gradle.kts
@@ -0,0 +1,130 @@
+import org.jetbrains.kotlin.gradle.dsl.JvmTarget
+
+import java.net.URL
+import java.security.MessageDigest
+import java.net.HttpURLConnection
+
+
+plugins {
+ id("com.android.application")
+ id("org.jetbrains.kotlin.android")
+ id("com.itsaky.androidide.plugins.build")
+}
+
+pluginBuilder {
+ pluginName = "ndk-installer"
+}
+
+android {
+ namespace = "org.appdevforall.ndkinstaller"
+ compileSdk = 34
+
+ defaultConfig {
+ applicationId = "org.appdevforall.ndkinstaller"
+ minSdk = 26
+ targetSdk = 34
+ versionCode = 1
+ versionName = "1.0.0"
+ }
+
+ buildTypes {
+ release {
+ isMinifyEnabled = false
+ proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
+ }
+ }
+
+ androidResources {
+ noCompress += listOf("xz")
+ }
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ }
+
+}
+
+kotlin {
+ compilerOptions {
+ jvmTarget.set(JvmTarget.JVM_17)
+ }
+}
+
+dependencies {
+ compileOnly(files("../libs/plugin-api.jar"))
+
+
+ implementation("org.jetbrains.kotlin:kotlin-stdlib:2.1.21")
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
+}
+
+fun httpDownload(url: String): ByteArray {
+ val connection = URL(url).openConnection() as HttpURLConnection
+ connection.instanceFollowRedirects = true
+ connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
+ connection.connectTimeout = 15000
+ connection.readTimeout = 30000
+
+ val code = connection.responseCode
+ if (code != 200) {
+ throw GradleException("Failed to download $url (HTTP $code)")
+ }
+
+ return connection.inputStream.use { it.readBytes() }
+}
+
+fun md5Of(file: File): String {
+ val md = MessageDigest.getInstance("MD5")
+ file.inputStream().use { input ->
+ val buffer = ByteArray(8192)
+ var read: Int
+ while (input.read(buffer).also { read = it } != -1) {
+ md.update(buffer, 0, read)
+ }
+ }
+ return md.digest().joinToString("") { "%02x".format(it) }
+}
+
+val downloadAssets by tasks.registering {
+ val assetsDir = project.file("src/main/assets")
+ val archiveFile = assetsDir.resolve("ndk-cmake.tar.xz")
+ val md5File = assetsDir.resolve("ndk-cmake.tar.xz.md5")
+
+ outputs.files(archiveFile)
+
+ doLast {
+ assetsDir.mkdirs()
+
+ val archiveUrl = "https://www.appdevforall.org/dev-assets/release/v8/ndk-cmake.tar.xz"
+ val md5Url = "https://www.appdevforall.org/dev-assets/release/v8/ndk-cmake.tar.xz.md5"
+
+ logger.info("Downloading archive....")
+ val archiveBytes = httpDownload(archiveUrl)
+ archiveFile.writeBytes(archiveBytes)
+
+ logger.info("Downloading MD5…")
+ val md5Bytes = httpDownload(md5Url)
+ md5File.writeBytes(md5Bytes)
+
+ val expected = md5File.readText().trim()
+ val actual = md5Of(archiveFile)
+
+ logger.info("Expected MD5: $expected")
+ logger.info("Actual MD5: $actual")
+
+ md5File.delete()
+
+ if (!expected.equals(actual, ignoreCase = true)) {
+ throw GradleException("MD5 checksum mismatch for ndk-cmake.tar.xz")
+ }
+
+ }
+}
+
+
+
+
+
+
+
diff --git a/ndk-installer-plugin/gradle.properties b/ndk-installer-plugin/gradle.properties
new file mode 100644
index 00000000..2e113229
--- /dev/null
+++ b/ndk-installer-plugin/gradle.properties
@@ -0,0 +1,3 @@
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+android.useAndroidX=true
+android.nonTransitiveRClass=true
diff --git a/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.jar b/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.jar
new file mode 100755
index 00000000..8bdaf60c
Binary files /dev/null and b/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.properties b/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..d4081da4
--- /dev/null
+++ b/ndk-installer-plugin/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/ndk-installer-plugin/gradlew b/ndk-installer-plugin/gradlew
new file mode 100755
index 00000000..ef07e016
--- /dev/null
+++ b/ndk-installer-plugin/gradlew
@@ -0,0 +1,251 @@
+#!/bin/sh
+
+#
+# Copyright © 2015 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH="\\\"\\\""
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/ndk-installer-plugin/gradlew.bat b/ndk-installer-plugin/gradlew.bat
new file mode 100644
index 00000000..5eed7ee8
--- /dev/null
+++ b/ndk-installer-plugin/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/ndk-installer-plugin/proguard-rules.pro b/ndk-installer-plugin/proguard-rules.pro
new file mode 100644
index 00000000..780d2227
--- /dev/null
+++ b/ndk-installer-plugin/proguard-rules.pro
@@ -0,0 +1,2 @@
+-keep class org.appdevforall.ndkinstaller.** { *; }
+-keep class com.itsaky.androidide.plugins.** { *; }
diff --git a/ndk-installer-plugin/settings.gradle.kts b/ndk-installer-plugin/settings.gradle.kts
new file mode 100644
index 00000000..a168e4dc
--- /dev/null
+++ b/ndk-installer-plugin/settings.gradle.kts
@@ -0,0 +1,31 @@
+rootProject.name = "ndk-installer-plugin"
+
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+
+buildscript {
+ repositories {
+ google()
+ mavenCentral()
+ }
+ dependencies {
+ classpath(files("../libs/plugin-api.jar"))
+ classpath(files("../libs/gradle-plugin.jar"))
+ classpath("com.android.tools.build:gradle:8.11.0")
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.0")
+ }
+}
+
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
+ repositories {
+ mavenCentral()
+ google()
+ gradlePluginPortal()
+ }
+}
diff --git a/ndk-installer-plugin/src/main/AndroidManifest.xml b/ndk-installer-plugin/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..d19ae657
--- /dev/null
+++ b/ndk-installer-plugin/src/main/AndroidManifest.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ndk-installer-plugin/src/main/assets/ndk-cmake.tar.xz b/ndk-installer-plugin/src/main/assets/ndk-cmake.tar.xz
new file mode 100644
index 00000000..de3d0277
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/ndk-cmake.tar.xz
@@ -0,0 +1 @@
+
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/build.gradle.kts.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/build.gradle.kts.peb
new file mode 100644
index 00000000..1c4e1b3d
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/build.gradle.kts.peb
@@ -0,0 +1,173 @@
+import java.util.Properties
+import java.io.FileInputStream
+
+plugins {
+id("com.android.application") version "${{AGP_VERSION}}"
+${% if LANGUAGE == 'kotlin' %}
+ kotlin("android") version "${{KOTLIN_VERSION}}"
+${% endif %}
+}
+
+val keystorePropsFile = rootProject.file("release.properties")
+val keystoreProps = Properties()
+
+if (keystorePropsFile.exists()) {
+ keystoreProps.load(FileInputStream(keystorePropsFile))
+}
+
+val hasValidSigningProps = keystorePropsFile.exists().also { exists ->
+ if (exists) {
+ FileInputStream(keystorePropsFile).use { keystoreProps.load(it) }
+ }
+}.let {
+ listOf("storeFile", "storePassword",
+ "keyAlias", "keyPassword").all { key ->
+ keystoreProps[key] != null
+ }
+}
+
+
+android {
+ namespace = "${{PACKAGE_NAME}}"
+ compileSdk = ${{COMPILE_SDK}}
+
+
+ // disable linter
+ lint {
+ checkReleaseBuilds = false
+ }
+
+ signingConfigs {
+ if (hasValidSigningProps) {
+ create("release") {
+ storeFile = rootProject.file(keystoreProps["storeFile"] as String)
+ storePassword = keystoreProps["storePassword"] as String
+ keyAlias = keystoreProps["keyAlias"] as String
+ keyPassword = keystoreProps["keyPassword"] as String
+ }
+ }
+ }
+
+ defaultConfig {
+ applicationId = "${{PACKAGE_NAME}}"
+ minSdk = ${{MIN_SDK}}
+ targetSdk = ${{TARGET_SDK}}
+ versionCode = 1
+ versionName = "1.0"
+
+ vectorDrawables {
+ useSupportLibrary = true
+ }
+
+ ndk {
+ abiFilters += "arm64-v8a"
+ }
+
+ externalNativeBuild {
+ cmake {
+ cppFlags += "-std=c++17"
+ }
+ }
+ }
+
+ ndkVersion = "29.0.14206865"
+
+ externalNativeBuild {
+ cmake {
+ path = file("src/main/cpp/CMakeLists.txt")
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility = ${{JAVA_SOURCE_COMPAT}}
+ targetCompatibility = ${{JAVA_TARGET_COMPAT}}
+ }
+
+ buildTypes {
+ release {
+ if (hasValidSigningProps) {
+ signingConfig = signingConfigs.getByName("release")
+ }
+ isMinifyEnabled = true
+ proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
+ }
+ }
+
+ buildFeatures {
+ viewBinding = true
+
+ }
+ composeOptions {
+ kotlinCompilerExtensionVersion = "1.5.10"
+ }
+ packaging {
+ resources {
+ resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}")
+ resources.excludes.add("META-INF/kotlinx_coroutines_core.version")
+
+ // The part below is only needed for compose builds.
+ // This packaging block is required to solve interdependency conflicts.
+ // They arise only when using local maven repo, so I suppose online repos have some way of solving such issues.
+
+ // Caused by: com.android.builder.merge.DuplicateRelativeFileException: 4 files found with path 'commonMain/default/linkdata/module' from inputs:
+ // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\collection\collection\1.4.2\collection-1.4.2.jar
+ // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\lifecycle\lifecycle-common\2.8.7\lifecycle-common-2.8.7.jar
+ // - AndroidIDE\libs_source\gradle\localMvnRepository\androidx\annotation\annotation\1.8.1\annotation-1.8.1.jar
+ // - AndroidIDE\libs_source\gradle\localMvnRepository\org\jetbrains\kotlinx\kotlinx-coroutines-core\1.7.3\kotlinx-coroutines-core-1.7.3.jar
+ // And some others.
+ resources.pickFirsts.add("nonJvmMain/default/linkdata/package_androidx/0_androidx.knm")
+ resources.pickFirsts.add("nonJvmMain/default/linkdata/root_package/0_.knm")
+ resources.pickFirsts.add("nonJvmMain/default/linkdata/module")
+
+ resources.pickFirsts.add("nativeMain/default/linkdata/root_package/0_.knm")
+ resources.pickFirsts.add("nativeMain/default/linkdata/module")
+
+ resources.pickFirsts.add("commonMain/default/linkdata/root_package/0_.knm")
+ resources.pickFirsts.add("commonMain/default/linkdata/module")
+ resources.pickFirsts.add("commonMain/default/linkdata/package_androidx/0_androidx.knm")
+
+ resources.pickFirsts.add("META-INF/kotlin-project-structure-metadata.json")
+
+ resources.merges.add("commonMain/default/manifest")
+ resources.merges.add("nonJvmMain/default/manifest")
+ resources.merges.add("nativeMain/default/manifest")
+ }
+ }
+
+ configurations.all {
+ resolutionStrategy {
+ // Force the use of Kotlin stdlib 1.9.22 for all modules
+ force("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
+ force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.22")
+ force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.22")
+
+ // Force specific AndroidX versions to avoid conflicts
+ force("androidx.collection:collection:1.4.2")
+ force("androidx.annotation:annotation:1.8.1")
+ force("androidx.core:core-ktx:1.8.0")
+ force("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
+ force("androidx.collection:collection-ktx:1.4.2")
+ }
+ }
+}
+
+tasks.withType {
+ options.compilerArgs.add("-Xlint:deprecation")
+}
+
+
+${% if LANGUAGE == 'kotlin' %}
+ tasks.withType().configureEach {
+ kotlinOptions.jvmTarget = "${{JAVA_TARGET}}"
+ }
+${% endif %}
+
+dependencies {
+
+
+ implementation("androidx.interpolator:interpolator:1.0.0")
+ implementation("androidx.startup:startup-runtime:1.1.1")
+ implementation("com.google.android.material:material:1.9.0")
+ implementation("androidx.constraintlayout:constraintlayout:2.1.4")
+ implementation("androidx.appcompat:appcompat:1.6.1")
+}
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/gitignore b/ndk-installer-plugin/src/main/assets/templates/ndk/app/gitignore
new file mode 100644
index 00000000..42afabfd
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/proguard-rules.pro b/ndk-installer-plugin/src/main/assets/templates/ndk/app/proguard-rules.pro
new file mode 100644
index 00000000..481bb434
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/AndroidManifest.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..71959e89
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/AndroidManifest.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/CMakeLists.txt b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/CMakeLists.txt
new file mode 100644
index 00000000..ac9cf262
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.10.2)
+
+project("ndkactivitykotlin")
+
+add_library(native-lib SHARED native-lib.cpp)
+
+find_library(log-lib log)
+
+target_link_libraries(native-lib ${log-lib})
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/native-lib.cpp.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/native-lib.cpp.peb
new file mode 100644
index 00000000..2bc61346
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/cpp/native-lib.cpp.peb
@@ -0,0 +1,9 @@
+#include
+#include
+
+extern "C" JNIEXPORT jstring JNICALL
+Java_${{ PACKAGE_NAME | replace({".": "_"}) }}_MainActivity_stringFromJNI(
+ JNIEnv* env,
+ jobject /* this */) {
+ return env->NewStringUTF("Hello from C++");
+}
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.java.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.java.peb
new file mode 100644
index 00000000..c12c581d
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.java.peb
@@ -0,0 +1,38 @@
+
+package ${{PACKAGE_NAME}};
+
+import androidx.appcompat.app.AppCompatActivity;
+import android.os.Bundle;
+import ${{PACKAGE_NAME}}.databinding.ActivityMainBinding;
+
+public class MainActivity extends AppCompatActivity {
+ private ActivityMainBinding binding;
+
+ // Load the native library
+ static {
+ System.loadLibrary("native-lib");
+ }
+
+ // Declare the native method
+ public native String stringFromJNI();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Inflate and get instance of binding
+ binding = ActivityMainBinding.inflate(getLayoutInflater());
+
+ // set content view to binding's root
+ setContentView(binding.getRoot());
+
+ // Call JNI method and display result
+ binding.textView.setText(stringFromJNI());
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ this.binding = null;
+ }
+}
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb
new file mode 100644
index 00000000..c359f767
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb
@@ -0,0 +1,42 @@
+
+package ${{PACKAGE_NAME}}
+
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import ${{PACKAGE_NAME}}.databinding.ActivityMainBinding
+
+class MainActivity : AppCompatActivity() {
+
+ private var _binding: ActivityMainBinding? = null
+
+ private val binding: ActivityMainBinding
+ get() = checkNotNull(_binding) { "Activity has been destroyed" }
+
+ // Declare the native method
+ private external fun stringFromJNI(): String
+
+ // Load the native library
+ companion object {
+ init {
+ System.loadLibrary("native-lib");
+ }
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ // Inflate and get instance of binding
+ _binding = ActivityMainBinding.inflate(layoutInflater)
+
+ // set content view to binding's root
+ setContentView(binding.root)
+
+ // Call JNI method and display result
+ binding.textView.text = stringFromJNI()
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ _binding = null
+ }
+}
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 00000000..2b068d11
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_background.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..07d5da9c
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_round.webp
new file mode 100644
index 00000000..ead67900
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/drawable/ic_launcher_round.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/layout/activity_main.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..3592bcad
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 00000000..eca70cfe
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 00000000..eca70cfe
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 00000000..d7bb5af9
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..bc9b71e2
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 00000000..b61d7366
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..b003c036
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 00000000..33b4e993
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..a62f3b0c
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 00000000..21a284e0
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..ead67900
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 00000000..aa7d6427
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..9126ae37
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/colors.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/colors.xml
new file mode 100644
index 00000000..a6b3daec
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/colors.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/themes.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/themes.xml
new file mode 100644
index 00000000..e8f677b8
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values-night/themes.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/colors.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/colors.xml
new file mode 100644
index 00000000..a6b3daec
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/colors.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/strings.xml.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/strings.xml.peb
new file mode 100644
index 00000000..c0d07cae
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/strings.xml.peb
@@ -0,0 +1,5 @@
+
+
+ ${{APP_NAME}}
+
+
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/themes.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/themes.xml
new file mode 100644
index 00000000..e8f677b8
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/values/themes.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/xml/backup_rules.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/xml/backup_rules.xml
new file mode 100644
index 00000000..9b42d90d
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/xml/backup_rules.xml
@@ -0,0 +1,13 @@
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/xml/data_extraction_rules.xml b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/xml/data_extraction_rules.xml
new file mode 100644
index 00000000..c6c3bb05
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/app/src/main/res/xml/data_extraction_rules.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/build.gradle.kts.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/build.gradle.kts.peb
new file mode 100644
index 00000000..77c988b8
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/build.gradle.kts.peb
@@ -0,0 +1,9 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+plugins {
+ id("com.android.application") apply false version "${{AGP_VERSION}}"
+ id("com.android.library") apply false version "${{AGP_VERSION}}"
+}
+
+tasks.register("clean") {
+ delete(rootProject.layout.buildDirectory)
+}
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/gitignore b/ndk-installer-plugin/src/main/assets/templates/ndk/gitignore
new file mode 100644
index 00000000..b6bc0116
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/gitignore
@@ -0,0 +1,83 @@
+# Built application files
+*.apk
+*.aar
+*.ap_
+*.aab
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+/bin/
+/gen/
+/out/
+# Uncomment the following line in case you need and you don't have the release build type files in your app
+# Gradle files
+.gradle/
+/build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# IntelliJ
+*.iml
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/gradle.xml
+.idea/assetWizardSettings.xml
+.idea/dictionaries
+.idea/libraries
+# Android Studio 3 in .gitignore file.
+.idea/caches
+.idea/modules.xml
+# Comment next line if keeping position of elements in Navigation Editor is relevant for you
+.idea/navEditor.xml
+
+# Keystore files
+# Uncomment the following lines if you do not want to check your keystore files in.
+#*.jks
+#*.keystore
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+.cxx/
+
+# Google Services (e.g. APIs or Firebase)
+# google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
+
+# fastlane
+fastlane/report.xml
+fastlane/Preview.html
+fastlane/screenshots
+fastlane/test_output
+fastlane/readme.md
+
+# Version control
+vcs.xml
+
+# lint
+lint/intermediates/
+lint/generated/
+lint/outputs/
+lint/tmp/
+# lint/reports/
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/gradle.properties b/ndk-installer-plugin/src/main/assets/templates/ndk/gradle.properties
new file mode 100644
index 00000000..cd0519bb
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/gradle.properties
@@ -0,0 +1,23 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app"s APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Kotlin code style for this project: "official" or "obsolete":
+kotlin.code.style=official
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/gradle/wrapper/gradle-wrapper.jar b/ndk-installer-plugin/src/main/assets/templates/ndk/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..a4b76b95
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/gradle/wrapper/gradle-wrapper.properties.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/gradle/wrapper/gradle-wrapper.properties.peb
new file mode 100644
index 00000000..0d1e26aa
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/gradle/wrapper/gradle-wrapper.properties.peb
@@ -0,0 +1,6 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-${{GRADLE_VERSION}}-bin.zip
+networkTimeout=10000
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/gradlew b/ndk-installer-plugin/src/main/assets/templates/ndk/gradlew
new file mode 100644
index 00000000..f5feea6d
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/gradlew
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/settings.gradle.kts.peb b/ndk-installer-plugin/src/main/assets/templates/ndk/settings.gradle.kts.peb
new file mode 100644
index 00000000..c4247da8
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/settings.gradle.kts.peb
@@ -0,0 +1,19 @@
+pluginManagement {
+ repositories {
+ gradlePluginPortal()
+ google()
+ mavenCentral()
+ }
+}
+
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+rootProject.name = "${{APP_NAME}}"
+
+include(":app")
\ No newline at end of file
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/template/template.json b/ndk-installer-plugin/src/main/assets/templates/ndk/template/template.json
new file mode 100644
index 00000000..131811a0
--- /dev/null
+++ b/ndk-installer-plugin/src/main/assets/templates/ndk/template/template.json
@@ -0,0 +1,27 @@
+{
+ "name": "NDK Activity",
+ "description": "Creates a new NDK activity",
+ "tooltipTag": "template.ndk.activity",
+ "version": "0.1",
+ "parameters": {
+ "required": {
+ "appName": {identifier: "APP_NAME"},
+ "packageName": {identifier: "PACKAGE_NAME"},
+ "saveLocation": {identifier: "SAVE_LOCATION"}
+ },
+ "optional": {
+ "language": {identifier: "LANGUAGE"},
+ "minsdk": {identifier: "MIN_SDK"}
+ }
+ },
+ "system": {
+ "agpVersion": { "identifier": "AGP_VERSION" },
+ "kotlinVersion": { "identifier": "KOTLIN_VERSION" },
+ "gradleVersion": { "identifier": "GRADLE_VERSION" },
+ "compileSdk": { "identifier": "COMPILE_SDK" },
+ "targetSdk": { "identifier": "TARGET_SDK" },
+ "javaSourceCompat": { "identifier": "JAVA_SOURCE_COMPAT" },
+ "javaTargetCompat": { "identifier": "JAVA_TARGET_COMPAT" },
+ "javaTarget": { "identifier": "JAVA_TARGET" }
+ }
+}
diff --git a/ndk-installer-plugin/src/main/assets/templates/ndk/template/thumb.png b/ndk-installer-plugin/src/main/assets/templates/ndk/template/thumb.png
new file mode 100644
index 00000000..70249e39
Binary files /dev/null and b/ndk-installer-plugin/src/main/assets/templates/ndk/template/thumb.png differ
diff --git a/ndk-installer-plugin/src/main/kotlin/org/appdevforall/ndkinstaller/NdkInstallerPlugin.kt b/ndk-installer-plugin/src/main/kotlin/org/appdevforall/ndkinstaller/NdkInstallerPlugin.kt
new file mode 100644
index 00000000..091b4734
--- /dev/null
+++ b/ndk-installer-plugin/src/main/kotlin/org/appdevforall/ndkinstaller/NdkInstallerPlugin.kt
@@ -0,0 +1,177 @@
+package org.appdevforall.ndkinstaller
+
+import com.itsaky.androidide.plugins.IPlugin
+import com.itsaky.androidide.plugins.PluginContext
+import com.itsaky.androidide.plugins.services.ArchiveFormat
+import com.itsaky.androidide.plugins.services.ExtractResult
+import com.itsaky.androidide.plugins.services.IdeArchiveService
+import com.itsaky.androidide.plugins.services.IdeEnvironmentService
+import com.itsaky.androidide.plugins.services.IdeFileService
+import com.itsaky.androidide.plugins.services.IdeTemplateService
+
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.SupervisorJob
+import kotlinx.coroutines.cancel
+import kotlinx.coroutines.launch
+import android.util.Log
+import java.io.File
+
+
+class NdkInstallerPlugin : IPlugin {
+
+ private lateinit var context: PluginContext
+ private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
+ private var installJob: Job? = null
+ private var templateService: IdeTemplateService? = null
+
+ override fun initialize(context: PluginContext): Boolean {
+ this.context = context
+ templateService = context.services.get(IdeTemplateService::class.java)
+ Log.i(TAG, "NDK plugin initialized")
+ return true
+ }
+
+ override fun activate(): Boolean {
+ installJob = scope.launch { installNdk() }
+ registerNdkTemplate()
+ Log.i(TAG, "NDK plugin activated")
+ return true
+ }
+
+ override fun deactivate(): Boolean {
+ installJob?.cancel()
+ removeNdk()
+ templateService?.unregisterTemplate("NDK.cgt")
+ return true
+ }
+
+ override fun dispose() {
+ scope.cancel()
+ templateService = null
+ }
+
+ private fun installNdk() {
+ val env = context.services.get(IdeEnvironmentService::class.java)
+ ?: return fail("IdeEnvironmentService unavailable; plugin must declare ide.environment.write")
+ val archive = context.services.get(IdeArchiveService::class.java)
+ ?: return fail("IdeArchiveService unavailable")
+
+ val targetDir = File(env.getAndroidHomeDirectory().absolutePath /*, NDK_SUBDIR*/)
+
+ val source = context.resources.openPluginAsset(NDK_ARCHIVE_NAME)
+ ?: return fail("Bundled asset not found: $NDK_ARCHIVE_NAME (place it in src/main/assets/)")
+
+ context.logger.info("Installing NDK to ${targetDir.absolutePath}")
+ val result = source.use { stream ->
+ archive.extract(
+ source = stream,
+ format = ArchiveFormat.TAR_XZ,
+ destination = targetDir
+ ) { bytes, entry ->
+ val mib = bytes / MIB
+ val suffix = entry?.let { " ($it)" } ?: ""
+ context.logger.debug("extract progress: ${mib} MiB$suffix")
+ }
+ }
+
+ when (result) {
+ is ExtractResult.Success -> context.logger.info(
+ "NDK install complete: ${result.filesExtracted} files, ${result.bytesWritten / MIB} MiB"
+ )
+ is ExtractResult.Failure -> context.logger.error(
+ "NDK install failed: ${result.error.message}",
+ result.error
+ )
+ }
+ }
+
+ private fun removeNdk() {
+ val env = context.services.get(IdeEnvironmentService::class.java) ?: return
+ val file = context.services.get(IdeFileService::class.java) ?: return
+ val ndkDir = File(env.getAndroidHomeDirectory(), NDK_SUBDIR)
+ if (ndkDir.exists()) {
+ val deleted = file.delete(ndkDir)
+ context.logger.info("ndk removal from ${ndkDir.absolutePath}: $deleted")
+ }
+ val cmakeDir = File(env.getAndroidHomeDirectory(), CMAKE_SUBDIR)
+ if (cmakeDir.exists()) {
+ val deleted = file.delete(cmakeDir)
+ context.logger.info("cmake removal from ${cmakeDir.absolutePath}: $deleted")
+ }
+ }
+
+ private fun registerNdkTemplate() {
+ val service = templateService ?: return
+ val ctx = context ?: return
+
+ val ASSETS_NDK = "templates/ndk"
+
+ runCatching {
+ val cgt = service.createTemplateBuilder("NDK")
+ .description("An NDK and CMake binary installer with corresponding NDK Activity template")
+ .showPackageNameOption()
+
+ .showLanguageOption()
+ .showMinSdkOption()
+ .thumbnailFromAssets("$ASSETS_NDK/template/thumb.png", ctx)
+ .addStaticFromAssets("gradle.properties", "$ASSETS_NDK/gradle.properties", ctx)
+ .addStaticFromAssets("settings.gradle.kts.peb", "$ASSETS_NDK/settings.gradle.kts.peb", ctx)
+ .addStaticFromAssets(".gitignore", "$ASSETS_NDK/gitignore", ctx)
+ .addStaticFromAssets("gradlew", "$ASSETS_NDK/gradlew", ctx)
+ .addStaticFromAssets("gradle/wrapper/gradle-wrapper.jar", "$ASSETS_NDK/gradle/wrapper/gradle-wrapper.jar", ctx)
+ .addStaticFromAssets("gradle/wrapper/gradle-wrapper.properties.peb", "$ASSETS_NDK/gradle/wrapper/gradle-wrapper.properties.peb", ctx)
+ .addStaticFromAssets("app/src/main/cpp/native-lib.cpp.peb", "$ASSETS_NDK/app/src/main/cpp/native-lib.cpp.peb", ctx)
+ .addStaticFromAssets("app/src/main/cpp/CMakeLists.txt", "$ASSETS_NDK/app/src/main/cpp/CMakeLists.txt", ctx)
+ .addStaticFromAssets("app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb", "$ASSETS_NDK/app/src/main/java/PACKAGE_NAME/MainActivity.kt.peb", ctx)
+ .addStaticFromAssets("app/src/main/java/PACKAGE_NAME/MainActivity.java.peb", "$ASSETS_NDK/app/src/main/java/PACKAGE_NAME/MainActivity.java.peb", ctx)
+ .addStaticFromAssets("app/src/main/AndroidManifest.xml", "$ASSETS_NDK/app/src/main/AndroidManifest.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml", "$ASSETS_NDK/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp", "$ASSETS_NDK/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-xhdpi/ic_launcher.webp", "$ASSETS_NDK/app/src/main/res/mipmap-xhdpi/ic_launcher.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/xml/data_extraction_rules.xml", "$ASSETS_NDK/app/src/main/res/xml/data_extraction_rules.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/xml/backup_rules.xml", "$ASSETS_NDK/app/src/main/res/xml/backup_rules.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/values/themes.xml", "$ASSETS_NDK/app/src/main/res/values/themes.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/values/strings.xml.peb", "$ASSETS_NDK/app/src/main/res/values/strings.xml.peb", ctx)
+ .addStaticFromAssets("app/src/main/res/values/colors.xml", "$ASSETS_NDK/app/src/main/res/values/colors.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/values-night/themes.xml", "$ASSETS_NDK/app/src/main/res/values-night/themes.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/values-night/colors.xml", "$ASSETS_NDK/app/src/main/res/values-night/colors.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp", "$ASSETS_NDK/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-xxhdpi/ic_launcher.webp", "$ASSETS_NDK/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/layout/activity_main.xml", "$ASSETS_NDK/app/src/main/res/layout/activity_main.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp", "$ASSETS_NDK/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp", "$ASSETS_NDK/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/drawable/ic_launcher_background.xml", "$ASSETS_NDK/app/src/main/res/drawable/ic_launcher_background.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/drawable/ic_launcher_round.webp", "$ASSETS_NDK/app/src/main/res/drawable/ic_launcher_round.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-hdpi/ic_launcher_round.webp", "$ASSETS_NDK/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-hdpi/ic_launcher.webp", "$ASSETS_NDK/app/src/main/res/mipmap-hdpi/ic_launcher.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/drawable-v24/ic_launcher_foreground.xml", "$ASSETS_NDK/app/src/main/res/drawable-v24/ic_launcher_foreground.xml", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-mdpi/ic_launcher_round.webp", "$ASSETS_NDK/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp", ctx)
+ .addStaticFromAssets("app/src/main/res/mipmap-mdpi/ic_launcher.webp", "$ASSETS_NDK/app/src/main/res/mipmap-mdpi/ic_launcher.webp", ctx)
+ .addStaticFromAssets("app/.gitignore", "$ASSETS_NDK/app/gitignore", ctx)
+ .addStaticFromAssets("app/proguard-rules.pro", "$ASSETS_NDK/app/proguard-rules.pro", ctx)
+ .addStaticFromAssets("app/build.gradle.kts.peb", "$ASSETS_NDK/app/build.gradle.kts.peb", ctx)
+ .addStaticFromAssets("build.gradle.kts.peb", "$ASSETS_NDK/build.gradle.kts.peb", ctx)
+ .build(ctx.resources.getPluginDirectory())
+
+ service.registerTemplate(cgt)
+ Log.i(TAG, "Ndk template registered")
+
+ }.onFailure {
+ Log.e(TAG, "Failed to register Ndk template", it)
+ }
+ }
+
+ private fun fail(message: String) {
+ context.logger.error("NDK installer: $message")
+ }
+
+ private companion object {
+ const val NDK_ARCHIVE_NAME = "ndk-cmake.tar.xz"
+ const val CMAKE_SUBDIR = "cmake"
+ const val NDK_SUBDIR = "ndk"
+ const val MIB = 1024L * 1024L
+ const val TAG = "NdkInstallerPlugin"
+ }
+}
diff --git a/scripts/update-libs.sh b/scripts/update-libs.sh
index 42819bd6..dc617fa0 100755
--- a/scripts/update-libs.sh
+++ b/scripts/update-libs.sh
@@ -108,13 +108,19 @@ echo "Updated libs/ from CodeOnTheGo@$CODEONTHEGO_SHA"
printf " %-20s %s\n" "plugin-api.jar" "$(du -h "$LIBS_DIR/plugin-api.jar" | cut -f1)"
printf " %-20s %s\n" "gradle-plugin.jar" "$(du -h "$LIBS_DIR/gradle-plugin.jar" | cut -f1)"
-PLUGINS=(Beepy apk-viewer markdown-preview keystore-generator snippets)
+PLUGINS=(Beepy apk-viewer markdown-preview keystore-generator snippets ndk-installer-plugin)
echo ""
echo "Building all example plugins against the refreshed libs..."
for plugin in "${PLUGINS[@]}"; do
echo ""
echo "→ $plugin"
- (cd "$REPO_ROOT/$plugin" && ./gradlew --console=plain assemblePlugin)
+ (
+ cd "$REPO_ROOT/$plugin"
+ if [[ "$plugin" == "ndk-installer-plugin" ]]; then
+ ./gradlew --console=plain downloadAssets
+ fi
+ ./gradlew --console=plain assemblePlugin
+ )
done
echo ""
echo "All plugins built successfully."
\ No newline at end of file