Skip to content

Commit

Permalink
Fix Gradle setup in android folder (facebookarchive#670)
Browse files Browse the repository at this point in the history
Project now opens and builds correctly in Android Studio and from
command line.
  • Loading branch information
friederbluemle authored and janicduplessis committed Nov 9, 2019
1 parent bdc283d commit cfee77a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 73 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
Expand All @@ -29,12 +28,12 @@ build/
.gradle
local.properties
*.iml

# Cocoapods
#
Pods/
android/gradle/
android/gradlew
android/gradlew.bat

# node.js
#
node_modules/
npm-debug.log
yarn-error.log
21 changes: 0 additions & 21 deletions android/android.iml

This file was deleted.

69 changes: 40 additions & 29 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,45 +1,56 @@
apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 28
def DEFAULT_FACEBOOK_SDK_VERSION = "[5.0,6.0["
buildscript {
if (project == rootProject) {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
}

def FACEBOOK_SDK_VERSION = safeExtGet('facebookSdkVersion', DEFAULT_FACEBOOK_SDK_VERSION)
android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
apply plugin: 'com.android.library'

android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
lintOptions {
abortOnError false
}
}

repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// Android JSC is installed from npm
url "$rootDir/../node_modules/jsc-android/dist"
}
google()
jcenter()
}

def FACEBOOK_SDK_VERSION = safeExtGet('facebookSdkVersion', '[5.0,6.0[')

dependencies {
implementation "androidx.appcompat:appcompat:1.0.+"
api 'com.facebook.react:react-native:+'
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.facebook.android:facebook-core:${FACEBOOK_SDK_VERSION}"
implementation "com.facebook.android:facebook-login:${FACEBOOK_SDK_VERSION}"
implementation "com.facebook.android:facebook-share:${FACEBOOK_SDK_VERSION}"
}

repositories {
mavenCentral()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
13 changes: 0 additions & 13 deletions android/proguard-rules.pro

This file was deleted.

3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest
package="com.facebook.reactnative.androidsdk">
<application />
</manifest>
3 changes: 0 additions & 3 deletions android/src/main/res/values/strings.xml

This file was deleted.

3 changes: 3 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ debug.keystore

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/

0 comments on commit cfee77a

Please sign in to comment.