HyBid Configuration and Integration with Unity Admob support - pubnative/pubnative-hybid-android-sdk GitHub Wiki
- Admob dashboard application : (https://support.google.com/admob/answer/7356219?visit_id=638424684954239459-2748398997&rd=1)
- Unity Hub (preferably latest version) : https://store.unity.com/download?check_logged_in=1
- Follow steps defined in admob dashboard quick start (https://developers.google.com/admob/unity/quick-start) to integrate admob with all its files contained in its unity package(https://github.com/googleads/googleads-mobile-unity/releases/tag/v8.7.0)
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 => { });
}
}
- Follow steps defined here ( https://developers.google.com/admob/unity/banner)
- Follow steps defined here ( https://developers.google.com/admob/unity/interstitial)
- Follow steps defined here (https://developers.google.com/admob/unity/rewarded)
-
Go To File -> Build Settings -> Choose Android -> Player Settings -> Player ... like Below
-
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
-
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
- 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
- Navigate to Assets -> GoogleMobileAds -> Editor -> GoogleUmpDependencies.xml ... it should open in Visual studio Editor like this
- 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.3.0">
<repositories>
<repository>https://verve.jfrog.io/artifactory/verve-gradle-release/</repository>
</repositories>
</androidPackage>
<androidPackage spec="net.pubnative:hybid.adapters.admob:3.3.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
- 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 .
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
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
- Choose the directory you want to build your apk with and then you are done now !!.