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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Soomla Works in editor but do nothing in Android Build

Discussion in 'Scripting' started by Yash987654321, Aug 19, 2015.

  1. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    I want to add IAPs in my game. I tried Soomla and it works perfectly in editor. I can click buy and i get my purchase. But in Android build I get no result. When I click the buy button nothing happens. Rarely a lag but no more than that. It do not launches the Purchase Window or anything at all. I have already made it for Beta Testing in the Dev Console.
    Here's my code
    Code (CSharp):
    1. public TextMesh DebugText;
    2. public MainScript Main;
    3. void Start()
    4.     {
    5.         StoreEvents.OnMarketPurchase += OnPurchase;
    6.         SoomlaStore.Initialize(new SoomlaAssets());
    7.         SoomlaStore.StartIabServiceInBg();
    8.     }
    9. public void Purchase(int BuyableID)
    10.     {
    11.         DebugText.text = "Purchasing";
    12.         for(int i = 0;i<Buyables.Length;i++)
    13.         {
    14.             if(Buyables[i].AcessID == BuyableID)
    15.             {
    16.                 SoomlaStore.BuyMarketItem(Buyables[i].ProductID,"Pruchase Completed!");
    17.             }
    18.         }
    19.         }
    20. void OnPurchase(VirtualItem pvi,string payload,System.Collections.Generic.Dictionary<string,string> extra)
    21.     {
    22.         DebugText.text = "Purchased!";
    23.         for(int i = 0;i<Buyables.Length;i++)
    24.         {
    25.             if(pvi.ID == Buyables[i].ItemID)
    26.             {
    27.                 Main.Themes[Buyables[i].CharacterID].Unlocked = true;
    28.             }
    29.         }
    30.         Main.Save();
    31.     }
    32. [System.Serializable]
    33. public struct Buyable
    34. {
    35. #if UNITY_EDITOR
    36.     [Tooltip("Do not have any real purpose, Just for the editor")]
    37.     public string CharacterName;
    38. #endif
    39.     [Tooltip("This should be the Purchase functions paramater")]
    40.     public int AcessID;
    41.     [Tooltip("This should be the ID(index) of Themes you want to purchase")]
    42.     public int CharacterID;
    43.     [Tooltip("Same as defiended in Economy Builder")]
    44.     public string ProductID;
    45.     [Tooltip("Same as defiended in Economy Builder")]
    46.     public string ItemID;
    47. }
    48.  
    I call Purchase(int) from the UnityUI. It
    works perfectly in the Editor but nothing in build. Also I havent added Play Services in my game in any case if they are required to make a purchase.
    Thanks :D
     
    Last edited: Aug 19, 2015
  2. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
  3. Marceta

    Marceta

    Joined:
    Aug 5, 2013
    Posts:
    177
    Try to log your game and post it here. Also check your manifest if it include Soomla.
     
  4. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    It may sound silly but how can I find/make the log lol :p. My Unity Remote won't work...... I will upload the in editor log soon and will check the manifest
    Thanks :D
     
  5. Marceta

    Marceta

    Joined:
    Aug 5, 2013
    Posts:
    177
    Plugin your device using usb and start monitor.exe which is located inside android sdk. Also start your game and try to buy something, there should be some informations on log. You will see real time log from your device which you can save as txt file.
    http://developer.android.com/tools/help/monitor.html
    C:\Program Files (x86)\Android\android-sdk\tools\lib\monitor-x86_64 [My location]

    Also you will have to enable usb debugging on your device and install adb drivers for your device on pc.

    This is how the application look like:
     
    DonLoquacious likes this.
  6. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    Hi I tried it and I also saw my device listed in available devices debug mode was on.... But I tried it but and I did not saw anything in the log. I will try again soon. Thanks for that :)
     
  7. jgb143

    jgb143

    Joined:
    Jun 8, 2010
    Posts:
    132
    Did you get it from the asset store? Because I had to update some of the files from their githut page. You are probably best to get it from there. Soomla was a pain to setup, and their tutorials seem like they think you already know how to use it, but once it was working it just worked and worked well.

    Oh yeah, one other important thing. Don't 'build and run'. Just build and then copy the apk to your phone manually.
     
  8. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    Thanks I'll update it.... And I did not build and run it. I knew about it :)
     
  9. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    @jgb143 unfortunately Updating Soomla did not worked. Though I greatly reduced the compile time :D.
    @Marceta I was somehow able to run the test and here is my log

    08-23 09:48:26.120: E/AudioResampler(251): Unsupported sample format, 1 bits, 2 channels
    08-23 09:48:26.890: E/SMD(239): DCD ON
    08-23 09:48:27.440: E/dalvikvm(7552): Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.showErrorDialogFragment
    08-23 09:48:27.440: E/dalvikvm(7552): Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.showErrorDialogFragment
    08-23 09:48:27.610: E/SOOMLA AESObfuscator(7552): You didn't provide a SOOMLA secret!!! Stopping now!
    08-23 09:48:27.860: E/SOOMLA SoomlaStore(7552): ERROR: SoomlaStore failure: You don't have a billing service attached. Decide which billing service you want, add it to AndroidManifest.xml and add its jar to the path.
    08-23 09:48:27.870: E/Unity(7552): SOOMLA SoomlaStore Couldn't load billing service! Billing functions won't work.
    08-23 09:48:27.870: E/Unity(7552):
    08-23 09:48:27.870: E/Unity(7552): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)
    08-23 09:48:29.890: E/SMD(239): DCD ON
    08-23 09:48:30.800: E/SamsungIME(2005): isHWKeyboardConnected() = false --> false
    08-23 09:48:30.840: E/SmartFaceService(790): onReceive: android.intent.action.CONFIGURATION_CHANGED
    08-23 09:48:30.840: E/SmartFaceService(790): mFolderCoverOpened: (true, true) -> true
    08-23 09:48:32.890: E/SMD(239): DCD ON
    08-23 09:48:34.280: E/SOOMLA SoomlaStore(7552): Billing service is not loaded. Can't invoke buyWithMarket.
    08-23 09:48:35.890: E/SMD(239): DCD ON
    08-23 09:48:38.890: E/SMD(239): DCD ON

    The only thing I understood here is that I did not provided the Soomla Secret but I did it in the Settings. I really don't know what is it (even after reading their docs) so I entered a random string if in any case we want a particular syntax based key please let me know where can we find it.
    Thanks :D
     

    Attached Files: