2012-05-03 13 views
0

我刚刚开始为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 
}; 

我如何测试我没有真正的发布应用程序抛出帐户?

回答

1

APK Expansion项目的示例代码在调用下载程序函数之前对文件进行了特定检查。确保您的文件在SD卡上,并直接访问它。

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

+0

非常感谢。你帮助最有帮助 – Huichos

+0

http://stackoverflow.com/questions/11933508/problems-testing-apk-expansion-library/12577825#12577825。为了更好的理解检查我的答案 –

相关问题