`
tudusi
  • 浏览: 1048629 次
文章分类
社区版块
存档分类
最新评论

Android in_app billing: java.lang.NullPointerException

 
阅读更多

今天做in_app billing feature时发现一个问题,当进行到 添加 Credit Card界面里程序会crash (下图是在play store里支持付费app时的界面,会遇到同样的问题,所以用在此处作为参照)


点击 Continue之后 就会Crash... Crash 信息如下:


Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40942068

Starting: Intent { cmp=com.android.vending/com.google.android.finsky.activities.FinskyCreateInstrumentActivity (has extras) } from pid 746
Could not find method android.app.Activity.getActionBar, referenced from method com.google.android.finsky.layout.CustomActionBarFactory.getInstance
VFY: unable to resolve virtual method 115: Landroid/app/Activity;.getActionBar ()Landroid/app/ActionBar;
VFY: replacing opcode 0x6e at 0x0006
VFY: dead code 0x0009-0010 in Lcom/google/android/finsky/layout/CustomActionBarFactory;.getInstance (Landroid/app/Activity;)Lcom/google/android/finsky/layout/CustomActionBar;
VFY: dead code 0x0012-0017 in Lcom/google/android/finsky/layout/CustomActionBarFactory;.getInstance (Landroid/app/Activity;)Lcom/google/android/finsky/layout/CustomActionBar;
GC_EXTERNAL_ALLOC freed 223K, 42% free 3778K/6471K, external 1017K/1028K, paused 39ms
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x401a3568)


FATAL EXCEPTION: main

java.lang.NullPointerException

at com.google.android.finsky.billing.creditcard.AddCreditCardFragment.getAddressSpec(AddCreditCardFragment.java:249)

at com.google.android.finsky.billing.creditcard.AddCreditCardFragment.setupWidgets(AddCreditCardFragment.java:349)

at com.google.android.finsky.billing.creditcard.AddCreditCardFragment.onBillingCountriesLoaded(AddCreditCardFragment.java:286)

at com.google.android.finsky.billing.creditcard.AddCreditCardFragment.access$400(AddCreditCardFragment.java:55)

at com.google.android.finsky.billing.creditcard.AddCreditCardFragment$3.run(AddCreditCardFragment.java:271)

at com.google.android.finsky.billing.GetBillingCountriesAction.run(GetBillingCountriesAction.java:40)

at com.google.android.finsky.billing.creditcard.AddCreditCardFragment.loadBillingCountries(AddCreditCardFragment.java:268)

at com.google.android.finsky.billing.creditcard.AddCreditCardFragment.onCreateView(AddCreditCardFragment.java:243)

at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:870)

at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)

at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)

at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)

at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)

at android.os.Handler.handleCallback(Handler.java:587)

at android.os.Handler.dispatchMessage(Handler.java:92)

at android.os.Looper.loop(Looper.java:130)

at android.app.ActivityThread.main(ActivityThread.java:3694)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:507)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)

at dalvik.system.NativeStart.main(Native Method)


产生这个错误的原因是:Google 发现你处于没有被授权支付的国度。这好像是无法躲过检查的,SIM卡里的地理信息好像是伪装不了的。

When an invalid country (one not authorized/enabled for purchases like China) code is read from the SIM and not found in the list mCountries  ( BillingPreferences.BILLING_COUNTRIES ), the mSelectedCountry is set to  NULL:

private void setupWidgets(Bundle bundle)
{
     mSelectedCountry =
BillingUtils.findCountry(BillingUtils.getDefaultCountry(getActivity(), null),
mCountries);
     ...
     mBillingAddress.setAddressSpec(mSelectedCountry,
getAddressSpec(mSelectedCountry));
     ...

}

SUGGESTED FIX:
com.google.android.finsky.billing.creditcard.AddCreditCardFragment.getAddressSpecroutine should check parameter NULL condition.



上网搜索,发现了有人与我遇到了同样的问题:

参考资料:

http://code.google.com/p/android/issues/detail?id=27188这里面详细说明了问题出现的原因

http://code.google.com/p/android/issues/detail?id=28162

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics