// Set the parent ad unit's ID for all ad units to be created under.
String effectiveRootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();
// Create local ad unit object.
AdUnit adUnit = new AdUnit();
adUnit.setName("Mobile_Ad_Unit");
adUnit.setParentId(effectiveRootAdUnitId);
adUnit.setDescription("Ad unit description.");
adUnit.setTargetWindow(AdUnitTargetWindow.BLANK);
adUnit.setTargetPlatform(TargetPlatform.MOBILE);
adUnit.setMobilePlatform(MobilePlatform.APPLICATION);
// Create ad unit size.
AdUnitSize adUnitSize = new AdUnitSize();
adUnitSize.setSize(new Size(400, 300, false));
adUnitSize.setEnvironmentType(EnvironmentType.BROWSER);
// Set the size of possible creatives that can match this ad unit.
adUnit.setAdUnitSizes(new AdUnitSize[] {adUnitSize});
// Create the ad unit on the server.
adUnit = inventoryService.createAdUnit(adUnit);
if (adUnit != null) {
System.out.println("An ad unit with ID \"" + adUnit.getId()
+ "\" was created under parent with ID \"" + adUnit.getParentId()
+ "\".");
} else {
System.out.println("No ad units created.");
}
} catch (Exception e) {