Getting "A task was cancelled" error in Android Publisher v3
See original GitHub issueHello,
I’m facing a inconsistente problem. I have a CI to upload build on Google Play automatically, but on the last month I received the error “A task was cancelled” only a few times when I run the upload process.
But this problem is becoming more frequent, yesterday and today I’m always receiving this error message when try to run the upload proccess.
I tested this problem on isolated console application and received the same error.
Could you help me?
This is the code for run upload process. The BundleSettings, AndroidPublisherService and AppEdit don’t have any problem, the problem only occurs when I use the Upload method.
BundleSettings configs = BundleSettings.FromFilePath(configFilePath);
if (configs == null)
{
throw new Exception("Cannot load a valid BundleConfig");
}
//Create publisherService
var androidPublisherService = CreateGoogleConsoleAPIService(configs);
// Create a new edit to make changes to your listing.
var edit = CreateAnEditObject(androidPublisherService, configs);
UploadAabFile(configs, androidPublisherService, edit).Upload() ;
Used Methods
private static EditsResource.BundlesResource.UploadMediaUpload UploadAabFile(BundleSettings configs,
AndroidPublisherService androidPublisherService,
AppEdit edit)
{
Console.WriteLine("Upload started for aab: " + Path.GetFileName(configs.ApkPath));
var upload = androidPublisherService.Edits.Bundles.Upload(
configs.PackageName,
edit.Id,
new FileStream(configs.ApkPath, FileMode.Open),
"application/octet-stream"
);
return upload;
}
private static AppEdit CreateAnEditObject(AndroidPublisherService androidPublisherService,
BundleSettings configs)
{
var edit = androidPublisherService.Edits
.Insert(null /** no content */, configs.PackageName)
.Execute();
Console.WriteLine("Created edit with id: " +
edit.Id +
" (valid for " + edit.ExpiryTimeSeconds + " seconds)");
return edit;
}
private static AndroidPublisherService CreateGoogleConsoleAPIService(BundleSettings configs)
{
var cred = GoogleCredential.FromJson(File.ReadAllText(configs.JsonKeyPath));
cred = cred.CreateScoped(new[] {AndroidPublisherService.Scope.Androidpublisher});
// Create the AndroidPublisherService.
var androidPublisherService = new AndroidPublisherService(new BaseClientService.Initializer
{HttpClientInitializer = cred});
return androidPublisherService;
}
This is the result error
Unhandled exception. System.AggregateException: One or more errors occurred. (A task was canceled.)
—> System.Threading.Tasks.TaskCanceledException: A task was canceled.
— End of inner exception stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task
1.get_Result()
at Google.Apis.Upload.ResumableUpload.Upload()
at ConsoleGPlayAPITool.Program.Main(String[] args) in E:\DoubleDashStudios\Projetos\GooglePlayAPIConsoleUploader\ConsoleGPlayAPITool\Program.cs:line 35
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top GitHub Comments
I’m so glad! If that hadn’t been it, I’d have been a bit clueless as to what to do next!
Hello @jskeet,
I think that you are correct, I change the code to set 10 minutes of timeout and the problem apparently was solved. Thank you. 😃
Here has the code if someone needs.