Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

[Solved] Can't Build APK using IAP!

Discussion in 'Unity IAP' started by MHolmstrom, Aug 6, 2017.

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

    MHolmstrom

    Joined:
    Aug 16, 2012
    Posts:
    115
    Hello there Unity, I'm building a Match-3 Line Game and I'm doing some amazing progress, I then started integrating IAP provided by Unity. I already have Facebook SDK integrated and it's all working like a charm.
    I get no console errors what so ever while running the game in the Editor but when I build my APK turns out 1/3 smaller in size. Let's install it on my Android Device. It works like it's supposed to. It asks for privileges using google store services etc.
    But when I start the app it's all black and then it runs in the background, and if I try to open again it goes back to the background. It's not playable and I can't say it's working at all.
    I enabled the Splash screen just to see if it was my game scene causing the problem but it was not because the splash screen never shows.
    I deleted the UnityPurchasing folder and build again and now it works like a charm. The only problem now is my IAP services don't work. So I tried to import it again but then we are back to where we started, I can't build a full build while IAP is in my project.
    I have searched the whole web for information and done all potential fixes but nothing seems to do the trick.

    My log when the APK is built (Remember it's also 1/3 the size of what it's supposed to).
    Using 2017.1.0f3 (Plus).
    Would be so thankful for advice or help!
    Stores.dll seems to be a problem for me, I have it included on all platforms, it's using .Net 3.5 so is my project so I don't see a problem there.
    Code (CSharp):
    1. ArgumentException: The Assembly ChannelPurchase is referenced by Stores ('Assets/Plugins/UnityPurchasing/Bin/Stores.dll'). But the dll is not allowed to be included or could not be found.
    2. UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2 cache, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:142)
    3. UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2 cache, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:148)
    4. UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:179)
    5. UnityEditor.HostView:OnGUI()
    Code (CSharp):
    1. UnityEditor.BuildPlayerWindow+BuildMethodException: Build failed with errors.
    2.   at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x001b9] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:162
    3.   at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00050] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:83
    4. UnityEditor.HostView:OnGUI()
     
  2. MHolmstrom

    MHolmstrom

    Joined:
    Aug 16, 2012
    Posts:
    115
    I imported the UnityChannel package as well but it backfired hard, the .dll problem is gone and my whole project only has 4 warnings although the game. But no Errors.
    When I build the app it's a smooth experience but then the app crash when I try to launch it!
    Stil looking for assistance! Not a great first impression of 2017.0.1f3
     
    Last edited: Aug 7, 2017
  3. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,384
    @MHolmstrom,
    • Which version of the IAP plugin are you using?
    • Would you be able to provide a full log from the device?
    • Are you using Codeless IAP? If not, could you share your purchasing script?
     
  4. nicholasr

    nicholasr

    Unity Technologies

    Joined:
    Aug 15, 2015
    Posts:
    119
    @MHolmstrom, thank you for the comprehensive report - this is really helpful. I also suspect the project files might be corrupted, and am a little perplexed that reinstallation did not resolve the issue - was that importing from the In-App Purchasing window? Since this problem-scenario is a new one, the responses to @ap-unity will be helpful for us to diagnose just what is up.

    In addition, while preparing those answers for Arthur, I was thinking that this additional detail could be helpful. It may not be news to you, however. The Unity IAP 1.12 series now includes that UnityChannel file at ./Assets/Plugins/UnityChannel/ChannelPurchase.dll along with a UnityStore.dll, and a subfolder "XiaomiSupport/" containing mainly Editor scripts. This code is available to all Android builds, not just those that target Xiaomi.

    There also is an Android JAR at ./Assets/Plugins/UnityChannel/Android/UnityChannel.aar which would only be included in the APK if the "Target Xiaomi Mi Game Pay" option was selected, increasing the size by a megabyte or more.

    upload_2017-8-8_16-17-34.png

    The "Stores.dll" is compiled so that it depends upon those Assemblies. The Java AAR is only required when the Android "Target" feature is activated.
     
  5. MHolmstrom

    MHolmstrom

    Joined:
    Aug 16, 2012
    Posts:
    115
    Thanks for all the replies, I have yet not had time to try your answers because I'm doing freelancing and my full-time at the moment.
    But what seems to work for me was to import the IAP from the Asset Store, because now it's working like a charm.
    Not sure if it was the "Service" window that didn't connect properly. Thanks for all replies I still got a backup from where the issue occurred and I'll see if I find a solution to it and I will then post it here!
     
    nicholasr likes this.
  6. nicholasr

    nicholasr

    Unity Technologies

    Joined:
    Aug 15, 2015
    Posts:
    119
    Fantastic news @MHolmstrom - yes any details you can share will be incorporated into our future support and development.
     
  7. rchapman

    rchapman

    Joined:
    Feb 13, 2014
    Posts:
    50
    Argh - fresh install/reinstall/uninstall/re-reinstall of IAP in 5.6.0f3, getting these errors on iOS. Looks like this was sent out the door without a proper test pass.
     
    JonnyHilly likes this.
  8. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,384
    @rchapman

    Would you be able to provide more details?

    What specific errors are you seeing? Are they in the editor or on the device? Do you have any device logs available when these errors occur? Does this problem occur with an empty project or only your existing project? Any details you are able to provide will really help us narrow down this issue.
     
  9. rchapman

    rchapman

    Joined:
    Feb 13, 2014
    Posts:
    50
    I can't build to iOS at all due to this error:

    ArgumentException: The Assembly ChannelPurchase is referenced by Stores ('Assets/Plugins/UnityPurchasing/Bin/Stores.dll'). But the dll is not allowed to be included or could not be found.

    I've tried to remove/reinstall the IAP package from the services panel as well as from the asset store, same problem in both cases.
     
  10. MHolmstrom

    MHolmstrom

    Joined:
    Aug 16, 2012
    Posts:
    115
    Have you looked at window > IAP and looked for target build?
    I got it from the asset store and did not import the the channel package. Make sure you got the required componenets from the sdk aswell!
     
  11. rchapman

    rchapman

    Joined:
    Feb 13, 2014
    Posts:
    50
    Are these steps documented anywhere? It seems to me installing from the services window should take care of this. I have no idea what the channel package is or why it needs to be installed.
     
  12. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,384
    @rchapman

    All the relevant files for Unity IAP (including the UnityChannel dll) should be included in the IAP plugin. And the plugin from the Services window is the same as from the Asset Store.

    Would you be able to check something for me.
    1. In the Editor, open your Player Settings menu: Edit -> Project Settings -> Player
    2. In the Other Settings section, change the value of API Compatibility Level
    3. Default is '.NET 2.0 Subset'. Change to: '.NET 2.0'
    4. Try another build and see if you still get errors.
     
    Last edited: Aug 22, 2017
  13. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,384
  14. rchapman

    rchapman

    Joined:
    Feb 13, 2014
    Posts:
    50
    That's it! Must have been the switch to .NET 2.0. Would be good to document this or, if it is documented, somehow highlight it during the install process.
     
    nicholasr and MHolmstrom like this.
Thread Status:
Not open for further replies.
unityunity