HyBid Configuration and Integration with Unity Admob support - pubnative/pubnative-hybid-android-sdk GitHub Wiki

Prerequisites

Steps

Note : You can ignore the below C# initialisation script part about admob because it will be initialised later with each ad type

using GoogleMobileAds.Api;
...
public class GoogleMobileAdsDemoScript : MonoBehaviour
{
    public void Start()
    {
        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(initStatus => { });
    }
}

Banner

Interstitial

Rewarded

Android Configuration for successful build

  • Go To File -> Build Settings -> Choose Android -> Player Settings -> Player ... like Below 111 2222 3333

  • Change company name and product name (name of apk which will be installed on your android device ) with your indicated values

  • Change package name with the same package name defined in admob dashboard application to prevent conflicts or no fill ads

  • Change Scripting Backend to IL2CPP and check ARMv7 and ARM64 checkboxes

  • In Build Section ,check Custom Main Gradle Template ,Custom Gradle Properties Template and Custom Gradle Settings Template

After doing the last configurations ,close Player Settings window and back to the window below

4444

  • choose Android -> Switch Platform -> Wait until resolving all dependencies and then close this window

  • To avoid popular unity issue ,navigate to Unity -> Settings -> External Tools ... uncheck all checkboxes under Android like below but keep the values themselves like below

9999

HyBid Integration

  • Once admob unity package is successfully imported and you do not have any errors ,so you are in the right place now .If you have any errors ,please resolve it before resuming

Steps

  • Navigate to project tab in your unity editor like below 555
  • Navigate to Assets -> GoogleMobileAds -> Editor -> GoogleUmpDependencies.xml ... it should open in Visual studio Editor like this 6666
  • replace the whole file with the code below
<dependencies>
  <androidPackages>
    <androidPackage spec="com.google.android.ump:user-messaging-platform:2.1.0">
      <repositories>
        <repository>https://maven.google.com/</repository>
      </repositories>
    </androidPackage>
    <androidPackage spec="net.pubnative:hybid.sdk:3.0.0">
			<repositories>
				<repository>https://verve.jfrog.io/artifactory/verve-gradle-release/</repository>
			</repositories>
		</androidPackage>
		<androidPackage spec="net.pubnative:hybid.adapters.admob:3.0.0">
			<repositories>
				<repository>https://verve.jfrog.io/artifactory/verve-gradle-release/</repository>
			</repositories>
		</androidPackage>
  </androidPackages>
</dependencies>
  • Save GoogleUmpDependencies.xml and then close it
  • Back to Unity Editor -> Assets -> External Dependency Manager -> Android Resolver -> Resolve 7777
  • After successful build ,you may find dialog to Enable Resolution ,you can easily enable it
  • Then again Assets -> External Dependency Manager -> Android Resolver -> Force Resolve to validate that dependencies are added successfully to your android template
  • Check step : Navigate to Assets -> Plugins -> Android -> mainTemplate.gradle ... you should find HyBid SDK and Admob adapter added there
  • If you come to this step ,then all the integrations are done now and you can move to design part .

Design

If you are familiar with unity you can skip this part and create your own panel and attach scripts like normal way steps

  • Create PanelContainer and you adjust with width and height with whatever values you like (it will act as a parent for all buttons created later)
  • Add Button Text Mesh pro and call it Banner
  • Add Button Text Mesh pro and call it Interstitial
  • Add Button Text Mesh pro and call it Rewarded Previously you already created Banner ,interstitial and rewarded scripts as followed in admob quick start guide
  • Attach script to each relevant button using Add Component in right panel

Build Android APK

When you come to this step ,it should the final step of integration HyBid SDK with unity admob adapters

  • Navigate to File -> Build Settings -> Android -> Switch Platform ( if current platform is not Android)
  • Navigate to Build -> Clean Build like Below

8888

  • Choose the directory you want to build your apk with and then you are done now !!.
⚠️ **GitHub.com Fallback** ⚠️