2016-10-02 2 views
1

コードプッシュチュートリアルの複数配備テストによれば、Androidでは、デバッグビルドにステージングキーを設定し、リリースビルドにはプロダクションキーを設定する方法が説明されています。しかし、私はこれが不十分だと分かります、デバッグビルドは、リリースビルドと同じように実行されませんので、ステージングのために別のGradle buildTypeを作成する方がよいでしょうか? どこでも話している人がいませんか?何か不足していますか?コードプッシュ複数配備用のAndroidステージングビルドタイプ

答えて

2

ここではデバッグビルドとリリースと一緒に、私はステージングとライブ環境のための私のproductFlavorsbuildTypesを設定することになった方法は次のとおりです。

... 
defaultConfig { 
    applicationId "com.your.app.id" 
    minSdkVersion 16 
    targetSdkVersion 22 
    versionCode 5 
    versionName "1.5.0" 
    ndk { 
     abiFilters "armeabi-v7a", "x86" 
    } 
} 
buildTypes { 
    release { 
     signingConfig signingConfigs.release 
     minifyEnabled enableProguardInReleaseBuilds 
     proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 
    } 
    debug { 
     debuggable true 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 
     applicationIdSuffix ".debug" 
     buildConfigField "boolean", "DEBUG", "true" 
    } 
} 
productFlavors { 
    live { 
     buildConfigField('String', 'BUILD_ENV', '"live"') 
     resValue "string", "app_name", "Your App" 
     resValue "string", "reactNativeCodePush_androidDeploymentKey", "___YOUR_LIVE/PROD_KEY___" 
     manifestPlaceholders = [ 
      appIcon: "@mipmap/ic_launcher" 
     ] 
    } 
    staging { 
     buildConfigField('String', 'BUILD_ENV', '"staging"') 
     applicationId "$defaultConfig.applicationId" + ".staging" 
     resValue "string", "app_name", "Your App (Staging)" 
     resValue "string", "reactNativeCodePush_androidDeploymentKey", "___YOUR_STAGING_KEY___" 
     manifestPlaceholders = [ 
      appIcon: "@mipmap/ic_launcher_staging" 
     ] 
    } 
} 
.... 

そして、我々は我々のpackage.jsonに使用し、いくつかの対応のscrips:

... 
"dev-android": "node node_modules/react-native/local-cli/cli.js run-android --variant staging --configuration Debug", 
"dev-android-live": "node node_modules/react-native/local-cli/cli.js run-android --variant live --configuration Debug", 
"build-android": "cd android && ./gradlew assembleRelease", 
"deploy-android": "code-push release-react your-code-push-app-name android -d staging --noDuplicateReleaseError", 
... 

希望に役立ちます。

関連する問題