Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Solved] Unable to instantiate receiver com.amazon.inapp.purchasing.ResponseReceiver

Discussion in 'Unity IAP' started by funx, Nov 28, 2016.

Thread Status:
Not open for further replies.
  1. funx

    funx

    Joined:
    Jun 9, 2014
    Posts:
    16
    I'm trying to implement Unity IAP for use with Amazon AppStore (not underground). I have my implementation successfully working already with Google Play and iTunes Connect.

    Unity version: 5.4.0f3 and the latest UnityPurchase plugin (as of 28th Nov 2016). I'm testing with a 4th generation Fire tablet using Live App Testing.

    After doing a purchase for a consumable item I get the following error in logcat and the app crashes:

    11-28 16:11:59.282 19223-19223/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.companyname.myapp, PID: 19223
    java.lang.Error: FATAL EXCEPTION [main]
    Unity version : 5.4.0f3
    Device model : Amazon KFTHWI
    Device fingerprint: Amazon/thor/thor:4.4.3/KTU84M/13.4.5.5_user_455004220:user/release-keys

    Caused by: java.lang.RuntimeException: Unable to instantiate receiver com.amazon.inapp.purchasing.ResponseReceiver: java.lang.ClassNotFoundException: Didn't find class "com.amazon.inapp.purchasing.ResponseReceiver" on path: DexPathList[[zip file "/data/app/com.companyname.myapp-1.apk", zip file "/system/priv-app/MetricsApi-2066310.apk", zip file "/system/priv-app/com.amazon.dp.logger.apk"],nativeLibraryDirectories=[/data/app-lib/com.companyname.myapp-1, /vendor/lib, /system/lib]]
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2493)
    at android.app.ActivityThread.access$1700(ActivityThread.java:145)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5266)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:826)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:642)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.amazon.inapp.purchasing.ResponseReceiver" on path: DexPathList[[zip file "/data/app/com.companyname.myapp-1.apk", zip file "/system/priv-app/MetricsApi-2066310.apk", zip file "/system/priv-app/com.amazon.dp.logger.apk"],nativeLibraryDirectories=[/data/app-lib/com.companyname.myapp-1, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2488)
    at android.app.ActivityThread.access$1700(ActivityThread.java:145)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5266)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:826)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:642)
    at dalvik.system.NativeStart.main(Native Method)
    11-28 16:11:59.332 920-1106/? W/ActivityManager: Force finishing activity com.companyname.myapp/.MyAppUnityPlayerActivity
    11-28 16:11:59.412 920-1267/? I/WindowState: WIN DEATH: Window{41c08578 u0 com.companyname.myapp/com.companyname.myapp.MyAppUnityPlayerActivity}

    I unpacked the APK I submitted to Live App Testing and it has the following response receiver automatically inserted into the AndroidManifest.xml by Unity during build time but it doesn't match the actual error above: Unable to instantiate receiver com.amazon.inapp.purchasing.ResponseReceiver:

    <receiver android:name="com.amazon.device.iap.ResponseReceiver">
    <intent-filter>
    <action android:name="com.amazon.inapp.purchasing.NOTIFY" android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"/>
    </intent-filter>
    </receiver>
     
  2. funx

    funx

    Joined:
    Jun 9, 2014
    Posts:
    16
    I seemed to have got around the issue by including the following in my AndroidManifest.xml:

    Code (CSharp):
    1.  <receiver android:name="com.amazon.inapp.purchasing.ResponseReceiver"
    2.       android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY">
    3.       <intent-filter>
    4.               <action android:name="com.amazon.inapp.purchasing.NOTIFY" />
    5.       </intent-filter>
    6.     </receiver>
    and including a dummy Java class in one of the custom JARs I include in my Android version:

    Code (CSharp):
    1. package com.amazon.inapp.purchasing;
    2.  
    3. import android.content.BroadcastReceiver;
    4. import android.content.Context;
    5. import android.content.Intent;
    6. import android.util.Log;
    7.  
    8. public class ResponseReceiver extends BroadcastReceiver {
    9.  
    10.     @Override
    11.     public void onReceive(Context context, Intent intent) {
    12.     }
    13. }
    14.  
     
Thread Status:
Not open for further replies.