gpt4 book ai didi

android - 与应用内购买相关的崩溃

转载 作者:行者123 更新时间:2023-11-29 00:33:06 25 4
gpt4 key购买 nike

我有一个应用程序刚刚在市场上推出,它采用应用程序内购买,它是从我几乎不理解的其他人的示例代码中拼凑而成的。该代码在大多数情况下似乎都能正常工作,但我有一台设备每次都会崩溃。它似乎在 gen 目录中的一些“生成的 java 文件”中崩溃,我跟踪了崩溃前的最后几个步骤,如下所示:

protected static boolean isBillingSupported()
{
if (amIDead())
{
return false;
}
Bundle request = makeRequestBundle("CHECK_BILLING_SUPPORTED");

if (mService != null && request != null)
{
try
{
Bundle response = mService.sendBillingRequest(request);

然后我进入这个方法并执行以下几行......(见评论)

public android.os.Bundle sendBillingRequest(android.os.Bundle bundle) throws android.os.RemoteException
{
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
android.os.Bundle _result;
try
{
_data.writeInterfaceToken(DESCRIPTOR); // DESCRIPTOR was "com.android.vending.billing.IMarketBillingService"
if ((bundle!=null))
{
_data.writeInt(1); // GOT HERE OK
bundle.writeToParcel(_data, 0);
}
else
{
_data.writeInt(0);
}
mRemote.transact(Stub.TRANSACTION_sendBillingRequest, _data, _reply, 0); // GOT HERE OK
_reply.readException(); // GOT HERE OK ... BUT THEN JUMPS TO XXXX
if ((0!=_reply.readInt())) // WE NEVER REACH THIS LINE!
{
_result = android.os.Bundle.CREATOR.createFromParcel(_reply);
}
else
{
_result = null;
}
}
finally // XXXX
{
_reply.recycle(); // THIS GETS EXECUTED
_data.recycle(); // THIS GETS EXECUTED
}
return _result; // WE REACH HERE, BUT THAT'S THE LAST LINE I SEE BEFORE THE EXCEPTION APPEARS IN THE LOG OUTPUT
}

日志文件显示如下:

01-10 22:54:00.730: W/dalvikvm(1292): threadid=1: thread exiting with uncaught exception (group=0x401cb760)
01-10 22:54:00.740: E/AndroidRuntime(1292): FATAL EXCEPTION: main
01-10 22:54:00.740: E/AndroidRuntime(1292): java.lang.NullPointerException
01-10 22:54:00.740: E/AndroidRuntime(1292): at android.os.Parcel.readException(Parcel.java:1327)
01-10 22:54:00.740: E/AndroidRuntime(1292): at android.os.Parcel.readException(Parcel.java:1275)
01-10 22:54:00.740: E/AndroidRuntime(1292): at com.android.vending.billing.IMarketBillingService$Stub$Proxy.sendBillingRequest(IMarketBillingService.java:100)
01-10 22:54:00.740: E/AndroidRuntime(1292): at com.mycompany.mygame.BillingHelper.isBillingSupported(BillingHelper.java:64)
01-10 22:54:00.740: E/AndroidRuntime(1292): at com.mycompany.mygame.Shop.onClick(Shop.java:174)
01-10 22:54:00.740: E/AndroidRuntime(1292): at android.view.View.performClick(View.java:3122)
01-10 22:54:00.740: E/AndroidRuntime(1292): at android.view.View$PerformClick.run(View.java:11942)
01-10 22:54:00.740: E/AndroidRuntime(1292): at android.os.Handler.handleCallback(Handler.java:587)
01-10 22:54:00.740: E/AndroidRuntime(1292): at android.os.Handler.dispatchMessage(Handler.java:92)
01-10 22:54:00.740: E/AndroidRuntime(1292): at android.os.Looper.loop(Looper.java:132)
01-10 22:54:00.740: E/AndroidRuntime(1292): at android.app.ActivityThread.main(ActivityThread.java:4028)
01-10 22:54:00.740: E/AndroidRuntime(1292): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 22:54:00.740: E/AndroidRuntime(1292): at java.lang.reflect.Method.invoke(Method.java:491)
01-10 22:54:00.740: E/AndroidRuntime(1292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
01-10 22:54:00.740: E/AndroidRuntime(1292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
01-10 22:54:00.740: E/AndroidRuntime(1292): at dalvik.system.NativeStart.main(Native Method)
01-10 22:54:02.770: I/dalvikvm(1292): threadid=4: reacting to signal 3
01-10 22:54:02.770: I/dalvikvm(1292): Wrote stack traces to '/data/anr/traces.txt'

我不知道从这里到哪里去,因为我完全不知道发生了什么。我对这段代码是如何或为什么会被“生成”感到困惑……大概即使我在这里看到一个错误,我也无法编辑它!这段代码是 Android 操作系统的一部分吗?也许真正的错误在传递的包中?..欢迎所有提示。

最佳答案

它看起来像 android.os.Parcel.obtain()命令返回 null,这将导致 _reply.readException() 上的 NPE .

如果你尝试会发生什么:

if ((_reply!=null)) {
_reply.readException();
} else {
Log.d(TAG, "_reply is null");
}

编辑

看到这行不通,我仔细研究了一下,发现了这个线程: http://code.google.com/p/marketbilling/issues/detail?id=25这似乎表明这是一个答案:

This happens when the device has not accepted the License Agreement and try to call this line I encountered this problem when my client just bought a new device and try run my app which make use of inApp so he didnt ever opened market app in his device and so had never accepted the Agreement once you accept the it this error will not be there

关于android - 与应用内购买相关的崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14276783/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com