Skip to content

Commit

Permalink
Support Project-Wide Gradle Config and bump version to 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tolu360 committed Apr 5, 2018
1 parent 28e3c3c commit 0f85285
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 21 deletions.
50 changes: 45 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ iOS/Android Google Places Widgets (Autocomplete, Place Picker) and API Services
<img width=200 title="Place Picker Open - iOS" src="./shots/picker-ios.png">

## Versioning:
- for RN >= 0.40.0, use v2+ (e.g. react-native-google-places@2.4.0)
- for RN (0.33.0 - 0.39.0), use v1+ or 0.8.8 (e.g. [email protected])
- for RN >= 0.40.0, use v2+ (e.g. react-native-google-places@2.5.0)
- for RN (0.33.0 - 0.39.0), use v1+ or 0.8.8 (e.g. [email protected]) **No longer updated**

## Sample App
- A new [sample app](https://github.com/tolu360/TestRNGP) is available to help with sample usage and debugging issues.
Expand Down Expand Up @@ -106,6 +106,46 @@ dependencies {
compile project(':react-native-google-places')
}
```
- Option 1: Use Project-Wide Gradle Config:

You can define *[project-wide properties](https://developer.android.com/studio/build/gradle-tips.html)* (**recommended**) in your root `/android/build.gradle`, and let the library auto-detect the presence of the following properties:

```groovy
buildscript {...}
allprojects {...}
/**
+ Project-wide Gradle configuration properties (replace versions as appropriate)
*/
ext {
compileSdkVersion = 25
targetSdkVersion = 25
buildToolsVersion = "25.0.2"
supportLibVersion = "25.0.2"
googlePlayServicesVersion = "11.6.2"
androidMapsUtilsVersion = "0.5+"
}
```

- Option 2: Use Specific Gradle Config:

If you do **not** have *project-wide properties* defined or want to use a different Google Play-Services version than the one included in this library (shown above), use the following instead (switch 11.6.2 for the desired version):

```groovy
...
dependencies {
...
compile(project(':react-native-google-places')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-places'
exclude group: 'com.google.android.gms', module: 'play-services-location'
}
compile 'com.google.android.gms:play-services-base:11.6.2'
compile 'com.google.android.gms:play-services-places:11.6.2'
compile 'com.google.android.gms:play-services-location:11.6.2'
}
```

- Add the following in your `...MainApplication.java` file:

```java
Expand Down Expand Up @@ -425,9 +465,9 @@ You have to link dependencies and re-run the build:
exclude group: 'com.google.android.gms', module: 'play-services-places'
exclude group: 'com.google.android.gms', module: 'play-services-location'
}
compile 'com.google.android.gms:play-services-base:10.2.0'
compile 'com.google.android.gms:play-services-places:10.2.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.android.gms:play-services-base:11.6.2'
compile 'com.google.android.gms:play-services-places:11.6.2'
compile 'com.google.android.gms:play-services-location:11.6.2'
}
```

Expand Down
48 changes: 33 additions & 15 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION = 25
def DEFAULT_BUILD_TOOLS_VERSION = "25.0.2"
def DEFAULT_TARGET_SDK_VERSION = 25
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "11.6.2"
def DEFAULT_ANDROID_MAPS_UTILS_VERSION = "0.5+"

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}

lintOptions {
disable 'InvalidPackage'
}
}

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.google.android.gms:play-services-base:10.2.4'
compile 'com.google.android.gms:play-services-places:10.2.4'
compile 'com.google.android.gms:play-services-location:10.2.4'
compile 'com.google.maps.android:android-maps-utils:0.3.4'
def googlePlayServicesVersion = rootProject.hasProperty('googlePlayServicesVersion') ? rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
def androidMapsUtilsVersion = rootProject.hasProperty('androidMapsUtilsVersion') ? rootProject.androidMapsUtilsVersion : DEFAULT_ANDROID_MAPS_UTILS_VERSION

provided "com.facebook.react:react-native:+"
compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
compile "com.google.android.gms:play-services-places:$googlePlayServicesVersion"
compile "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
compile "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "iOS/Android Google Places Widgets (Autocomplete, Place Picker) and API Services for React Native Apps",
"main": "index.js",
"author": "Tolu Olowu (Arttitude 360) <[email protected]>",
"version": "2.4.8",
"version": "2.5.0",
"scripts": {},
"repository": {
"type": "git",
Expand Down

0 comments on commit 0f85285

Please sign in to comment.