Android - 是否可以通过Google Developer API推广到测试版?

时间:2015-06-02 08:28:35

标签: android google-api

目前,如果我想将我的Android应用从Alpha推广到Beta,我会在Google Developer Console中进行推广。 我正在尝试使用Google API的C#客户端自动执行此过程。可能吗?如果是这样,我很乐意看到代码示例。 谢谢!

1 个答案:

答案 0 :(得分:1)

我会根据我在这里得到的答案回答自己:https://github.com/googlesamples/android-play-publisher-api/issues/20#issuecomment-107923343

这样的事情对我有用:

        var service = new AndroidPublisherService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential
        });

        // Insert new edit
        var edit = new AppEdit()
        {
            ExpiryTimeSeconds = ToEpochTime(DateTime.UtcNow.AddMinutes(30)).ToString()
        };
        edit = service.Edits.Insert(edit, packageName).Execute();

        // Fetching the Alpha track and clearing the version code from it
        var tracks = service.Edits.Tracks.List(packageName, edit.Id).Execute().Tracks;
        var alphaTrack = tracks.Single(track => track.TrackValue.Equals(EditsResource.TestersResource.GetRequest.TrackEnum.Alpha.ToString(), StringComparison.InvariantCultureIgnoreCase));
        var versionCode = alphaTrack.VersionCodes.Single();
        alphaTrack.VersionCodes.Clear();
        service.Edits.Tracks.Patch(alphaTrack, packageName, edit.Id, EditsResource.TracksResource.PatchRequest.TrackEnum.Alpha).Execute();

        // Updating a Beta track with the same version code as in the Alpha track
        var betaTrack = new Track {TrackValue = "beta", VersionCodes = new [] { versionCode }};
        service.Edits.Tracks.Update(betaTrack, packageName, edit.Id, EditsResource.TracksResource.UpdateRequest.TrackEnum.Beta).Execute();

        // Commit the edit
        service.Edits.Commit(packageName, edit.Id).Execute();