问题描述
如何使用 Google Play 应用程序包中的 Java 按需加载 Android 资产包?
我尝试在 AssetPackManager 中传递参数并对其进行硬编码。
我认为我的问题与不了解界面有关。
一些链接
https://developer.android.com/guide/playcore/asset-delivery/integrate-java
Play Core Java API 提供了 AssetPackManager 类来请求资源包,
管理下载和访问资产。
您可以根据要访问的资产包的交付类型实施此 API。
我的资产包 (SongsNW) 结构与应用程序处于同一级别的缩进
app // my app
src
main
java
AndroidManifest.xml
build.gradle
我的应用级 build.gradle(上面)列出了我的 AssetPacks
android {
other {
...
}
dynamicFeatures = [':....X',':SongsNW',':.....Y',':.....Z']
}
dependencies {
....
}
我的资产包 (SongsNW)
SongsNW
src
main
assets
NW folder with assets
AndroidManifest.xml
build.gradle
我的 AndroidManifest.xml(在上面的 SongsNW 下)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.companyname.songsnw">
<dist:module
dist:instant="false"
dist:title="@string/title_songsnw">
<dist:delivery>
<dist:on-demand/>
</dist:delivery>
<dist:fusing dist:include="false" />
</dist:module>
</manifest>
我的 build.gradle(在上面的 SongsNW 下)
apply plugin: 'com.android.asset-pack'
assetPack {
packName = "SongsNW" // Directory name for the asset pack
dynamicDelivery {
deliveryType = "on-demand"
}
}
LoadAssetPack.java(模块)
package com.companyname.appname;
import android.util.Log;
import com.google.android.play.core.assetpacks.AssetPackLocation;
import com.google.android.play.core.assetpacks.AssetPackState;
import com.google.android.play.core.assetpacks.AssetPackStates;
import com.google.android.play.core.tasks.OnCompleteListener;
import com.google.android.play.core.tasks.RuntimeExecutionException;
import com.google.android.play.core.tasks.Task;
import static android.content.ContentValues.TAG;
interface AssetPackManager {
// I am passing the assetPackName to here with this call:
// AssetPackLocation assetPackLocation = AssetPackManager.getPackLocation("SongsNW");
public static final String TAG = "LoadAssetPack";
public static final String assetPackName = "";
// public static final String assetPackName = "SongsNW";
public static final AssetPackLocation assetPacklocation = null;
public static final AssetPackLocation assetPackLocation = getPackLocation(assetPackName);
public static AssetPackLocation getPackLocation(String assetPackName) {
Log.d(TAG,"in AssetPackManager assetPackName:" + assetPackName);
AssetPackLocation assetPackLocation = getPackLocation(assetPackName);
Log.d(TAG,"assetPackName:" + assetPackName + " assetPackLocation: " + assetPackLocation );
return assetPackLocation; // null if it isn't complete
}
// I need to run the following list,but first I need to understand what I am doing wrong.
AssetPackStates cancel (List<String> packNames)
Task<AssetPackStates> fetch (List<String> packNames)
Task<AssetPackStates> getPackStates (List<String> packNames)
void registerListener (AssetPackStateUpdateListener listener)
Task<Void> removePack (String packName)
Task<Integer> showCellularDataConfirmation (Activity activity)
void unregisterListener (AssetPackStateUpdateListener listener)
}
这不是上述问题的答案,但我相信它更好地定义了问题。
首先能看到原错误信息。
增加 Android Studio Logcat 缓冲区大小以容纳 16384 KB(默认 1024 KB)
文件 > 设置 > 编辑器 > 常规 > 控制台 > 覆盖控制台循环缓冲区大小。
然后您可以在顶部看到错误。
Logcat 中的消息:
I/系统服务器:InitBeforeStartServices
W/YouTube:在批量初始化结束之前获取 Gservices 键“disable_binder_callback_flush”
W/Primes:Primes 未初始化,返回默认(无操作)Primes 实例,该实例将忽略所有调用。
请在使用任何 Primes API 之前调用 Primes.initialize(...)。
谷歌上述错误提供:
Play 服务尝试进行身份验证,过早关闭配置文件弹出窗口,失败 #2362
https://github.com/playgameservices/play-games-plugin-for-unity/issues/2362
在以下评论中,他们讨论的是 Google Play 服务。
... Web 客户端 ID 是正确的方法。一旦我正确配置了它,它就成功了。不直观的部分是redirect_uri。对于因为 Google Api 控制台不是超级直观而遇到相同问题的任何人:在凭据部分中,在 Oauth 同意屏幕选项卡下,底部是“授权域”部分。要添加授权域,您需要将其输入到下方显示 example.com 的框中。
这带来了很多额外的问题:
什么是 Web 客户端 ID?这个凭证部分在哪里?什么是redirect_uri?什么是我的授权域?真正的问题是,我为什么要尝试创建和管理 Google Cloud 项目?我相信答案是因为 Google Play 将我的应用程序包存储在那里。
正确管理项目的答案可能在于:
https://cloud.google.com/resource-manager/docs/creating-managing-projects
我在
找到了 OAuth 客户端
Google Play 管理中心 > 设置 > 开发者帐户 > API 访问
所以,我此时的问题是:“我需要在 Google Play 中填写以初始化系统服务器的最低限度是多少。(这是我的第一个错误陈述)。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)