【问题标题】:Creating an application that uses Expansion Files without publisher account在没有发布者帐户的情况下创建使用扩展文件的应用程序
【发布时间】:2012-05-03 23:50:29
【问题描述】:

我刚开始为 Android 开发,我没有 Google Play 开发者许可证。对于我的应用程序,我必须使用 APK 扩展文件。

我尝试应用包含在 play_apk_expansion 中的 downloader_sample 代码,但是得到了这个方法抛出的 InvalidKeySpecException

private static PublicKey generatePublicKey(String encodedPublicKey) {
    try {
        byte[] decodedKey = Base64.decode(encodedPublicKey);
        KeyFactory keyFactory = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM);
        return keyFactory.generatePublic(new X509EncodedKeySpec(decodedKey));
    } catch (NoSuchAlgorithmException e) {
        // This won't happen in an Android-compatible environment.
        throw new RuntimeException(e);
    } catch (Base64DecoderException e) {
        Log.e(TAG, "Could not decode from Base64.");
        throw new IllegalArgumentException(e);
    } catch (InvalidKeySpecException e) {
        Log.e(TAG, "Invalid key specification.");
        throw new IllegalArgumentException(e);
    }
}

我也有

public class SampleDownloaderService extends DownloaderService {
// You must use the public key belonging to your publisher account
public static final String BASE64_PUBLIC_KEY = "MyLVLKey";
// You should also modify this salt
public static final byte[] SALT = new byte[] { 1, 42, -12, -1, 54, 98,
        -100, -12, 43, 2, -8, -4, 9, 5, -106, -107, -33, 45, -1, 84
};

如何在没有真实发布者帐户的情况下测试我的应用程序?

【问题讨论】:

    标签: android google-play expansion-files


    【解决方案1】:

    APK 扩展项目的示例代码在调用下载器函数之前对文件是否存在进行了特定检查。确保您的文件位于 SD 卡上并直接访问它。

    要按原样使用内置下载器,您需要一个发布者帐户,因为这些文件托管在 Google Play 上。只需稍作更改,您就可以使用下载器从任何您想要的地方下载,例如本地服务器。

    【讨论】:

    猜你喜欢
    • 2017-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-25
    • 1970-01-01
    相关资源
    最近更新 更多