Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Deploy no Android

Continuous Deploy no Android

Júlio Zynger

April 12, 2016
Tweet

More Decks by Júlio Zynger

Other Decks in Programming

Transcript

  1. Google Developer Console Habilitar a Google Play Android Developer API

    * * crie um projeto no developer console se já não houver um com APIs configuradas * painel Visão Geral do console https://console.developers.google.com/apis
  2. Google Developer Console Obtendo a service account key * painel

    Credenciais do console https://console.developers.google.com/apis
  3. Google Play Developer API * • Subscriptions and In-App Purchases

    API ◦ In-App Products ◦ Status de produtos comprados ◦ Produtos recorrentes e subscriptions • Publishing API ◦ Criação e modificação dos Listings de seu app ◦ Upload de novas versões do APK ◦ Atribuição de APKs às Tracks do Google Play (alpha, beta, staged rollout e produção) * Limite de 200 mil requisições por dia
  4. Configurando a dependência Instanciando o GoogleCredential NetHttpTransport http = GoogleNetHttpTransport.newTrustedTransport();

    JacksonFactory json = JacksonFactory.getDefaultInstance(); Set<String> scopes = Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER); File secretFile = new File(Constants.SECRET_FILE_PATH); GoogleCredential credential = new GoogleCredential.Builder(). setTransport(http). setJsonFactory(json). setServiceAccountPrivateKeyId(Constants.KEY_ID). setServiceAccountId(Constants.SERVICE_ACCOUNT_EMAIL). setServiceAccountScopes(scopes). setServiceAccountPrivateKeyFromPemFile(secretFile). build(); https://developers.google.com/android-publisher/#publishing
  5. Configurando a dependência Instanciando o GoogleCredential NetHttpTransport http = GoogleNetHttpTransport.newTrustedTransport();

    JacksonFactory json = JacksonFactory.getDefaultInstance(); Set<String> scopes = Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER); File secretFile = new File(Constants.SECRET_FILE_PATH); GoogleCredential credential = new GoogleCredential.Builder(). setTransport(http). setJsonFactory(json). setServiceAccountPrivateKeyId(Constants.KEY_ID). setServiceAccountId(Constants.SERVICE_ACCOUNT_EMAIL). setServiceAccountScopes(scopes). setServiceAccountPrivateKeyFromPemFile(secretFile). build(); https://developers.google.com/android-publisher/#publishing setServiceAccountPrivateKeyId(Constants.KEY_ID). setServiceAccountId(Constants.SERVICE_ACCOUNT_EMAIL). setServiceAccountPrivateKeyFromPemFile(secretFile). private_key_id client_email private_key (.pem)
  6. Configurando a dependência Instanciando o AndroidPublisher NetHttpTransport http = GoogleNetHttpTransport.newTrustedTransport();

    JacksonFactory json = JacksonFactory.getDefaultInstance(); GoogleCredential credential = ... AndroidPublisher publisher = new AndroidPublisher.Builder(http, json, credential). setApplicationName(PACKAGE). build(); https://developers.google.com/android-publisher/#publishing
  7. Configurando a dependência AppEdits AndroidPublisher publisher = ... Edits edits

    = publisher.edits(); // insert, get, delete AppEdit appEdit = edits.insert(PACKAGE, null).execute(); String transactionId = appEdit.getId(); ... ... https://developers.google.com/android-publisher/#publishing
  8. Configurando a dependência AppEdits - validate e commit AndroidPublisher publisher

    = ... Edits edits = publisher.edits(); // insert, get, delete AppEdit appEdit = edits.insert(PACKAGE, null).execute(); String transactionId = appEdit.getId(); ... ... edits.validate(PACKAGE, transactionId).execute(); edits.commit(PACKAGE, transactionId).execute(); https://developers.google.com/android-publisher/#publishing
  9. Configurando a dependência AppEdits - validate e commit AndroidPublisher publisher

    = ... Edits edits = publisher.edits(); // insert, get, delete AppEdit appEdit = edits.insert(PACKAGE, null).execute(); String transactionId = appEdit.getId(); ... ... edits.validate(PACKAGE, transactionId).execute(); edits.commit(PACKAGE, transactionId).execute(); https://developers.google.com/android-publisher/#publishing { "code" : 403, "errors" : [ { "domain" : "androidpublisher", "message" : "The full description for the app is too long for language en-US.", "reason" : "fullDescriptionTooLong" } ], "message" : "The full description for the app is too long for language en-US." }
  10. Configurando a dependência AppEdits - Listings Edits edits = publisher.edits();

    Listings listings = edits.listings(); ListingsListResponse listingsListResponse = listings.list(PACKAGE, transactionId).execute(); // Selecionar o Listing que vai ser atualizado Listing listing = listingsListResponse.getListings().get(...) listing.setFullDescription(description); listings.update(PACKAGE, transactionId, language, listing).execute(); // ... validate // ... commit https://developers.google.com/android-publisher/#publishing
  11. Configurando a dependência AppEdits - Listings Edits edits = publisher.edits();

    Listings listings = edits.listings(); ListingsListResponse listingsListResponse = listings.list(PACKAGE, transactionId).execute(); // Selecionar o Listing que vai ser atualizado Listing listing = listingsListResponse.getListings().get(...) listing.setFullDescription(description); listings.update(PACKAGE, transactionId, language, listing).execute(); // ... validate // ... commit https://developers.google.com/android-publisher/#publishing { "fullDescription" : "This app is a simple demo application for developers who are interested in continuous deploy in the android platform.", "language" : "en-US", "shortDescription" : "Demo application for developers", "title" : "Continuous Deploy Demo App", "video" : "" }
  12. Configurando a dependência AppEdits - upload do APK Apks apks

    = edits.apks(); FileContent apkContent = new FileContent(APK_MIME_TYPE, apkFile); Apk apk = apks.upload(PACKAGE, transactionId, apkContent).execute(); int version = apk.getVersionCode(); https://developers.google.com/android-publisher/#publishing
  13. Configurando a dependência AppEdits - Tracks Apks apks = edits.apks();

    FileContent apkContent = new FileContent(APK_MIME_TYPE, apkFile); Apk apk = apks.upload(PACKAGE, transactionId, apkContent).execute(); int version = apk.getVersionCode(); Tracks tracks = edits.tracks(); List<Integer> versions = Collections.singletonList(version); Track track = new Track().setVersionCodes(versions); tracks.update(PACKAGE, transactionId, trackId, track).execute(); https://developers.google.com/android-publisher/#publishing
  14. Configurando a dependência AppEdits - Tracks Apks apks = edits.apks();

    FileContent apkContent = new FileContent(APK_MIME_TYPE, apkFile); Apk apk = apks.upload(PACKAGE, transactionId, apkContent).execute(); int version = apk.getVersionCode(); Tracks tracks = edits.tracks(); List<Integer> versions = Collections.singletonList(version); Track track = new Track().setVersionCodes(versions); tracks.update(PACKAGE, transactionId, trackId, track).execute(); https://developers.google.com/android-publisher/#publishing “alpha”, “beta”, “rollout” (com userFraction), “production”
  15. Configurando a dependência AppEdits - APKListings Apks apks = edits.apks();

    FileContent apkContent = new FileContent(APK_MIME_TYPE, apkFile); Apk apk = apks.upload(PACKAGE, transactionId, apkContent).execute(); int version = apk.getVersionCode(); Tracks tracks = edits.tracks(); List<Integer> versions = Collections.singletonList(version); Track track = new Track().setVersionCodes(versions); tracks.update(PACKAGE, transactionId, trackId, track).execute(); Apklistings apklistings = edits.apklistings(); ApkListing whatsnew = new ApkListing().setRecentChanges(whatsNewDescription); apklistings.update(PACKAGE, transactionId, version, language, whatsnew).execute(); https://developers.google.com/android-publisher/#publishing