我在C#中有一个简单的工具,该工具使用Google.Apis.AndroidPublisher.v3 nuget包将应用部署到内部测试轨道,这是我自动构建的最后一步。从7月中旬我编写工具开始到9月中旬为止,它一直没有问题(最近成功执行:2018-09-17)。然后我好几个星期都没碰这个应用程序了。截至上周五(2018-09-28),该工具失败,并显示Google.GoogleApiException
,没有内部异常,消息
Google.Apis.Requests.RequestError
[500]
No individual errors
和堆栈跟踪
at Google.Apis.Requests.ClientServiceRequest`1.<ParseResponse>d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Google.Apis.Requests.ClientServiceRequest`1.Execute()
at MyProject.Tools.PlayStoreUploader.Program.Deploy(AndroidPublisherService service, String packageName, String releaseName, FileInfo apkFile, Int32 mainObbVersionCode, FileInfo patchObbFile, String releaseNotes) in C:\dev\MyProject\Tools\MyProject.Tools.PlayStoreUploader\Program.cs:line 211
at MyProject.Tools.PlayStoreUploader.Program.Main(String[] args) in C:\dev\MyProject\Tools\MyProject.Tools.PlayStoreUploader\Program.cs:line 126
基本上完成所有工作的Deploy
方法是
private static void Deploy(
AndroidPublisherService service,
string packageName,
string releaseName,
FileInfo apkFile,
int mainObbVersionCode,
FileInfo patchObbFile,
string releaseNotes)
{
var edits = service.Edits;
// Create a new edit
string editId = edits.Insert(null /* no body */, packageName).Execute().Id;
// Upload new apk
int apkVersion;
using (Stream strm = apkFile.OpenRead())
{
var uploadRequest = edits.Apks.Upload(packageName, editId, strm, MimeTypeApk);
uploadRequest.Upload();
apkVersion = uploadRequest.ResponseBody.VersionCode.Value;
}
// Attach an existing main obb
edits.Expansionfiles.Update(
new ExpansionFile { ReferencesVersion = mainObbVersionCode },
packageName,
editId,
apkVersion,
UpdateRequest.ExpansionFileTypeEnum.Main).
Execute();
// Attach a new patch file
if (patchObbFile != null)
{
using (Stream strm = patchObbFile.OpenRead())
{
edits.Expansionfiles.Upload(
packageName,
editId,
apkVersion,
// This Google API is clearly auto-generated by a badly written tool, because it duplicates the enums.
UploadMediaUpload.ExpansionFileTypeEnum.Patch,
strm,
MimeTypeObb).
Upload();
}
}
// Assign apk to "Internal test" track.
var release = new TrackRelease
{
Name = releaseName,
VersionCodes = new long?[] { apkVersion },
ReleaseNotes = new List<LocalizedText> { new LocalizedText { Language = "en", Text = releaseNotes } },
Status = TrackReleaseStatus.Completed
};
edits.Tracks.Update(
new Track { Releases = new List<TrackRelease> { release } },
packageName,
editId,
TrackIdentifier.Internal).
Execute();
// Publish
edits.Commit(packageName, editId).Execute();
}
相关常量是
const string MimeTypeApk = "application/vnd.android.package-archive";
const string MimeTypeObb = "application/octet-stream";
// As documented at https://developers.google.com/android-publisher/tracks
static class TrackIdentifier
{
public const string Alpha = "alpha";
public const string Beta = "beta";
public const string Internal = "internal";
public const string Production = "production";
}
// As (poorly) documented at https://developers.google.com/android-publisher/api-ref/edits/tracks#resource
// See also https://android-developers.googleblog.com/2018/06/automating-your-app-releases-with.html
static class TrackReleaseStatus
{
/// <summary>Not yet rolled out to anyone</summary>
public const string Draft = "draft";
/// <summary> For staged rollouts to a small percentage of users</summary>
public const string InProgress = "inProgress";
/// <summary> Suspends a staged rollout</summary>
public const string Halted = "halted";
/// <summary> Full rollout</summary>
public const string Completed = "completed";
}
在倒数第二行Deploy
,edits.Commit(packageName, editId).Execute();
中引发了异常。由于先前的调用成功,因此排除了身份验证失败的原因。 edits/commit的文档中列出的可能的故障原因为
- 打开此编辑后,您将为同一应用打开另一个编辑
- 打开您的编辑后,其他任何用户也会对该应用进行修改
- 您或任何其他用户在打开编辑状态时通过开发者控制台对应用进行更改
但我确定这些都不适用。
还有什么能解释为什么我可以设置修改,包括上传APK和OBB,但不提交呢?
答案 0 :(得分:1)
这听起来像是Play控制台中的错误,如500 error code所示,它表示“内部错误”。
当发生这种情况时,建议您与Play控制台支持联系,以使他们知道问题所在。您可以通过Play控制台中“?”后面的帮助菜单进行操作。 (问号)图标。