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

Question Unsolvable compilation errors that show up as soon as Unity IAP package is imported.

Discussion in 'Unity IAP' started by Bimbuh, Feb 24, 2022.

  1. Bimbuh

    Bimbuh

    Joined:
    Dec 21, 2018
    Posts:
    12
    I tried integrating Unity IAP package (from the package manager) into my project (empty project for now), only to be met with very strange compilation errors

    Happens in Unity 2019.4.33f1 and Unity 2019.4.36f1. They are:

    Library\PackageCache\com.unity.purchasing@4.1.3\Runtime\AppleCore\INativeAppleStore.cs(5,42): error CS0122: 'UnityPurchasingCallback' is inaccessible due to its protection level

    and

    Microsoft (R) Visual C# Compiler version 2.9.1.65535 (9d34608e)
    Copyright (C) Microsoft Corporation. All rights reserved.
    error CS1704: An assembly with the same simple name 'Purchasing.Common' has already been imported. Try removing one of the references (e.g. 'E:\_Unity2k19\UnityA12Test\Library\ScriptAssemblies\Purchasing.Common.dll') or sign them to enable side-by-side.


    I am totally clueless as to the raison d'etre of these errors, given that they do not originate from scripts I wrote. Can anyone please help me out with this? What could be causing this error and how can I resolve it.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please compare to a new/empty project and import IAP. Are you upgrading this project from a previous version of IAP? If so, make a project back up and then delete /Assets/Plugins/UnityPurchasing, make sure there are no compile errors (you may need to block comment or remove your purchase scripts), then import IAP via Package Manager. The latest is 4.1.3. Another thing to try (perhaps easier) is to just delete the /Library folder with the project as it is (make a back up first) outside of Unity then open it in Unity again.
     
  3. Bimbuh

    Bimbuh

    Joined:
    Dec 21, 2018
    Posts:
    12
    As mentioned in my post, the project is completely empty, no scripts, no assets, just a brand new project (I faced this issue while using 2019.4.33f1, I thought it was a Unity version problem, so I downloaded the latest version to give it a try and unfortunately the issue is still present). The project is empty. I just created an empty project, switched to Android (Target Android) and imported IAP, then got this error. All of my projects are in Unity 2019.4.21f1 and Unity does not have this IAP caused compilation error..IAP just works just fine with 2019.4.21f1.

    I am doing all my best to move to the latest version of Unity 2019.x because none of my apps would install on any device running Android 12. Google Play won't accept any of my updates targeting Android 12, due to the android:export=true issue. I tried all sorts of fixes on this forum and from the internet, all to no avail. From what I read, the said issue with the manifest file has been automatically fixed starting with Unity 2019.4.33f1. Unfortunately I can't move my projects to these Unity versions because to the problems mentioned in this post.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, it's only with 2019.4.33f1. Can you try with Unity 2020/2021 versions? Also, see this thread https://forum.unity.com/threads/uni...cessible-due-to-its-protection-level.1082075/ . You only install IAP from Package Manager, not from the Services window. Do not Import if prompted.
     
  5. Bimbuh

    Bimbuh

    Joined:
    Dec 21, 2018
    Posts:
    12
    Can I please know what you mean by " it's only with 2019.4.33f1". Do you mean the Android 12 issue is fixed ONLY with Unity 2019.4.33f1?

    "You only install IAP from Package Manager, not from the Services window. Do not Import if prompted." I guess that's what I did wrong. I imported also from the Services window. Actually, I saw a warning on the services Window prohibiting me from clicking "import". I went ahead to do it because after installing the IAP package from the package manager, there was no noticeable change. I generally verify a proper installation of the IAP package by going to Window>Unity IAP> Create IAP button. But after installing IAP from the package manager (the errors mentioned in my post don't show up after I do this) nothing happens, "Unity IAP" isn't even present in the Window section. So I go ahead to import from the services window (which I used to do in the past to get IAP working), which seems to then cause all the trouble I am currently facing. So please, how should I go about fixing this? How should I get IAP properly installed and functioning (able to even edit the IAP catalog from the Window menu) without importing from the Services section as I used to do in the past.
     
  6. Bimbuh

    Bimbuh

    Joined:
    Dec 21, 2018
    Posts:
    12
    "Can you try with IAP 2020/2021 versions?" Where do I get these versions? From the asset store?

    If by "it's only with 2019.4.33f1" you meant the issue only occurs with 2019.4.33f1, that's not the case, it also occurs with Unity 2019.4.36f1.
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, so it's not only 2019.33f1 for you (is what I meant). I am not familiar with an Android 12 issue. And correct, don't use the Services window. You only import via Package Manager. I just used 2019.20f1 (because I already had it installed) and imported IAP 4.1.3 without issue. Then choose menu Services/In App Purchasing. However, don't use an IAP Button or IAP Catalog, there are known issues with Codeless IAP. Instead, use Scripted IAP. I just published this updated Sample IAP Project https://forum.unity.com/threads/sample-iap-project.529555/#post-7922275