public static void initialize(final Activity activity,final String gameId,final IUnityAdsListener listener,final boolean testMode){
  DeviceLog.entered();
  if (_configurationInitialized) {
    return;
  }
  _configurationInitialized=true;
  if (gameId == null || gameId.length() == 0) {
    DeviceLog.error("Error while initializing Unity Ads: empty game ID, halting Unity Ads init");
    if (listener != null) {
      listener.onUnityAdsError(UnityAdsError.INVALID_ARGUMENT,"Empty game ID");
    }
    return;
  }
  if (activity == null) {
    DeviceLog.error("Error while initializing Unity Ads: null activity, halting Unity Ads init");
    if (listener != null) {
      listener.onUnityAdsError(UnityAdsError.INVALID_ARGUMENT,"Null activity");
    }
    return;
  }
  if (testMode) {
    DeviceLog.info("Initializing Unity Ads " + SdkProperties.getVersionName() + " ("+ SdkProperties.getVersionCode()+ ") with game id "+ gameId+ " in test mode");
  }
 else {
    DeviceLog.info("Initializing Unity Ads " + SdkProperties.getVersionName() + " ("+ SdkProperties.getVersionCode()+ ") with game id "+ gameId+ " in production mode");
  }
  setDebugMode(_debugMode);
  ClientProperties.setGameId(gameId);
  ClientProperties.setListener(listener);
  ClientProperties.setApplicationContext(activity.getApplicationContext());
  SdkProperties.setTestMode(testMode);
  if (EnvironmentCheck.isEnvironmentOk()) {
    DeviceLog.info("Unity Ads environment check OK");
  }
 else {
    DeviceLog.error("Error during Unity Ads environment check, halting Unity Ads init");
    if (listener != null) {
      listener.onUnityAdsError(UnityAdsError.INIT_SANITY_CHECK_FAIL,"Unity Ads init environment check failed");
    }
    return;
  }
  Configuration configuration=new Configuration();
  Class[] apiClassList={com.unity3d.ads.api.AdUnit.class,com.unity3d.ads.api.Broadcast.class,com.unity3d.ads.api.Cache.class,com.unity3d.ads.api.Connectivity.class,com.unity3d.ads.api.DeviceInfo.class,com.unity3d.ads.api.Listener.class,com.unity3d.ads.api.Storage.class,com.unity3d.ads.api.Sdk.class,com.unity3d.ads.api.Request.class,com.unity3d.ads.api.Resolve.class,com.unity3d.ads.api.VideoPlayer.class,com.unity3d.ads.api.Placement.class,com.unity3d.ads.api.Intent.class};
  configuration.setWebAppApiClassList(apiClassList);
  InitializeThread.initialize(configuration);
}

public static void initialize ( final Activity activity , final String gameId , final IUnityAdsListener listener , final boolean testMode ) { DeviceLog . entered ( ) ; if ( _configurationInitialized ) { return ; } _configurationInitialized = true ; if ( gameId == null || gameId . length ( ) == 0 ) { DeviceLog . error ( "Error while initializing Unity Ads: empty game ID, halting Unity Ads init" ) ; if ( listener != null ) { listener . onUnityAdsError ( UnityAdsError . INVALID_ARGUMENT , "Empty game ID" ) ; } return ; } if ( activity == null ) { DeviceLog . error ( "Error while initializing Unity Ads: null activity, halting Unity Ads init" ) ; if ( listener != null ) { listener . onUnityAdsError ( UnityAdsError . INVALID_ARGUMENT , "Null activity" ) ; } return ; } if ( testMode ) { DeviceLog . info ( "Initializing Unity Ads " + SdkProperties . getVersionName ( ) + " (" + SdkProperties . getVersionCode ( ) + ") with game id " + gameId + " in test mode" ) ; } else { DeviceLog . info ( "Initializing Unity Ads " + SdkProperties . getVersionName ( ) + " (" + SdkProperties . getVersionCode ( ) + ") with game id " + gameId + " in production mode" ) ; } setDebugMode ( _debugMode ) ; ClientProperties . setGameId ( gameId ) ; ClientProperties . setListener ( listener ) ; ClientProperties . setApplicationContext ( activity . getApplicationContext ( ) ) ; SdkProperties . setTestMode ( testMode ) ; if ( EnvironmentCheck . isEnvironmentOk ( ) ) { DeviceLog . info ( "Unity Ads environment check OK" ) ; } else { DeviceLog . error ( "Error during Unity Ads environment check, halting Unity Ads init" ) ; if ( listener != null ) { listener . onUnityAdsError ( UnityAdsError . INIT_SANITY_CHECK_FAIL , "Unity Ads init environment check failed" ) ; } return ; } Configuration configuration = new Configuration ( ) ; Class [ ] apiClassList = { com . unity3d . ads . api . AdUnit . class , com . unity3d . ads . api . Broadcast . class , com . unity3d . ads . api . Cache . class , com . unity3d . ads . api . Connectivity . class , com . unity3d . ads . api . DeviceInfo . class , com . unity3d . ads . api . Listener . class , com . unity3d . ads . api . Storage . class , com . unity3d . ads . api . Sdk . class , com . unity3d . ads . api . Request . class , com . unity3d . ads . api . Resolve . class , com . unity3d . ads . api . VideoPlayer . class , com . unity3d . ads . api . Placement . class , com . unity3d . ads . api . Intent . class } ; configuration . setWebAppApiClassList ( apiClassList ) ; InitializeThread . initialize ( configuration ) ; }
initializes unity ads . unity ads should be initialized when app starts .
