2016-10-02 3 views
1

코드 푸시 자습서의 다중 배치 테스트에 따르면 안드로이드에서 디버그 빌드에 스테이징 키를 설정하는 방법과 릴리스 빌드에서 프로덕션 키를 설정하는 방법이 설명되어 있습니다. 그러나 이것이 부족하다는 것을 알았습니다. 디버그 빌드는 릴리스 빌드와 같은 방식으로 실행되지 않으므로 준비를위한 다른 Gradle buildType을 만드는 것이 더 좋지 않을까요 ?? 어디서나이 이야기를하는 사람을 찾을 수 없습니까? 여기코드 푸시 다중 배포 용 안드로이드 준비 빌드 유형

답변

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" 
     ] 
    } 
} 
.... 

그리고 우리가 사용하는 일부 해당 scrips에 우리의 package.json :

... 
"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", 
... 

희망이 있습니다.