apply plugin:"com.android.application"import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
apply from:"../../node_modules/react-native/react.gradle"
apply from:"../../node_modules/react-native-code-push/android/codepush.gradle"/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture =false
def releaseTime(){returnnewDate().format("yyyyMMdd", TimeZone.getTimeZone("UTC"))}/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds =false
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
aaptOptions.cruncherEnabled =false
aaptOptions.useNewCruncher =false
defaultConfig {
flavorDimensions "default"
applicationId "com.hurong.hry79428579"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
manifestPlaceholders =[
QQ_APPID :"1106835601",
JPUSH_APPKEY:"1152b0f91db40ba476c2dffe",
APP_CHANNEL :"developer-default"]
ndk {
abiFilters "armeabi-v7a","x86"}}//多渠道打包
productFlavors {//名信贷渠道
mxd {//修改包名
applicationId "com.hurong.hry79428579"//修改app名字,string资源下不能包含"app_name"
resValue "string","app_name","名信贷"//修改AndroidManifest.xml部分字段(包含logo)
manifestPlaceholders =[CHANNEL_VALUE:"mxd",app_icon:"@mipmap/logo"]}//贷回家渠道
dhj {
applicationId "com.hurong.hry84050011"
resValue "string","app_name","贷回家"//修改AndroidManifest.xml部分字段(包含logo)
manifestPlaceholders =[CHANNEL_VALUE:"dhj",app_icon:"@mipmap/logo"]}}//简写方式// productFlavors {// baidu {}// xiaomi {}// }// productFlavors.all {// flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]// }
dexOptions {
preDexLibraries =false}
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}}
splits {
abi {reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false// If true, also generate a universal APK
include "armeabi-v7a","x86"}}
buildTypes {
release {// minifyEnabled enableProguardInReleaseBuilds
signingConfig signingConfigs.release
// proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"//原先打包输出apk方式
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName ="${variant.productFlavors[0].name}_1zy_v${variant.versionName}_${releaseTime()}.apk"}}}
debug {
signingConfig signingConfigs.release
}}// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->// For each separate APK per architecture, set a unique version code as described here:// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes =["armeabi-v7a":1,"x86":2]
def abi = output.getFilter(OutputFile.ABI)if(abi != null){// null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi)*1048576+ defaultConfig.versionCode
}}}
packagingOptions {
exclude 'lib*//*//*libMegviiInnerUtils-0.0.2.so'}}
dependencies {
compile project(':react-native-fs')
compile project(':react-native-pdf')
compile project(':rn-fetch-blob')
compile project(':react-native-code-push')
compile project(':react-native-restart')
compile project(':react-native-image-crop-picker')
compile project(':react-native-exception-handler')
compile project(':react-native-splash-screen')
compile project(':react-native-vector-icons')
compile project(':react-native-touch-id')
compile project(':react-native-picker')
compile project(':react-native-linear-gradient')
compile project(':react-native-image-picker')
compile project(':react-native-device-info')
compile fileTree(include:['*.jar'], dir:'libs')//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:23.0.1'//compile "com.facebook.react:react-native:+"compile('com.facebook.react:react-native:0.46.0'){ force =true}// From node_modulescompile(name:'moxie-client-2.4.4', ext:'aar')
compile 'com.android.support.constraint:constraint-layout:1.1.3'compile(name:'idauthsdk', ext:'aar')
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.5'
compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.3@aar'}// Run this once to be able to run the application with BUCK// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy){
from configurations.compile
into 'libs'}
<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"package="com.hurong.kh"><uses-permissionandroid:name="android.permission.RECEIVE_SMS"/><uses-permissionandroid:name="android.permission.READ_SMS"/><uses-permissionandroid:name="android.permission.INTERNET"/><uses-permissionandroid:name="android.permission.CAMERA"/><uses-permissionandroid:name="android.permission.GET_ACCOUNTS"/><uses-permissionandroid:name="android.permission.BLUETOOTH"/><!-- for Device Name --><uses-permissionandroid:name="android.permission.READ_PHONE_STATE"/><!-- for Phone Number --><uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permissionandroid:name="android.permission.SYSTEM_ALERT_WINDOW"/><uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE"/><uses-permissionandroid:name="android.permission.ACCESS_WIFI_STATE"/><uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION"/><uses-permissionandroid:name="android.permission.CHANGE_WIFI_STATE"/><uses-permissionandroid:name="com.android.launcher.permission.READ_SETTINGS"/><uses-permissionandroid:name="android.permission.READ_CONTACTS"/><uses-permissionandroid:name="ndroid.permission.CALL_PHONE"/><uses-featureandroid:name="android.hardware.camera"/><uses-featureandroid:name="android.hardware.camera.autofocus"/><uses-featureandroid:name="android.hardware.camera.flash"/><uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION"/><uses-permissionandroid:name="android.permission.READ_EXTERNAL_STORAGE"/><uses-permissionandroid:name="android.permission.VIBRATE"/><applicationandroid:name="com.hurong.kh.MainApplication"android:allowBackup="true"android:icon="${app_icon}"android:label="@string/app_name"android:theme="@style/AppTheme"tools:replace="android:theme"><activityandroid:name="com.hurong.kh.MainActivity"android:configChanges="keyboard|keyboardHidden|orientation|screenSize"android:label="@string/app_name"android:windowSoftInputMode="adjustResize"><intent-filter><actionandroid:name="android.intent.action.MAIN"/><categoryandroid:name="android.intent.category.LAUNCHER"/></intent-filter></activity><activityandroid:name="com.facebook.react.devsupport.DevSettingsActivity"/><serviceandroid:name="com.moxie.client.accessible.AccessibleCrawlerService"android:accessibilityFlags="flagReportViewIds"android:enabled="true"android:exported="true"android:label="@string/accessibility_name"android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"><intent-filter><actionandroid:name="android.accessibilityservice.AccessibilityService"/></intent-filter><meta-dataandroid:name="android.accessibilityservice"android:resource="@xml/accessible_crawler_config"/></service><!--解决react-native在小米8出现黑边或者透明边--><meta-dataandroid:name="android.max_aspect"android:value="2.1"/></application></manifest>
gradlew assembleRelease 打的是所有配置好的渠道包 gradlew assemble渠道名Release 打的是指定渠道包 gradlew assembleMxdRelease
打包指定的渠道名大小写无所谓