- Home /
Soomla Error for android
I have created my own store front with the soomla tutorials. I'm getting an error when I start my game. The script with my store stuff is:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Soomla.Store.Example {
/// <summary>
/// This class defines our game's economy, which includes virtual goods, virtual currencies
/// and currency packs, virtual categories
/// </summary>
public class IAPitems : IStoreAssets{
/// <summary>
/// see parent.
/// </summary>
public int GetVersion() {
return 0;
}
/// <summary>
/// see parent.
/// </summary>
public VirtualCurrency[] GetCurrencies() {
return new VirtualCurrency[]{CREDITS_CURRENCY};
}
/// <summary>
/// see parent.
/// </summary>
public VirtualGood[] GetGoods() {
return new VirtualGood[] {RAINBOW_CHICKEN, HALLOWEEN_CHICKEN, SANTA_CHICKEN, NO_ADS_LTVG};
}
/// <summary>
/// see parent.
/// </summary>
public VirtualCurrencyPack[] GetCurrencyPacks() {
return new VirtualCurrencyPack[] {SMALL_CREDITS_PACK, MEDIUM_CREDITS_PACK, BIG_CREDITS_PACK, MEGA_CREDITS_PACK};
}
/// <summary>
/// see parent.
/// </summary>
public VirtualCategory[] GetCategories() {
return new VirtualCategory[]{GENERAL_CATEGORY};
}
/** Static Final Members **/
public const string CREDITS_CURRENCY_ITEM_ID = "currency_credits";
public const string SMALL_CREDITS_PACK_PRODUCT_ID = "android.test.refunded";
public const string MEDIUM_CREDITS_PACK_PRODUCT_ID = "android.test.canceled";
public const string BIG_CREDITS_PACK_PRODUCT_ID = "android.test.purchased";
public const string MEGA_CREDITS_PACK_PRODUCT_ID = "2500_pack";
public const string RAINBOW_CHICKEN_ITEM_ID = "rainbow_chicken";
public const string HALLOWEEN_CHICKEN_ITEM_ID = "halloween_chicken";
public const string SANTA_CHICKEN_ITEM_ID = "santa_chicken";
public const string NO_ADS_LIFETIME_PRODUCT_ID = "no_ads";
/** Virtual Currencies **/
public static VirtualCurrency CREDITS_CURRENCY = new VirtualCurrency(
"Credits", // name
"", // description
CREDITS_CURRENCY_ITEM_ID // item id
);
/** Virtual Currency Packs **/
public static VirtualCurrencyPack SMALL_CREDITS_PACK = new VirtualCurrencyPack(
"5000 Credits", // name
"Test refund of an item", // description
"5kCredits", // item id
5000, // number of currencies in the pack
CREDITS_CURRENCY_ITEM_ID, // the currency associated with this pack
new PurchaseWithMarket(SMALL_CREDITS_PACK_PRODUCT_ID, 0.99)
);
public static VirtualCurrencyPack MEDIUM_CREDITS_PACK = new VirtualCurrencyPack(
"27500 Credits", // name
"Test cancellation of an item", // description
"27kCredits", // item id
27500, // number of currencies in the pack
CREDITS_CURRENCY_ITEM_ID, // the currency associated with this pack
new PurchaseWithMarket(MEDIUM_CREDITS_PACK_PRODUCT_ID, 4.99)
);
public static VirtualCurrencyPack BIG_CREDITS_PACK = new VirtualCurrencyPack(
"55000 Credits", // name
"Test purchase of an item", // description
"55kCredits", // item id
55000, // number of currencies in the pack
CREDITS_CURRENCY_ITEM_ID, // the currency associated with this pack
new PurchaseWithMarket(BIG_CREDITS_PACK_PRODUCT_ID, 9.99)
);
public static VirtualCurrencyPack MEGA_CREDITS_PACK = new VirtualCurrencyPack(
"120000 Credits", // name
"Test item unavailable", // description
"120kCredits", // item id
120000, // number of currencies in the pack
CREDITS_CURRENCY_ITEM_ID, // the currency associated with this pack
new PurchaseWithMarket(MEGA_CREDITS_PACK_PRODUCT_ID, 19.99)
);
/** LifeTimeVGs **/
// Note: create non-consumable items using LifeTimeVG with PuchaseType of PurchaseWithMarket
public static VirtualGood RAINBOW_CHICKEN = new LifetimeVG(
"Rainbow Chicken", // name
"Unlock the Rainbow Chicken", // description
"rainbow_chick", // item id
new PurchaseWithVirtualItem(CREDITS_CURRENCY_ITEM_ID, 15000)); // the way this virtual good is purchased
public static VirtualGood HALLOWEEN_CHICKEN = new LifetimeVG(
"Halloween Chicken", // name
"Unlock the Halloween Chicken", // description
"halloween_chick", // item id
new PurchaseWithVirtualItem(CREDITS_CURRENCY_ITEM_ID, 30000)); // the way this virtual good is purchased
public static VirtualGood SANTA_CHICKEN = new LifetimeVG(
"Santa Chicken", // name
"Unlock the Santa Chicken", // description
"santa_chicken", // item id
new PurchaseWithVirtualItem(CREDITS_CURRENCY_ITEM_ID, 50000)); // the way this virtual good is purchased
public static VirtualGood NO_ADS_LTVG = new LifetimeVG(
"No Ads", // name
"No More Ads!", // description
"no_ads", // item id
new PurchaseWithMarket(NO_ADS_LIFETIME_PRODUCT_ID, 0.99)); // the way this virtual good is purchased
/** Virtual Categories **/
// The muffin rush theme doesn't support categories, so we just put everything under a general category.
public static VirtualCategory GENERAL_CATEGORY = new VirtualCategory(
"General", new List<string>(new string[] { RAINBOW_CHICKEN_ITEM_ID, HALLOWEEN_CHICKEN_ITEM_ID, SANTA_CHICKEN_ITEM_ID })
);
}
}
The error im getting is: NullReferenceException: Object reference not set to an instance of an object Soomla.Store.SoomlaStore.Initialize (IStoreAssets storeAssets) (at Assets/Plugins/Soomla/Store/SoomlaStore.cs:88) HomeScreen.Start () (at Assets/Scripts/HomeScreen.cs:12)
The line on the HomeScreen script for the error is:
SoomlaStore.Initialize(new Soomla.Store.Example.IAPitems());
Answer by liortal · Nov 22, 2014 at 09:54 PM
I do not know the Soomla framework or plugin, but by looking at their code, it looks like the reference comes from this code inside the Initialize method (SoomlaStore.cs:88):
StoreEvents.Instance.onSoomlaStoreInitialized("", true);
The StoreEvents component is probably added to some game object or prefab that should have been created before accessing it.
Make sure you have this object in your scene.
Your answer
![](https://koobas.hobune.stream/wayback/20220613172143im_/https://answers.unity.com/themes/thub/images/avi.jpg)