-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Key manipulation InvalidKeySpecException #10
Comments
Hi @jpardogo! Yes, a sample project is a great idea. Here's some code from one of our apps that lives in the activity that displays the items to purchase. Because we build both Amazon and Google from the same codebase, we rely on the Gradle flavor mechanism for that. Hopefully this will get you started. private void initIap() {
String iapKey;
int iapBuildTarget;
if ("amazon".equals(BuildConfig.FLAVOR)) {
iapKey = "";
iapBuildTarget = IAPManager.BUILD_TARGET_AMAZON;
} else if ("google".equals(BuildConfig.FLAVOR)) {
iapKey = "***** INSERT YOUR GOOGLE IAP KEY HERE ******";
iapBuildTarget = IAPManager.BUILD_TARGET_GOOGLE;
} else {
return;
}
List<String> iapKeys = yourFunctionToGetIapKeys();
IAPManager.build(this, iapBuildTarget, iapKeys);
IAPManager.addPurchaseListener(this);
IAPManager.init(iapKey, BuildConfig.DEBUG);
} Does that help? |
@jpardogo from further reading here, https://stackoverflow.com/questions/32428947/android-in-app-billing-error-invalidkeyspecexception, it sounds like your key is likely invalid somehow. As this library doesn't really do anything except pass it through, we don't have much control. |
Hi, yes the library was modifying the string key I passed as a parameter (I debug it and confirmed it). Other improvements that could be good:
public static void init(boolean enableLogging) {
init(null, enableLogging)
}
public static void init(String key, boolean enableLogging) {
if(key!=null){
billingService.init(key);
}
billingService.enableDebugLogging(enableLogging);
}
and here:
|
@jpardogo Thanks for the several great ideas there. I've created new issues:
I'm not sure why the for-loop is there either. As far as I know, this is the exact same sample code that Google provides for IAP in multiple places. I wonder why they bother to rebuild the key? I'm hesitant to change their code without understanding why. Do you know what section of your key it was changing and why? |
I guess they where sending the IAP key in an specific format and the app was decoding it, with the for loop, this way the real inapp key wasn't store as a plain string on the source code. Also we can follow the same init method strategy for other end points where some arguments are not required for amazon or Google. |
I would send all callback in the main thread and the user will take care of doing anything they want with its own threading strategy. Also the onError callback is useful for error user feedback, not only debuging. Great lib by the way, with a bit of work it could be awesome. |
I'm pretty curious about why you deal this way with the string key for google in app. I'm getting 'InvalidKeySpecException', an example project with the library would help.
https://github.com/eggheadgames/android-in-app-payments/blob/1.2.8/library/src/main/java/com/billing/google/GoogleBillingService.java#L40
The text was updated successfully, but these errors were encountered: