Search Unity

Unity IAP Xcode NullReferenceException

Discussion in 'Unity IAP' started by rmjfox, Aug 31, 2018.

  1. rmjfox

    rmjfox

    Joined:
    Jun 4, 2018
    Posts:
    9
    I am trying to integrate Unity IAP to my project targeted for iOS and Android. I have followed all the instructions and also completed apple tax contracts etc. But when I run the project on iphone through xcode, the console shows a nullreferenceexception. I have pasted the xcode logs below. I have highlighted the error in bold. This same error happens when I run an empty project with just Unity plugin enabled and running the IAPDemo Scene. This happens when UnityPurchasing.Initialize(this, builder) is called. The purchase script is loaded with the main screen. I am not even calling any Buy product function. This happens at initialise itself. Can anyone let me know what this is? Should I continue forward with this?Will it cause an issue? Is it an iOS version issue?I am using iOS 10.3.3 for testing purposes? Could that be the problem?

    Purchase script same as the one in Unity sample.
    Unity Version - 2018.1.0f2 Personal
    Unity IAP Version - 1.21
    Device - iPhone 6s

    XCODE LOG -

    [DYMTLInitPlatform] platform initialization successful
    UnityIAP UnityEarlyTransactionObserver: Created

    UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    Built from '2018.1/staging' branch, Version '2018.1.0f2 (d4d99f31acba)', Build type 'Release', Scripting Backend 'il2cpp'
    -> registered mono modules 0x100de3960
    -> applicationDidFinishLaunching()
    Metal GPU Frame Capture Enabled
    Metal API Validation Disabled
    libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see <rdar://problem/11744455>)
    UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    -> applicationDidBecomeActive()
    GfxDevice: creating device client; threaded=1
    Initializing Metal device caps: Apple A9 GPU
    Initialize engine version: 2018.1.0f2 (d4d99f31acba)
    UnloadTime: 3.241541 ms
    UnityIAP Version: 1.21
    UnityEngine.Purchasing.StandardPurchasingModule:Instance(AppStore)
    IAPDemo:Awake()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    NullReferenceException: A null value was found where an object instance was required.
    at UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
    at UnityEngine.AndroidJavaObject.Finalize () [0x00000] in <filename unknown>:0
    UnityEngine.UnhandledExceptionHandler:printException(String, Exception)
    UnityEngine.UnhandledExceptionHandler:HandleUnhandledException(Object, UnhandledExceptionEventArgs)

    (Filename: currently not available on il2cpp Line: -1)

    NullReferenceException: A null value was found where an object instance was required.
    at UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
    at UnityEngine.AndroidJavaObject.Finalize () [0x00000] in <filename unknown>:0
    UnityEngine.UnhandledExceptionHandler:printException(String, Exception)
    UnityEngine.UnhandledExceptionHandler:HandleUnhandledException(Object, UnhandledExceptionEventArgs)


    (Filename: currently not available on il2cpp Line: -1)

    Setting up 1 worker threads for Enlighten.
    Thread -> id: 16f30b000 -> priority: 1
    Using configuration builder objects
    UnityEngine.Purchasing.StoreCatalogImpl:handleCachedCatalog(Action`1)
    UnityEngine.Purchasing.<Process>d__4:MoveNext()
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    UnityIAP: Requesting 3 products
    UnityIAP: Requesting product data...
    UnityIAP: Received 0 products
    UnityIAP: No App Receipt found
    UnityIAP: No App Receipt found

    Unavailable product 100.gold.coins -100.gold.coins
    UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Unavailable product 500.gold.coins -500.gold.coins
    UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Unavailable product sword -sword
    UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Billing failed to initialize!

    IAPDemo:OnInitializeFailed(InitializationFailureReason)
    UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    No products available for purchase!
    UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    UnityIAP Promo: Clearing promo product metadata
    UnityEngine.Purchasing.Promo:provideProductsToAds(HashSet`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    UnityIAP: Add transaction observer
    UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments
    [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction
    [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction
     
    Firemaw likes this.
  2. alexanderperrin

    alexanderperrin

    Joined:
    Dec 15, 2016
    Posts:
    67
    I am finding the same issue running 2017.4.2f2 with UnityPurchasing 1.21.0 on iOS 11.2.2. The issue appears when getting a ConfigurationBuilder instance, in my case:
    Code (CSharp):
    1. var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    My system appears to initialise regardless of the issue, but it's not great!
     
  3. rmjfox

    rmjfox

    Joined:
    Jun 4, 2018
    Posts:
    9
    @alexanderperrin I had the issue at ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()) as well initially. But that was when my purchaser script was in another script folder in my project. When I shifted the purchaser script to the folder location in UnityPurchasing/Script the error went. But then the error started occurring at UnityPurchasing.Initialize(this, builder). Can you check this at your side as well?
     
  4. rmjfox

    rmjfox

    Joined:
    Jun 4, 2018
    Posts:
    9
    Anyone know what this UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00000] is? Someone please help. Its urgent.

    NullReferenceException: A null value was found where an object instance was required.
    at UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
    at UnityEngine.AndroidJavaObject.Finalize () [0x00000] in <filename unknown>:0
     
  5. alexanderperrin

    alexanderperrin

    Joined:
    Dec 15, 2016
    Posts:
    67
    I'll try to give it a go today, however moving my IAP script breaks a few other things so it might take some time.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  7. alexanderperrin

    alexanderperrin

    Joined:
    Dec 15, 2016
    Posts:
    67
    @JeffDUnity3D I am able to confirm that the error does not occur on 1.20!
     
    Firemaw likes this.
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Glad it's working on 1.20 for you. We are still investigating with respect to 1.21
     
  9. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    302
    Are you kidding me? Just updated and built to iOS and getting this. Why would you even keep this on the asset store when you KNOW it has these issues? The changelog even states that NO CHANGES has been made to IAP other than adding support for the UDP module.

    @JeffDUnity3D
     
    Last edited: Sep 19, 2018
  10. yoambulante

    yoambulante

    Joined:
    Feb 3, 2017
    Posts:
    4
    the least thing I ever wanted was have to be worried about Unity IAP updates... this problem is affecting millions!! i am now rolling back to 1.20 (hopefully I will never have update to any newer version unless strictly necessary), lesson learned.
     
  11. rmjfox

    rmjfox

    Joined:
    Jun 4, 2018
    Posts:
    9
    Finally got around to check this with previous version of Unity IAP. I can also confirm that it doesn't occur on 1.20. It was my first time with IAP and this got me really worried as I had started off with version 1.21. So lost some precious time there trying to fix this issue. And since it only happened with the new version, it hadn't been previously mentioned anywhere. Initially I went ahead with it after @alexanderperrin pointed out that it did seem to initialise. And even though everything seemed to work normally, it kept me a bit skeptical as I wouldn't want any error especially in this part of the project. But now with version 1.20, that exception has gone and everything seems to be fine and I am just glad that it is. Thanks for the help @alexanderperrin @JeffDUnity3D
     
  12. Suvitruf

    Suvitruf

    Joined:
    Sep 3, 2014
    Posts:
    39
    Have this issue on Android with IAP 1.21
     
  13. Suvitruf

    Suvitruf

    Joined:
    Sep 3, 2014
    Posts:
    39
    Same, as @rmjfox...I've rolled back to 1.20 and now it's fine. So, please fix 1.21 version.
     
  14. drordoit

    drordoit

    Joined:
    Sep 7, 2013
    Posts:
    36
    Have the same problem , rolling back to 1.20 "solve" the issue but give me some other error ("MissingMethodException: Method not found: 'UnityEngine.VR.VRSettings.get_enabled'.") when clicking the purchasing button. Any solutions for 1.21?
     
    Last edited: Oct 8, 2018
  15. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  16. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    769
    @JeffDUnity3D when I downgraded to 1.20, I got a build error for android:

    [!] Google Api Error: apkPermissionsRequirePrivacyPolicy: The apk has permissions that require a privacy policy set for the app, e.g: android.permission.READ_PHONE_STATE.[0m
     
  17. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi @goldbug ,
    It's an irrelevant issue, please post it in a new forum in the future.
    Unity IAP for Google Play doesn't require this permission. It might be caused by another plugin you are using in your project.
    If you still think it's an issue in Unity IAP, please re-import Unity IAP plugin, delete the 'Library' folder and try it again.
    Thank you.