{"id":13471825,"url":"https://github.com/invertase/react-native-gradle-plugin","last_synced_at":"2025-06-10T13:34:53.779Z","repository":{"id":55110912,"uuid":"165285914","full_name":"invertase/react-native-gradle-plugin","owner":"invertase","description":"A gradle plugin for React Native Android that simplifies and standardises build configurations (such as dependency versioning) for Projects \u0026 React Native modules.","archived":false,"fork":false,"pushed_at":"2022-12-20T10:05:46.000Z","size":94,"stargazers_count":64,"open_issues_count":2,"forks_count":8,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-23T21:49:44.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/invertase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-11T17:52:21.000Z","updated_at":"2024-07-31T15:24:53.000Z","dependencies_parsed_at":"2023-01-30T00:16:03.794Z","dependency_job_id":null,"html_url":"https://github.com/invertase/react-native-gradle-plugin","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invertase%2Freact-native-gradle-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invertase%2Freact-native-gradle-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invertase%2Freact-native-gradle-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invertase%2Freact-native-gradle-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/invertase","download_url":"https://codeload.github.com/invertase/react-native-gradle-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invertase%2Freact-native-gradle-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259085402,"owners_count":22803192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-07-31T16:00:49.585Z","updated_at":"2025-06-10T13:34:53.745Z","avatar_url":"https://github.com/invertase.png","language":"Groovy","funding_links":["https://opencollective.com/react-native-firebase"],"categories":["Groovy"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://invertase.io\"\u003e\n    \u003cimg src=\"https://static.invertase.io/assets/invertase-logo-small.png\"\u003e\u003cbr/\u003e\n  \u003c/a\u003e\n  \u003ch2 align=\"center\"\u003eReact Native Gradle Plugin\u003c/h2\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/@invertase/puppeteer-pool.svg?style=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://discord.gg/C9aK28N\"\u003e\u003cimg src=\"https://img.shields.io/discord/295953187817521152.svg?logo=discord\u0026style=flat-square\u0026colorA=7289da\u0026label=discord\" alt=\"Chat\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/invertaseio\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/invertaseio.svg?style=social\u0026label=Follow\" alt=\"Follow on Twitter\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n----\n\nA gradle plugin for React Native Android that simplifies and standardises build configurations (including versioning) for both Projects \u0026 React Native modules.\n\n#### Current Features\n\n - Android app / React Native module auto-versioning using the version defined in your `package.json`\n - Standardise overriding android/gradle/tools SDK versions of React Native Modules\n - Standardise overriding dependency versions of React Native Modules, e.g. Firebase Android SDKs\n - Built-in inspections (warning logs \u0026 suggested solutions) for common build mistakes/errors, e.g. `duplicate dex`\n\n## Installation\n\nAdd the plugin to your `build.gradle`;\n\n**Groovy**:\n```groovy\nplugins {\n  id \"io.invertase.gradle.build\" version \"1.3\"\n}\n```\n\n**Kotlin**:\n```kotlin\nplugins {\n  id(\"io.invertase.gradle.build\") version \"1.3\"\n}\n```\n\nThis must be added after your `buildscript` block.\n\n## Usage\n\n### For Projects \u0026 React Native Modules\n\n#### Versioning Overrides\n\nAdd a versions configuration to your app build gradle, for example; \n\n```groovy\nproject.ext {\n  set('react-native', [\n    versions: [\n      // Android version section can be automatically applied by calling \n      // ReactNative.module.applyAndroidVersions()\n      //    or\n      // ReactNative.project.applyAndroidVersions()\n      // android version section supports legacy behavior e.g.:\n      //    project.ext.compileSdkVersion\n      android           : [\n        minSdk    : 16,\n        targetSdk : 28,\n        compileSdk: 28,\n        // optional as gradle.buildTools comes with one by default\n        // buildTools: \"28.0.3\"\n      ],\n\n      googlePlayServices: [\n        base: \"16.0.1\",\n        // additional version sub sections as defined by native module authors\n        // e.g maps:\n        maps: \"16.0.1\",\n      ],\n\n      // additional version sections can be defined by\n      // native module authors, e.g. React Native Firebase:\n      firebase          : [\n        functions: \"16.1.3\"\n      ],\n    ],\n  ])\n}\n```\n\nThese additionally form the default versions when used in a react native module. \n\n**Example: Using a version**\n\n```groovy\ndependencies {\n  api project(':@react-native-firebase/app')\n  // getVersion() first looks for the overridden version defined in the consumers project\n  // if non is found; it falls back to the default version defined in the React Native modules' build.gradle, as above\n  implementation \"com.google.firebase:firebase-functions:${ReactNative.ext.getVersion(\"firebase\", \"functions\")}\"\n  implementation \"com.google.android.gms:play-services-base:${ReactNative.ext.getVersion(\"googlePlayServices\", \"base\")}\"\n}\n```\n\n---\n\n#### Android build versioning using `package.json` version\n\nAndroid builds can specify a build code and version name, e.g.:\n\n```groovy\nandroid {\n  defaultConfig {\n    versionCode 1\n    versionName \"1.0\"\n  }\n}\n```\n\nUpdating this every time you need to publish your app can be avoided by having it default to using the \nversion defined in your projects `package.json` file, the process is explained [here](https://medium.com/@andr3wjack/versioning-react-native-apps-407469707661) \nin-depth by @AndrewJack.\n\nThis can be automated with this gradle plugin by adding the following to your app (or RN module) `build.gradle`:\n\n```groovy\nReactNative.shared.applyPackageVersion()\n```\n\n---\n\n#### Excluding common META-INF files\n\n`META-INF` files can cause `'duplicate file'` build failures if they're not excluded, this plugin allows excluding the \nmost common types of these files by adding  the following to your app (or RN module) `build.gradle`:  \n\n\n```groovy\nReactNative.shared.applyDefaultExcludes()\n```\n\nFor reference this will inject the following config:\n\n```groovy\nandroid {\n  packagingOptions {\n    exclude 'META-INF/-no-jdk.kotlin_module'\n    exclude 'META-INF/DEPENDENCIES'\n    exclude 'META-INF/NOTICE'\n    exclude 'META-INF/LICENSE'\n    exclude 'META-INF/LICENSE.txt'\n    exclude 'META-INF/NOTICE.txt'\n  }\n}\n```\n\n---\n\n### For React Native Modules\n\n#### Auto apply Android SDK versions\n\n```groovy\nReactNative.module.applyAndroidVersions()\n```\n\nThis will apply the default versions or the user overridden versions of the android SDK versions specified in `react-native -\u003e versions -\u003e android { }`.\n\nThis removes the need for the following (that most RN modules are currently doing):\n\n```groovy\nandroid {\n  compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION\n  buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION\n  defaultConfig {\n    minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION\n    targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION\n  }\n}\n```\n\n`applyAndroidVersions()` is backwards compatible with the old format as above and internally checks for these as well as the new format.\n\n---\n\n#### Auto locate and add React Native as a dependency\n\nThis adds the React Native custom maven repository like normal, but; with support for various scenarios whilst developing your android module locally without an app;\n\n - automatically finds the right location of `node_modules/react-android` when opening your React Native Android module standalone in Android Studio\n - mono-repo support for the above, e.g. React Native at the root package as a dev dependency\n - specifying an exact location via options (`reactNativeAndroidDir`) - useful when testing your module against a fork of React Native located outside of your project or building React Native from sources\n\n```groovy\n// accepts \"api\" or \"implementation\" as dependency type arg\nReactNative.module.applyReactNativeDependency(\"api\")\n```\n\n**Example: Specify exact location via options**:\n\n```groovy\nproject.ext {\n  set('react-native', [\n    // ... other configs e.g. versions\n    options: [\n      reactNativeAndroidDir: \"/../../../../my-react-native-fork/android\"\n    ]\n  ])\n}\n```\n\n---\n\n## Planned Features\n\n - Support for injecting Java constants (`buildConfigField`) into your app from a JS script, `package.json` or `app.json`\n - Support for injecting Android Resources (resValue) into app from a JS script, `package.json` or `app.json`\n\n## React Native modules using this plugin\n\n - [React Native Firebase](https://github.com/invertase/react-native-firebase)\n\n*Submit a PR to add your React Native module(s) here.*\n\n## License\n\n- See [LICENSE](/LICENSE)\n\n----\n\nBuilt and maintained with 💛 by [Invertase](https://invertase.io). \n\n- [💼 Hire Us](https://invertase.io/hire-us)\n- [☕️ Sponsor Us](https://opencollective.com/react-native-firebase)\n- [👩‍💻 Work With Us](https://invertase.io/jobs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvertase%2Freact-native-gradle-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finvertase%2Freact-native-gradle-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvertase%2Freact-native-gradle-plugin/lists"}