Search Unity

Unable to submit build to Xiaomi?

Discussion in 'Unity Build Automation' started by vexe, Feb 16, 2018.

  1. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Greetings,

    we're trying to upload our build to Xiaomi through Unity's Cloud Build but we are unable to do so. We tried both uploading from the editor and the dashboard, in both cases there was no "Push To Xiaomi" option available in the arrow/drop down menu besides the build/apk, only "Download Apk". (View attached screenshots)

    - We're on Unity 2017 1.1p2.
    - We have IAP, Cloud and Collaborate services enabled.
    - Ads services is disabled, we use the dedicated Unity Ads plugin instead as we've had problems with the built-in Ads.
    - We use the latest Unity IAP that has the Xiaomi support in it (Unity Channel plugin etc)
    - We have targeted Xiaomi store in the editor via "Window | Unity IAP | Android | Target Xiaomi Mi Game Play"
    - We have generated the required product file "MiProductCatalog.prop" which contains our in-game products. (File is under Plugins/Android/assets/MiProductCatalog.prop)
    - We have set the package name/bundle identifier to end with ".mi"
    - No Chartboost, Google Play Games, Facebook or any other plugin
    - Implemented the necessary codes for IAP/Unity Channel to work
    - Tried both specifying the AppInfo class in code and via the AppStoreSettings.asset file, didn't make a difference.

    This screenshot shows the menu where the "Push to Xiaomi" option should show but it's not, only "Download APK file"



    This just shows that we have Cloud enabled


    This is the IAP related peice of code:

    Code (csharp):
    1.  
    2.  
    3. public class XLoginListener : ILoginListener
    4. {
    5.     public Action OnInitSuccess;
    6.     public Action<string> OnInitFailure;
    7.     public Action<UserInfo> OnLoginSuccess;
    8.     public Action<string> OnLoginFailure;
    9.  
    10.     public void OnLogin(UserInfo User)
    11.     {
    12.         Debug.LogErrorFormat("[Xiaomi] Login Succeed: userId {0}, userLoginToken {1}, channel {2}",
    13.             User.userId, User.userLoginToken, User.channel);
    14.         OnLoginSuccess.SafeInvoke(User);
    15.     }
    16.  
    17.     public void OnInitialized()
    18.     {
    19.         Debug.LogError("[Xiaomi] Initialization Succeed");
    20.         OnInitSuccess.SafeInvoke();
    21.     }
    22.  
    23.     public void OnInitializeFailed(string Message)
    24.     {
    25.         Debug.LogError("[Xiaomi] Initialization Failed: " + Message);
    26.         OnInitFailure.SafeInvoke(Message);
    27.     }
    28.  
    29.     public void OnLoginFailed(string Message)
    30.     {
    31.         Debug.LogError("[Xiaomi] Login Failed: " + Message);
    32.         OnLoginFailure.SafeInvoke(Message);
    33.     }
    34. }
    35.  
    36. public class XPlatformDef
    37. {
    38.     public XLoginListener LoginListener;
    39. }
    40.  
    41. XPlatformDef XPlatform;
    42.  
    43. void Xiaomi_Init()
    44. {
    45.     StandardPurchasingModule Module = StandardPurchasingModule.Instance();
    46.     ConfigurationBuilder Builder = ConfigurationBuilder.Instance(Module);
    47.  
    48.     ProductCatalog Catalog = ProductCatalog.LoadDefaultCatalog();
    49.     foreach (ProductCatalogItem Product in Catalog.allProducts)
    50.     {
    51.         if (Product.allStoreIDs.Count > 0)
    52.         {
    53.             IDs IdList = new IDs();
    54.             foreach (StoreID ID in Product.allStoreIDs)
    55.             {
    56.                 IdList.Add(ID.id, ID.store);
    57.             }
    58.             Builder.AddProduct(Product.id, Product.type, IdList);
    59.         }
    60.         else
    61.         {
    62.             Builder.AddProduct(Product.id, Product.type);
    63.         }
    64.     }
    65.  
    66.     //NOTE(Ali): the process is as follows:
    67.     // - initialize Xiaomi store via StoreService.Initialize
    68.     // - on success, initialize Xiaomi login
    69.     // - on success, initialize Unity IAP
    70.     XPlatform = new XPlatformDef();
    71.     XPlatform.LoginListener = new XLoginListener();
    72.     XPlatform.LoginListener.OnInitSuccess = () =>
    73.     {
    74.         StoreService.Login(XPlatform.LoginListener);
    75.     };
    76.     XPlatform.LoginListener.OnLoginSuccess = (UserInfo User) =>
    77.     {
    78.         UnityPurchasing.Initialize(MobilePlatform.Purchasing, Builder);
    79.     };
    80.  
    81.     #if (!UNITY_EDITOR)
    82.     {
    83.         AppInfo App = Xiaomi_GetAppInfo();
    84.         StoreService.Initialize(App, XPlatform.LoginListener);
    85.     }
    86.     #endif
    87. }
    88.  
    89. AppInfo Xiaomi_GetAppInfo()
    90. {
    91.     AppInfo Result;
    92.        
    93.     Result = new AppInfo();
    94.     Result.appId = "<actual app id>";
    95.     Result.appKey = "<actual app key>";
    96.     Result.clientId = "<actual client id>";
    97.     Result.clientKey = "<actual client key>";
    98.     Result.debug = true;
    99.  
    100.     //Tried this, thought it would make a difference in detecting the build and be able to push, didn't matter much.
    101.     //AppStoreSettings Settings = Resources.Load<AppStoreSettings>("AppStoreSettings");
    102.     //Result = Settings.getAppInfo();
    103.  
    104.     return(Result);
    105. }
    106.  
    I'm not sure what we're missing or doing wrong here. If anyone has any idea/hints/tips/pointers it would be much appreciated.

    Thanks.
     
  2. rachelgarza

    rachelgarza

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    29
    Hi,
    Sorry you're having a rough time with this! Just to help troubleshoot; is the user who is attempting to submit to Xiaomi the owner of the organization that project is under?
     
  3. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @rachelgarza Thank you very much! That was it.

    We spend approximately 6 hours yesterday messing around with this, reading documentation and getting frustrated with the support staff, and nowhere was this crucial point happened to be mentioned...
     
  4. rachelgarza

    rachelgarza

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    29
    Great! Glad that solved it for you. You're right, the documentation could definitely use some clarification on that... Will work on getting it updated ASAP.

    Thanks!