{"id":43077702,"url":"https://github.com/polymonster/premake-android-studio","last_synced_at":"2026-01-31T14:12:09.945Z","repository":{"id":43460371,"uuid":"146991046","full_name":"polymonster/premake-android-studio","owner":"polymonster","description":"premake5 module for android-studio and gradle build.","archived":false,"fork":false,"pushed_at":"2025-12-10T21:21:35.000Z","size":1595,"stargazers_count":36,"open_issues_count":2,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-12-11T08:43:47.211Z","etag":null,"topics":["android-sdk","android-studio","gradle-build","jni","ndk","premake","premake-module"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polymonster.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-09-01T10:59:26.000Z","updated_at":"2025-12-10T21:21:39.000Z","dependencies_parsed_at":"2024-05-15T23:30:59.734Z","dependency_job_id":"267e5dec-96cf-406f-b98b-374d1614db18","html_url":"https://github.com/polymonster/premake-android-studio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/polymonster/premake-android-studio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polymonster%2Fpremake-android-studio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polymonster%2Fpremake-android-studio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polymonster%2Fpremake-android-studio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polymonster%2Fpremake-android-studio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polymonster","download_url":"https://codeload.github.com/polymonster/premake-android-studio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polymonster%2Fpremake-android-studio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28944837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T13:02:32.153Z","status":"ssl_error","status_checked_at":"2026-01-31T13:00:07.528Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-sdk","android-studio","gradle-build","jni","ndk","premake","premake-module"],"created_at":"2026-01-31T14:12:09.204Z","updated_at":"2026-01-31T14:12:09.937Z","avatar_url":"https://github.com/polymonster.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# premake-android-studio \r\n[![Build Status](https://github.com/polymonster/premake-android-studio/workflows/ci/badge.svg)](https://github.com/polymonster/premake-android-studio/actions)\r\n\r\nIf you are using premake as your build configuration system for Visual Studio, XCode or GNU Make and wanted to easily integrate Android into your development work flow, this module will abstract the convoluted world of gradle, sdk and ndk.\r\n\r\nTo find out how to use premake modules you can check the reference [here](https://github.com/premake/premake-core/wiki/Using-Modules), You can find the premake-core repository [here](https://github.com/premake/premake-core) and the latest premake executables [here](https://premake.github.io/download/). \r\n\r\nIn addition to generating Android Studio friendly build.gradle files you can also build from the command line using gradle build.\r\n\r\n*****\r\n\r\n## Usage\r\n```bash\r\npremake5 android-studio\r\n```\r\n\r\n*****\r\n\r\n## Android specific premake extensions\r\n```lua\r\nandroidabis { \"armeabi\", \"armeabi-v7a\", \"arm64-v8a\", \"x86\", \"x86_64\" }\r\n\r\n-- sdk / gradle version\r\ngradleversion \"com.android.tools.build:gradle:3.1.4\"\r\nandroidsdkversion \"28\"\r\nandroidminsdkversion \"25\"\r\nandroidndkversion \"26.2.11394342\"\r\nandroidndkpath \"file_path_to_ndk_directory_is_optional\"\r\nandroidappid \"com.company.application\"\r\nandroidnamespace \"com.company.application\"\r\n\r\n-- extra build settings to apply to each config (config scope)\r\nandroidbuildsettings\r\n{\r\n    \"firebaseCrashlytics { nativeSymbolUploadEnabled true }\"\r\n}\r\n\r\n-- plugins to apply (project scope)\r\nandroidplugins\r\n{\r\n    \"com.google.gms.google-services\"\r\n}\r\n\r\n-- gradle properties (workspace scope)\r\ngradleproperties\r\n{\r\n    \"org.gradle.jvmargs=-Xmx4608m\",\r\n    \"org.gradle.parallel=true\"\r\n}\r\n\r\n-- gradle wrapper (workspace scope)\r\n-- generates the file build/android/gradle/wrapper/gradle-wrapper.properties\r\ngradlewrapper \r\n{\r\n    \"distributionUrl=https://services.gradle.org/distributions/gradle-7.1-bin.zip\"\r\n}\r\n\r\n-- repositories (workspace scope)\r\n--\r\n-- if left empty then default google() and jcenter() repositories will be supplied\r\n-- otherwise, only the repository entries listed will be supplied\r\nandroidrepositories\r\n{\r\n    \"jcenter()\",\r\n    \"maven { url 'http://maven.gameanalytics.com/release' }\"\r\n}\r\n\r\n-- asset packs (workspace scope)\r\nassetpacks\r\n{\r\n    [\"asset_pack_name\"] = \"install-time\" -- supported values are \"fast-follow\", \"on-demand\", \"install-time\"\r\n    [\"another_pack_name\"] = \"on-demand\"\r\n}\r\n\r\n-- files, dependencies, directories (project scope)\r\n--\r\n-- starting an entry with 'implementation' keyword will result in the entry string being copied over raw\r\n-- if 'implementation' is not specified at the start then it will be implicitly added as well as the quotes\r\n-- the raw string method can be used to add more complex dependencies, e.g. fileTree(), files(), etc. \r\nandroiddependencies\r\n{\r\n    \"implementation platform('com.google.firebase:firebase-bom:29.0.0')\",\r\n    \"com.android.support:appcompat-v7:+\",\r\n    \"com.android.support:support-v4:25.0.0\",\r\n    \"com.android.support:design:25.0.0\"\r\n}\r\n\r\n-- files, dependencies, diretories (workspace scope)\r\nandroiddependenciesworkspace\r\n{\r\n    \"com.google.gms:google-services:4.3.10\"\r\n}\r\n\r\n-- cross project dependencies \r\nandroidprojectdependencies \r\n{ \r\n    \"SubModuleA\", \r\n    \"SubModuleB\" \r\n}\r\n\r\n-- asset pack dependencies (project scope)\r\nassetpackdependencies\r\n{\r\n    \"asset_pack_name\",\r\n    \"another_pack_name\"\r\n}\r\n\r\narchivedirs\r\n{\r\n    \"path/to/jar/\",\r\n    \"path/to/aar/\"\r\n}\r\n\r\nassetdirs\r\n{\r\n    \"path/to/assets\" -- these will go into android asset manager and inside .pkg\r\n}\r\n\r\nandroiduselegacypackaging \"false\" -- legacy packaging option (true/false)\r\n\r\n-- signing\r\nandroidkeystorefile \"keystore.jks\"\r\nandroidstorepassword \"K3yStorePa55w0rd\"\r\nandroidkeyalias \"Product Key\"\r\nandroidkeypassword \"Pr0ductK3yPa$$word\"\r\n\r\n-- version info\r\nandroidversioncode \"1\"\r\nandroidversionname \"1.0\"\r\n\r\n-- Relative path to export the APK\r\napkoutputpath \"./../../../../../builds\"\r\n\r\n-- Relative path to export the AAR\r\naaroutputpath \"./../../../../libs\"\r\n\r\n-- run configuration module name\r\n-- the name of the module that will be run when running/debugging in Android Studio\r\n-- should be provided along with \"runconfigoptions\" to ensure run configuration targets correct module\r\nrunconfigmodule \"module\"\r\n\r\n-- run configuration options\r\n-- key value pairs for the run configuration options, will be written to xml in \u003cbuild\u003e/.idea/runConfigurations\r\n-- { 'DEPLOY_APK_FROM_BUNDLE, 'true' } when using \"assetpacks\" ensures app is launched in the correct asset bundle mode\r\nrunconfigoptions \r\n{\r\n    { 'DEPLOY', 'true' },\r\n    { 'DEPLOY_APK_FROM_BUNDLE', 'true' },\r\n    { 'DEPLOY_AS_INSTANT', 'false' }\r\n}\r\n\r\n-- Custom CMake arguments injection\r\nandroidcmake\r\n{\r\n    '# setup: treat warnings as errors',\r\n    'set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wall -Werror\")'\r\n}\r\n\r\n-- Android automation test instrumentation runner support \r\nandroidtestrunner \"androidx.test.runner.AndroidJUnitRunner\"\r\n\r\n```\r\n\r\n*****\r\n\r\n## Custom build commands\r\n\r\npremake [custom build commands](https://premake.github.io/docs/Custom-Build-Commands/) are partially supported through the gradle [exec](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html) task. Currently you can only apply `prebuildcommand` and `postbuildcommands`. Gradle exec is a bit strange so you need to separate all arguments by commas and wrap them in quotes. \r\n\r\nHere is a small example using `cp` to copy a file using a string with double quotes `\"` and wrapping the args in single quotes `'` with args separated by commas `,`. You can supply multiple post build commands which will be executed in order.\r\n\r\n```lua\r\npostbuildcommands {\r\n    \"'cp', 'a.txt', 'b.txt'\",\r\n    \"'echo', 'hello world!'\"\r\n}\r\n```\r\n\r\n## Android specific premake considerations\r\n\r\nYou can use CMake variables injected specifically for android from within the premake script to make life easier to handle multiple abis and so forth.\r\n\r\n```lua\r\nlibdirs\r\n{\r\n    \"path/to/libs/${ANDROID_ABI}/\"\r\n}\r\n```\r\n\r\nFind a full list of CMake Android variables [here](https://gist.github.com/nddrylliog/4774829)\r\n\r\nTo link and .aar (Android Archive) or .jar (Java Archive) simply add them to links along with their extension:\r\n\r\n```lua\r\nlinks\r\n{\r\n    \"android_archive.aar\",\r\n    \"java_archive.jar\"\r\n}\r\n```\r\n\r\nTo add a directory to search for .aar or .jar files add these to archivedirs:\r\n\r\n```lua\r\narchivedirs\r\n{\r\n    \"path/to/aar_libs\"\r\n}\r\n```\r\n\r\nWhen adding .java files for the android project please note that only directories and not single files can be added to the project, by adding a directory it's entire subtree is also added (ie. \"dir/\\*\\*.\\*), this means if a directory contains non java files they will still be added to the java source set. The simplest way to avoid adding files to the wrong category is to put all java files inside their own directory:\r\n\r\n```lua\r\nfiles\r\n{\r\n    \"src/java/**.java\"\r\n}\r\n```\r\n\r\nResource files such as images and layouts must all be included from a sub directory named \"res\":\r\n\r\n```lua\r\nfiles\r\n{\r\n    \"src/res/**.*\"\r\n}\r\n```\r\n\r\nAndroidManifest.xml is required for all projects, if one does not exist a simple stub will be auto generated, if an AndroidManifest.xml is specified inside premake files then this one will be used instead:\r\n\r\n```lua\r\nfiles\r\n{\r\n    \"src/manifest/AndroidManifest.xml\"\r\n}\r\n```\r\n\r\nGoogle-services.json is required for Google Firebase features, if google-services.json is specified inside premake files, then this one will be COPIED into the root of a project so the google services plugin can preprocess it:\r\n\r\n```lua\r\nfiles\r\n{\r\n    \"src/google-services.json\"\r\n}\r\n```\r\n\r\nThe module will dected files types based on extensions and add them into the appropriate categories:\r\n\r\n```txt\r\nNative (.c, .h, .cpp, .hpp)\r\nJava (.java)\r\nResource (.xml, .png)\r\nManifest (AndoridManifest.xml)\r\n\r\nNative files are added to cmake lists.\r\nJava, Resource and Manifest files are added to the gradle project.\r\n```\r\n\r\n## Automation support \r\nAndroid's UIAutomation2 framework requires the project to setup the `testInstrumentationRunner` and to add the required dependencies.\r\nThe module will automatically inject the `androidTest.java.srcDirs` to discover your tests.\r\n\r\nThis is an example of how to enable UIAutomation support for your project (addapt to your needs):\r\n\r\n```lua\r\nandroidtestrunner \"androidx.test.runner.AndroidJUnitRunner\"\r\n\r\n androiddependencies \r\n{\r\n    \"junit:junit:4.12\",\r\n    \"androidx.test:runner:1.4.0\",\r\n    \"androidx.test:rules:1.4.0\",\r\n    \"androidx.test.uiautomator:uiautomator:2.2.0\",\r\n}\r\n```\r\n\r\n## Asset Packs\r\nIf you want to use asset packs to publish to google play store and avoid the 150mb limit, you can simply use the 'assetpacks' key-value list to register asset packs. This will create a folder and the required metadata. Asset packs must be declared at workspace scope and included in a project via the `assetpackdependencies` string list at project scope. The asset pack directory will be created inside the top level gradle directory (workspace.location) from there it is up to you to copy your assets into the correct subdirectory\r\n`asset_pack_directory/src/main/assets`\r\n\r\n*****\r\n\r\n## JNI\r\n\r\nTo call c++ from a Java file you must use jni (java native interface). This process requires importing a c or c++ lib from java, defining a function call and implementing the c or c++ function with the correct function name for java to find the exported function.\r\n\r\nJava:\r\n```java\r\npackage com.as.example;\r\n\r\nimport android.app.Activity;\r\nimport android.os.Bundle;\r\nimport android.util.Log;\r\n\r\npublic class main_activity extends Activity\r\n{\r\n\tpublic static native int hello_cpp(); // declare c or c++ function (synonymous with c's extern)\r\n\r\n\tstatic \r\n\t{\r\n\t\tSystem.loadLibrary(\"android_studio_example\"); // load c or c++ lib\r\n\t}\r\n\r\n\t@Override\r\n\tprotected void onCreate(Bundle arg0) \r\n\t{\r\n\t\tLog.d(\"Hello world!\", \"I'm Java\");\r\n\r\n\t\thello_cpp(); // call c or c++ function \r\n\r\n\t\tsuper.onCreate(arg0);\r\n\t}\r\n}\r\n```\r\n\r\nC/C++\r\n```c\r\nextern \"C\"\r\nJNIEXPORT void JNICALL Java_com_as_example_main_1activity_hello_1cpp(void* args)\r\n{\r\n    __android_log_write(ANDROID_LOG_INFO, \"CPP\", \"oh hai!, I'm c++\");\r\n}\r\n```\r\n\r\nNaming convention for exported functions available to java is as follows:  \r\n\r\nJava_ \u003cpackage_name_separated_by_underscores\u003e function_name\r\n\r\nIf an underscore is used in the function name this is replaced with \"_1\"\r\n\r\nso for package com.as.example function hello_cpp becomes Java_com_as_example_main_1activity_hello_1cpp\r\n\r\n*****\r\n\r\n## Example\r\n\r\nAn example program is included for testing and reference purposes, it features a main activity, a java entry point and a jni call to native c++ code.\r\n\r\nThe premake5 executable provided in this repository is for linux, if you want to build for another platform change this exectuable.\r\n\r\nTo run the example:\r\n```bash\r\ncd example\r\n../premake5 android-studio\r\n```\r\n\r\nOpen the folder example/build with Android Studio then sync gradle, build and run. Android Studio will manage any gradle, sdk or ndk dependencies for you. \r\n\r\nOutput from run should contain:\r\n```bash\r\nD/Hello world!: I'm Java\r\nI/CPP: oh hai!, I'm c++\r\n```\r\n\r\nYou can alternatively build from the commandline with the following, provided you have installed the Android sdk, ndk and gradle:\r\n```bash\r\ncd example/build\r\ngradle build\r\n```\r\n\r\nTo run the example on Linux or Windows add your premake5 executable to this directory and follow the above steps.\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolymonster%2Fpremake-android-studio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolymonster%2Fpremake-android-studio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolymonster%2Fpremake-android-studio/lists"}