java - 如何通过 Android Publisher Java API v2 将 obb 文件上传到 Google Play

标签 java upload google-play-developer-api

我以 GitHub 为例. 它工作正常,但我需要用我的 apk 上传 obb 文件。

我的部分代码:

        AndroidPublisher.Edits.Insert editRequest = edits.insert(bundleID, null);
        AppEdit edit = editRequest.execute();
        final String editId = edit.getId();
        final AbstractInputStreamContent apkFile = new FileContent("application/vnd.android.package-archive", new File(apkPath));

        AndroidPublisher.Edits.Apks.Upload uploadRequest = edits.apks().upload(bundleID, editId, apkFile);

        Apk apk = uploadRequest.execute();

        List<Integer> apkVersionCodes = new ArrayList<>();
        apkVersionCodes.add(apk.getVersionCode());
        AndroidPublisher.Edits.Tracks.Update updateTrackRequest = edits.tracks().update(bundleID, editId, TRACK_ALPHA, new Track().setVersionCodes(apkVersionCodes));
        updateTrackRequest.execute();
        // Commit changes for edit.
        AndroidPublisher.Edits.Commit commitRequest = edits.commit(bundleID, editId);
        commitRequest.execute();

我该怎么做?

最佳答案

要上传新的扩展文件并将其与 APK 相关联:

String expansionFileType = "main"; // either "main" or "patch"
FileContent file = new FileContent("application/octet-stream", new File(path));
edits.expansionfiles().upload(appId, editId, versionCode, expansionFileType, file).execute();

如果您想将现有的扩展文件与 APK 相关联:

String expansionFileType = "main";
int previousVersionCode = // find the version code here
ExpansionFile obbFile = new ExpansionFile().setReferencesVersion(previousVersionCode);
edits.expansionfiles().update(appId, editId, versionCode, expansionFileType, obbFile).execute();

关于java - 如何通过 Android Publisher Java API v2 将 obb 文件上传到 Google Play,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35629725/

相关文章:

android - 如何为我的应用程序启用谷歌服务

java - 我需要一个正则表达式来匹配 puppet 事实

java - 在单元测试期间填充 Spring @Value

java - Minecraft Forge - 通过 setBlockState 放置时方 block 消失

java - 使用接受文件的 Spring Controller 防止内存不足错误

python - 使用 python 为 Google Play Developer API 使用 oauth2 授权服务帐户

java - 在 tomcat 6 中部署 spring 应用程序时出现 "Access is denied"消息

asp.net - 带预览的多个文件上传

iphone 图像到 Ruby on Rails - 内容主体错误,parse_multipart

android - 如何知道从 Play 商店安装的应用程序是否使用了我的 Android 应用程序