Skip to content

Instantly share code, notes, and snippets.

@AndrewJack
Created February 14, 2017 09:40
Show Gist options
  • Save AndrewJack/10dc22708582b009fb74f07904f3bfb1 to your computer and use it in GitHub Desktop.
Save AndrewJack/10dc22708582b009fb74f07904f3bfb1 to your computer and use it in GitHub Desktop.
React Native Android Library SDK Versions
subprojects {
ext {
compileSdk = 25
buildTools = "25.0.1"
minSdk = 19
targetSdk = 25
}
afterEvaluate { project ->
if (!project.name.equalsIgnoreCase("app")
&& project.hasProperty("android")) {
android {
compileSdkVersion compileSdk
buildToolsVersion buildTools
defaultConfig {
minSdkVersion minSdk
targetSdkVersion targetSdk
}
}
}
}
}
@rigdern
Copy link

rigdern commented May 4, 2017

@AndrewJack I have a question about a variation of this.

When creating a React Native module, it seems that it's recommended to list RN as a dependency like this:

dependencies {
    compile "com.facebook.react:react-native:+"  // From node_modules
}

(for an example see react-native-image-picker)

However, if your app is building RN from source, this should be changed to:

dependencies {
    compile project(':ReactAndroid')
}

If you don't do this, the module will be compiled against the wrong version of React Native.

For each of the app's dependencies, is there a way to transform the dependency compile "com.facebook.react:react-native:+" into compile project(':ReactAndroid') using gradle's subprojects feature?

@mo-solnet
Copy link

mo-solnet commented Sep 14, 2017

@AndrewJack Wow, thank you so much!
I can verify this works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment