提交 a9b64acd authored 作者: vipcxj's avatar vipcxj

add: 热更新支持

上级 95015694
差异被折叠。
...@@ -94,6 +94,8 @@ def enableSeparateBuildPerCPUArchitecture = false ...@@ -94,6 +94,8 @@ def enableSeparateBuildPerCPUArchitecture = false
*/ */
def enableProguardInReleaseBuilds = false def enableProguardInReleaseBuilds = false
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
android { android {
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion "25.0.3" buildToolsVersion "25.0.3"
...@@ -109,6 +111,23 @@ android { ...@@ -109,6 +111,23 @@ android {
abiFilters "armeabi-v7a", "x86" abiFilters "armeabi-v7a", "x86"
} }
} }
productFlavors {
dev {
minSdkVersion 21
}
prod {
minSdkVersion 16
}
}
dexOptions {
javaMaxHeapSize "2G"
}
releaseStaging {
buildConfigField "String", "CODEPUSH_KEY", '"' + properties.getProperty("code_push.key_staging") + '"'
}
release {
buildConfigField "String", "CODEPUSH_KEY", '"' + properties.getProperty("code_push.key_production") + '"'
}
signingConfigs { signingConfigs {
release { release {
storeFile file("app.jks") storeFile file("app.jks")
......
D4OD3'd9
\ No newline at end of file
...@@ -34,7 +34,7 @@ public class MainApplication extends Application implements ReactApplication { ...@@ -34,7 +34,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList( return Arrays.<ReactPackage>asList(
new MainReactPackage(), new MainReactPackage(),
new CodePush(null, getApplicationContext(), BuildConfig.DEBUG), new CodePush(BuildConfig.CODEPUSH_KEY, getApplicationContext(), BuildConfig.DEBUG),
new RNDeviceInfo(), new RNDeviceInfo(),
new IDCardReactPackage() new IDCardReactPackage()
); );
......
...@@ -18,4 +18,6 @@ ...@@ -18,4 +18,6 @@
# org.gradle.parallel=true # org.gradle.parallel=true
android.useDeprecatedNdk=true android.useDeprecatedNdk=true
org.gradle.jvmargs=-Xmx4G org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx3G
...@@ -9,3 +9,5 @@ ...@@ -9,3 +9,5 @@
# header note. # header note.
#Wed Sep 27 15:26:11 CST 2017 #Wed Sep 27 15:26:11 CST 2017
sdk.dir=/Users/yaohx_169/Library/Android/sdk sdk.dir=/Users/yaohx_169/Library/Android/sdk
code_push.key_production=1jJDUki8dREADfZnMQWgjrk02K1Q4ksvOXqog
code_push.key_staging=09Bbn7Y3d8WBtouy9x5JxTjVvZgI4ksvOXqog
...@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react'; ...@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import { BackHandler, Animated, Easing } from 'react-native'; import { BackHandler, Animated, Easing } from 'react-native';
import { StackNavigator, addNavigationHelpers, NavigationActions } from 'react-navigation'; import { StackNavigator, addNavigationHelpers, NavigationActions } from 'react-navigation';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import codePush from 'react-native-code-push';
import NavigatorService from './services/navigator'; import NavigatorService from './services/navigator';
import Welcome from './routes/welcome'; import Welcome from './routes/welcome';
import Error from './routes/error'; import Error from './routes/error';
...@@ -66,6 +67,11 @@ class Router extends PureComponent { ...@@ -66,6 +67,11 @@ class Router extends PureComponent {
BackHandler.addEventListener('hardwareBackPress', this.backHandle); BackHandler.addEventListener('hardwareBackPress', this.backHandle);
} }
componentDidMount() {
codePush.sync();
}
componentWillUnmount() { componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.backHandle); BackHandler.removeEventListener('hardwareBackPress', this.backHandle);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论