Skip to content
This repository was archived by the owner on Oct 20, 2020. It is now read-only.

Commit bd09672

Browse files
committed
Re-init example project for RN 29.2
1 parent 11234e8 commit bd09672

21 files changed

Lines changed: 250 additions & 236 deletions

example/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

example/.flowconfig

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,58 @@
11
[ignore]
22

33
# We fork some components by platform.
4-
.*/*.web.js
54
.*/*.android.js
65

7-
# Some modules have their own node_modules with overlap
8-
.*/node_modules/node-haste/.*
6+
# Ignore templates with `@flow` in header
7+
.*/local-cli/generator.*
98

10-
# Ugh
11-
.*/node_modules/babel.*
12-
.*/node_modules/babylon.*
13-
.*/node_modules/invariant.*
9+
# Ignore malformed json
10+
.*/node_modules/y18n/test/.*\.json
1411

15-
# Ignore react and fbjs where there are overlaps, but don't ignore
16-
# anything that react-native relies on
17-
.*/node_modules/fbjs/lib/Map.js
18-
.*/node_modules/fbjs/lib/Promise.js
19-
.*/node_modules/fbjs/lib/fetch.js
20-
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
21-
.*/node_modules/fbjs/lib/isEmpty.js
22-
.*/node_modules/fbjs/lib/crc32.js
23-
.*/node_modules/fbjs/lib/ErrorUtils.js
12+
# Ignore the website subdir
13+
<PROJECT_ROOT>/website/.*
2414

25-
# Flow has a built-in definition for the 'react' module which we prefer to use
26-
# over the currently-untyped source
27-
.*/node_modules/react/react.js
28-
.*/node_modules/react/lib/React.js
29-
.*/node_modules/react/lib/ReactDOM.js
15+
# Ignore BUCK generated dirs
16+
<PROJECT_ROOT>/\.buckd/
3017

31-
# Ignore commoner tests
32-
.*/node_modules/commoner/test/.*
18+
# Ignore unexpected extra @providesModule
19+
.*/node_modules/commoner/test/source/widget/share.js
3320

34-
# See https://github.com/facebook/flow/issues/442
35-
.*/react-tools/node_modules/commoner/lib/reader.js
36-
37-
# Ignore jest
38-
.*/node_modules/jest-cli/.*
39-
40-
# Ignore Website
41-
.*/website/.*
21+
# Ignore duplicate module providers
22+
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
23+
.*/Libraries/react-native/React.js
24+
.*/Libraries/react-native/ReactNative.js
25+
.*/node_modules/jest-runtime/build/__tests__/.*
4226

4327
[include]
4428

4529
[libs]
4630
node_modules/react-native/Libraries/react-native/react-native-interface.js
31+
node_modules/react-native/flow
32+
flow/
4733

4834
[options]
4935
module.system=haste
5036

37+
esproposal.class_static_fields=enable
38+
esproposal.class_instance_fields=enable
39+
40+
experimental.strict_type_args=true
41+
5142
munge_underscores=true
5243

5344
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
54-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
45+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
5546

5647
suppress_type=$FlowIssue
5748
suppress_type=$FlowFixMe
5849
suppress_type=$FixMe
5950

60-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
61-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-9]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-9]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
6253
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
6354

55+
unsafe.enable_getters_and_setters=true
56+
6457
[version]
65-
0.20.1
58+
^0.29.0

example/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ project.xcworkspace
2424

2525
# Android/IJ
2626
#
27+
*.iml
2728
.idea
2829
.gradle
2930
local.properties
@@ -32,3 +33,9 @@ local.properties
3233
#
3334
node_modules/
3435
npm-debug.log
36+
37+
# BUCK
38+
buck-out/
39+
\.buckd/
40+
android/app/libs
41+
android/keystores/debug.keystore

example/android/app/BUCK

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import re
2+
3+
# To learn about Buck see [Docs](https://buckbuild.com/).
4+
# To run your application with Buck:
5+
# - install Buck
6+
# - `npm start` - to start the packager
7+
# - `cd android`
8+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
9+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
10+
# - `buck install -r android/app` - compile, install and run application
11+
#
12+
13+
lib_deps = []
14+
for jarfile in glob(['libs/*.jar']):
15+
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
16+
lib_deps.append(':' + name)
17+
prebuilt_jar(
18+
name = name,
19+
binary_jar = jarfile,
20+
)
21+
22+
for aarfile in glob(['libs/*.aar']):
23+
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
24+
lib_deps.append(':' + name)
25+
android_prebuilt_aar(
26+
name = name,
27+
aar = aarfile,
28+
)
29+
30+
android_library(
31+
name = 'all-libs',
32+
exported_deps = lib_deps
33+
)
34+
35+
android_library(
36+
name = 'app-code',
37+
srcs = glob([
38+
'src/main/java/**/*.java',
39+
]),
40+
deps = [
41+
':all-libs',
42+
':build_config',
43+
':res',
44+
],
45+
)
46+
47+
android_build_config(
48+
name = 'build_config',
49+
package = 'com.example',
50+
)
51+
52+
android_resource(
53+
name = 'res',
54+
res = 'src/main/res',
55+
package = 'com.example',
56+
)
57+
58+
android_binary(
59+
name = 'app',
60+
package_type = 'debug',
61+
manifest = 'src/main/AndroidManifest.xml',
62+
keystore = '//android/keystores:debug',
63+
deps = [
64+
':app-code',
65+
],
66+
)

example/android/app/build.gradle

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ apply plugin: "com.android.application"
33
import com.android.build.OutputFile
44

55
/**
6-
* The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets.
6+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7+
* and bundleReleaseJsAndAssets).
78
* These basically call `react-native bundle` with the correct arguments during the Android build
89
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
910
* bundle directly from the development server. Below you can see all the possible configurations
1011
* and their defaults. If you decide to add a configuration block, make sure to add it before the
11-
* `apply from: "react.gradle"` line.
12+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
1213
*
1314
* project.ext.react = [
1415
* // the name of the generated asset file containing your JS bundle
@@ -23,6 +24,15 @@ import com.android.build.OutputFile
2324
* // whether to bundle JS and assets in release mode
2425
* bundleInRelease: true,
2526
*
27+
* // whether to bundle JS and assets in another build variant (if configured).
28+
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29+
* // The configuration property can be in the following formats
30+
* // 'bundleIn${productFlavor}${buildType}'
31+
* // 'bundleIn${buildType}'
32+
* // bundleInFreeDebug: true,
33+
* // bundleInPaidRelease: true,
34+
* // bundleInBeta: true,
35+
*
2636
* // the root of your project, i.e. where "package.json" lives
2737
* root: "../../",
2838
*
@@ -45,15 +55,20 @@ import com.android.build.OutputFile
4555
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
4656
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
4757
* // for example, you might want to remove it from here.
48-
* inputExcludes: ["android/**", "ios/**"]
58+
* inputExcludes: ["android/**", "ios/**"],
59+
*
60+
* // override which node gets called and with what additional arguments
61+
* nodeExecutableAndArgs: ["node"]
62+
*
63+
* // supply additional arguments to the packager
64+
* extraPackagerArgs: []
4965
* ]
5066
*/
5167

52-
apply from: "react.gradle"
68+
apply from: "../../node_modules/react-native/react.gradle"
5369

5470
/**
55-
* Set this to true to create three separate APKs instead of one:
56-
* - A universal APK that works on all devices
71+
* Set this to true to create two separate APKs instead of one:
5772
* - An APK that only works on ARM devices
5873
* - An APK that only works on x86 devices
5974
* The advantage is the size of the APK is reduced by about 4MB.
@@ -83,9 +98,9 @@ android {
8398
}
8499
splits {
85100
abi {
86-
enable enableSeparateBuildPerCPUArchitecture
87-
universalApk true
88101
reset()
102+
enable enableSeparateBuildPerCPUArchitecture
103+
universalApk false // If true, also generate a universal APK
89104
include "armeabi-v7a", "x86"
90105
}
91106
}
@@ -114,5 +129,12 @@ dependencies {
114129
compile project(':react-native-billing')
115130
compile fileTree(dir: "libs", include: ["*.jar"])
116131
compile "com.android.support:appcompat-v7:23.0.1"
117-
compile "com.facebook.react:react-native:0.18.+"
132+
compile "com.facebook.react:react-native:+" // From node_modules
133+
}
134+
135+
// Run this once to be able to run the application with BUCK
136+
// puts all compile dependencies into folder libs for BUCK to use
137+
task copyDownloadableDepsToLibs(type: Copy) {
138+
from configurations.compile
139+
into 'libs'
118140
}

example/android/app/proguard-rules.pro

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@
2626
# See http://sourceforge.net/p/proguard/bugs/466/
2727
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
2828
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29+
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
2930

3031
# Do not strip any method/class that is annotated with @DoNotStrip
3132
-keep @com.facebook.proguard.annotations.DoNotStrip class *
33+
-keep @com.facebook.common.internal.DoNotStrip class *
3234
-keepclassmembers class * {
3335
@com.facebook.proguard.annotations.DoNotStrip *;
36+
@com.facebook.common.internal.DoNotStrip *;
3437
}
3538

3639
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
@@ -42,26 +45,22 @@
4245
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
4346
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
4447
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
45-
-keepclassmembers class * { @com.facebook.react.uimanager.ReactProp <methods>; }
46-
-keepclassmembers class * { @com.facebook.react.uimanager.ReactPropGroup <methods>; }
48+
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
49+
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
4750

4851
-dontwarn com.facebook.react.**
4952

5053
# okhttp
5154

5255
-keepattributes Signature
5356
-keepattributes *Annotation*
54-
-keep class com.squareup.okhttp.** { *; }
55-
-keep interface com.squareup.okhttp.** { *; }
56-
-dontwarn com.squareup.okhttp.**
57+
-keep class okhttp3.** { *; }
58+
-keep interface okhttp3.** { *; }
59+
-dontwarn okhttp3.**
5760

5861
# okio
5962

6063
-keep class sun.misc.Unsafe { *; }
6164
-dontwarn java.nio.file.*
6265
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
6366
-dontwarn okio.**
64-
65-
# stetho
66-
67-
-dontwarn com.facebook.stetho.**

0 commit comments

Comments
 (0)