electrode-io / electrode-native

A platform to ease integration&delivery of React Native apps in existing mobile applications
https://native.electrode.io
Other
726 stars 113 forks source link

Modify build.gradle to support some native modules #1198

Open silencedcoder opened 5 years ago

silencedcoder commented 5 years ago

I need to use react-native-image-crop-picker, @react-native-community/blur, but build.gradle needs some additional configuration. use react-native-image-crop-picker need add: image

use @react-native-community/blur need add: image

Can you add the modifications to build. gradle? Or there are other ways to support it. I need help,thanks a lot

belemaire commented 5 years ago

@silencedcoder Adding repositories is already supported through repositories plugin configuration directive. In the plugin configuration in manifest, in the android configuration section, you can add an array of repositories. For example :

{
  "android": {
    "repositories": [
      "https://jitpack.io",
      "https://maven.google.com"
    ]
  }
}

They will be properly injected in the Container repositories list in build.gradle. Don't add the first one though (the one pointing to file location) as we are injecting react native from maven central, not local file path. That being said you shouldn't need to add these repos because every Container are using the following repositories by default :

google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }

For your second request, to be able to add elements to the android defaultConfig of the Android Container, this is not yet supported through plugin configuration, we will look into a way to add support for it, probably in upcoming 0.35 release.

As a workaround, while waiting for a more proper solution, you can rely on the replaceInFile plugin directive to inject these elements in the build.gradle defaultConfig object of the Container.

As an example, you can see here how it's done : https://github.com/electrode-io/electrode-native-manifest/pull/115

This way you could search for defaultConfig { in Container build.gradle and replace it with something like defaultConfig { \n renderscriptTargetApi 23 \n renderscriptSupportModeEnabled true \n for example.