Search Unity

To add in-app products, you need to add the BILLING permission to your APK.

Discussion in 'Unity IAP' started by drndfx, Feb 11, 2019.

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

    drndfx

    Joined:
    Jul 3, 2013
    Posts:
    89
    I see this on Google Play store developer window after I upload my APK and when I try to go to “IAP” setup section. Do you know what this is?

    I already have Unity IAP installed


    To add in-app products, you need to add the BILLING permission to your APK.”

     
    IgorAherne likes this.
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. drndfx

    drndfx

    Joined:
    Jul 3, 2013
    Posts:
    89
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    They are the basically the same scripts, they both inherit from iStoreListener. Please refer to the Sample IAP Project here for an example: https://forum.unity.com/threads/sample-iap-project.529555/
     
  5. ChadrickEvans

    ChadrickEvans

    Joined:
    Mar 14, 2015
    Posts:
    46
    the page from that manual is in this order:
    -Upload APK
    -Add Products on Google Play console.

    If the console doesn't allow us to add products unless the APK is already uploaded, how would we add products first?

    I've been having an issue where I can't manually add billing permissions to the apk without overriding Unity's way of automatically making permissions. I would prefer Unity to make them automatically.
     
    yuch3n likes this.
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    No, you need to add your products first, regardless of the documentation. I've never needed to explicitly add any permissions.
     
  7. jfperusse_bhvr

    jfperusse_bhvr

    Joined:
    Nov 11, 2014
    Posts:
    9
    @JeffDUnity3D I confirm that we have the same error message on play.google.com indicating that we must add the permission and upload a new APK before we can add products. This is probably something which changed on Google side.
     
    polyphonic13 likes this.
  8. jfperusse_bhvr

    jfperusse_bhvr

    Joined:
    Nov 11, 2014
    Posts:
    9
    Actually, it might be the error message on the Google Play Console which is confusing. I believe the requirement is embedded in the UnityIAP library itself (https://developer.android.com/google/play/billing/billing_library_releases_notes#release-1_0):
    • Embedded billing permission inside library’s manifest. It's not necessary to add the com.android.vending.BILLING permission inside Android manifest anymore.
    Uploading an APK with UnityIAP should suffice in enabling the IAP section of the Google Play Console.
     
  9. RyanMartin

    RyanMartin

    Joined:
    Feb 20, 2017
    Posts:
    10
    It should, but I've had issues with it as well. I still get the notice from Google Play that my billing permissions aren't there.

    I've tried adding products in Unity first as well, but nothing I do is helping.

    upload_2019-9-12_19-9-48.png

    upload_2019-9-12_19-10-49.png
     
  10. andrew-wong-dgnt

    andrew-wong-dgnt

    Joined:
    Dec 31, 2016
    Posts:
    1
    I am having this problem too..
     
  11. RyanMartin

    RyanMartin

    Joined:
    Feb 20, 2017
    Posts:
    10
    I took things one step further. I downgraded manually to an older version of Unity IAP. (1.18)
    I exported the project to Android Studio and manually added the dependencies to my android manifest file and my gradle build...

    And THEN I realized that I didn't click "Start Rollout to Alpha," which then enabled me to generate my in game products in the Google Play Console.

    Looks like the issue was me all along. Most tutorials on this subject are a bit out of date. Make sure you actually roll out your .apk, with the IAP service included and enabled, and ROLL OUT your build to a test channel, then you should be good to go.

    ;)
     
  12. ph4ntomz

    ph4ntomz

    Joined:
    Jul 22, 2016
    Posts:
    37
    I was running into the exact same issue when I was trying to upload my aab file. Nothing of the recommended ways worked for me so I tried modifying the android manifest myself.

    The comments on here (https://stackoverflow.com/questions...eed-to-add-the-billing-permission-to-your-apk) suggest that you don't need to set the permission any more, but I wanted to try anyway.

    To modify the xml after Unity created it, I used the following script:
    Code (CSharp):
    1.  
    2. using System.IO;
    3. using System.Text;
    4. using System.Xml;
    5. using UnityEditor.Android;
    6.  
    7. public class ModifyUnityAndroidAppManifestSample : IPostGenerateGradleAndroidProject
    8. {
    9.  
    10.     public void OnPostGenerateGradleAndroidProject(string basePath)
    11.     {
    12.         // If needed, add condition checks on whether you need to run the modification routine.
    13.         // For example, specific configuration/app options enabled
    14.  
    15.         var androidManifest = new AndroidManifest(GetManifestPath(basePath));
    16.  
    17.         androidManifest.SetBillingPermission();
    18.  
    19.         // Add your XML manipulation routines
    20.  
    21.         androidManifest.Save();
    22.     }
    23.  
    24.     public int callbackOrder { get { return 1; } }
    25.  
    26.     private string _manifestFilePath;
    27.  
    28.     private string GetManifestPath(string basePath)
    29.     {
    30.         if (string.IsNullOrEmpty(_manifestFilePath))
    31.         {
    32.             var pathBuilder = new StringBuilder(basePath);
    33.             pathBuilder.Append(Path.DirectorySeparatorChar).Append("src");
    34.             pathBuilder.Append(Path.DirectorySeparatorChar).Append("main");
    35.             pathBuilder.Append(Path.DirectorySeparatorChar).Append("AndroidManifest.xml");
    36.             _manifestFilePath = pathBuilder.ToString();
    37.         }
    38.         return _manifestFilePath;
    39.     }
    40. }
    41.  
    42.  
    43. internal class AndroidXmlDocument : XmlDocument
    44. {
    45.     private string m_Path;
    46.     protected XmlNamespaceManager nsMgr;
    47.     public readonly string AndroidXmlNamespace = "http://schemas.android.com/apk/res/android";
    48.     public AndroidXmlDocument(string path)
    49.     {
    50.         m_Path = path;
    51.         using (var reader = new XmlTextReader(m_Path))
    52.         {
    53.             reader.Read();
    54.             Load(reader);
    55.         }
    56.         nsMgr = new XmlNamespaceManager(NameTable);
    57.         nsMgr.AddNamespace("android", AndroidXmlNamespace);
    58.     }
    59.  
    60.     public string Save()
    61.     {
    62.         return SaveAs(m_Path);
    63.     }
    64.  
    65.     public string SaveAs(string path)
    66.     {
    67.         using (var writer = new XmlTextWriter(path, new UTF8Encoding(false)))
    68.         {
    69.             writer.Formatting = Formatting.Indented;
    70.             Save(writer);
    71.         }
    72.         return path;
    73.     }
    74. }
    75.  
    76.  
    77. internal class AndroidManifest : AndroidXmlDocument {
    78.     private readonly XmlElement ApplicationElement;
    79.  
    80.     public AndroidManifest(string path) : base(path) {
    81.         ApplicationElement = SelectSingleNode("/manifest/application") as XmlElement;
    82.     }
    83.  
    84.     private XmlAttribute CreateAndroidAttribute(string key, string value) {
    85.         XmlAttribute attr = CreateAttribute("android", key, AndroidXmlNamespace);
    86.         attr.Value = value;
    87.         return attr;
    88.     }
    89.  
    90.     internal XmlNode GetActivityWithLaunchIntent() {
    91.         return SelectSingleNode("/manifest/application/activity[intent-filter/action/@android:name='android.intent.action.MAIN' and " +
    92.                 "intent-filter/category/@android:name='android.intent.category.LAUNCHER']", nsMgr);
    93.     }
    94.  
    95.     internal void SetApplicationTheme(string appTheme) {
    96.         ApplicationElement.Attributes.Append(CreateAndroidAttribute("theme", appTheme));
    97.     }
    98.  
    99.     internal void SetStartingActivityName(string activityName) {
    100.         GetActivityWithLaunchIntent().Attributes.Append(CreateAndroidAttribute("name", activityName));
    101.     }
    102.  
    103.  
    104.     internal void SetHardwareAcceleration() {
    105.         GetActivityWithLaunchIntent().Attributes.Append(CreateAndroidAttribute("hardwareAccelerated", "true"));
    106.     }
    107.  
    108.     internal void SetBillingPermission() {
    109.         var manifest = SelectSingleNode("/manifest");
    110.         XmlElement child = CreateElement("uses-permission");
    111.         manifest.AppendChild(child);
    112.         XmlAttribute newAttribute = CreateAndroidAttribute("name", "com.android.vending.BILLING");
    113.         child.Attributes.Append(newAttribute);
    114.     }
    115. }
    It's basically the script from here (https://stackoverflow.com/questions/43293173/use-custom-manifest-file-and-permission-in-unity) and only modified the permission line. The script needs to be placed in Assets/Editor/ModifyUnityAndroidAppManifestSample.cs

    Google was satisfied with this and I can now add my IAP products.
     
  13. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Thanks, but I have never needed to modify the manifest and I've published to Google with IAP probably a hundred times, across all versions of IAP.
     
  14. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    I had the same issue.
    The solution was that just uploading the apk is not enough, you have to release it. So I released it as an "Internal test". And boom. I can create IAP
     
    chrisasimako53, cdr9042 and Lexudau like this.
  15. EstacionPi

    EstacionPi

    Joined:
    Sep 17, 2019
    Posts:
    1
    Were you able to create IAP after releasing it or after they reviewed it?
     
  16. Lexudau

    Lexudau

    Joined:
    Apr 7, 2015
    Posts:
    4
    This seems to be my problem and the solution for it. Thank you.
     
  17. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Sigh.. im hit with this issue as well. Haven't been able to fix it yet
     
  18. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Describe your issue and steps to reproduce.
     
  19. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Basically go into Google play console and create a new app. It won't let you create any products.
    "Your app doesn't have any in-app products yet
    To add in-app products, you need to add the BILLING permission to your APK."

    This makes 0 sense. Why would I upload an APK with in app purchases that I haven't created yet?

    If we don't have to manually edit the manifest, then what is the solution? I've enabled Unity IAP and uploaded this (useless) update to internal testing. This didn't resolve the problem.
     
    Last edited: Mar 6, 2021
    AliBuck likes this.
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please don't mulit-post, I answered in your other post.
     
Thread Status:
Not open for further replies.