{"_id":"563b50349e3f2225009fd296","__v":69,"parentDoc":null,"version":{"_id":"5429beef1163360800ed31fd","__v":21,"project":"5429beef1163360800ed31fa","createdAt":"2014-09-29T20:19:59.904Z","releaseDate":"2014-09-29T20:19:59.904Z","categories":["5429beef1163360800ed31fe","55e74e1f5d36b32b002563fa","55e7500a73169617001f2e86","55e76b8196131b2f00bf4b72","55e89569cdbb8a350096df9c","55f8935eb089b71700a8364e","55f8a67d3bb4bb0d0022d093","55f9dbefc7ef770d00d9bf6d","5601c21a22ecf60d002b27b3","5601c21ff12aee0d001bb06e","5601c2256c7b610d00280db5","5601c22c22ecf60d002b27b4","5603738d0c78b00d0039af47","5626f70bfcbbc621004ebf52","566f7a1ae144ab0d00e9732f","566f85ca7820960d00c3b93d","56708ce43a32d20d00c45cbf","56708d436995210d003aad8e","5736471abe10a9200030732c","57a82c7aff9bd30e00a6f1c1","591b8500e3992319007190f4"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"566f85ca7820960d00c3b93d","pages":[],"project":"5429beef1163360800ed31fa","version":"5429beef1163360800ed31fd","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-15T03:15:22.182Z","from_sync":false,"order":3,"slug":"integrating-for-apps","title":"Integrating for Apps"},"project":"5429beef1163360800ed31fa","user":"563b4a20dfa1282b000dd262","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-11-05T12:48:52.406Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Welcome to AdsNative Android SDK documentation. Please check out the \"Getting Started\" section below before integrating your app with the SDK.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Getting Started\"\n}\n[/block]\nThis section explains the process of including AdsNative SDK in your Android application and setting dependencies.\n\n** Prerequisites and Dependencies **\n\n  * Android version 4.0.3 (API 15) and above\n\nAdd following to your build.gradle\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"dependencies {\\n    compile 'com.android.support:support-v4:22.2.1'\\n    compile 'com.android.support:appcompat-v7:22.2.1'\\n    compile 'com.android.support:recyclerview-v7:22.2.1'\\n    compile 'com.google.android.gms:play-services:7.8.0'\\n}\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\n**Including AdsNative SDK in your Android project**\n\nClick [**here**](https://github.com/picatcha/adsnative-sdk-android/archive/master.zip) to download the SDK as zipped source. Extract **adsnative_sdk_2.0.0.aar** from <unzipped>/adsnative_sdk/ location and place it under your project's libs folder (create libs if not already done).\n\nAdd the compiled .aar to your build.gradle file as below.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"repositories {\\n    flatDir {\\n        dirs 'libs'\\n    }\\n}\\n// ...\\ndependencies {\\n    compile(name:'adsnative_sdk_2.0.0', ext:'aar')\\n}\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\n**Required Permissions in Android Manifest**\nFollowing permissions are mandatory. Please add them to your AndroidManifest.xml file.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<uses-permission android:name=\\\"android.permission.INTERNET\\\" />\\n<uses-permission android:name=\\\"android.permission.ACCESS_NETWORK_STATE\\\" />\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n**Recommended Permissions in Android Manifest**\nWe recommend adding following permissions to your AndroidManifest.xml.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<uses-permission android:name=\\\"android.permission.ACCESS_COARSE_LOCATION\\\" />\\n<uses-permission android:name=\\\"android.permission.ACCESS_FINE_LOCATION\\\" />\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n**ProGuard**\nAdsNative SDK is already obfuscated and minified using ProGuard. If you are running ProGuard on your Android application, please add the following to your ProGuard configuration file.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"-keep class com.adsnative.** { *; }\\n-dontwarn com.adsnative.**\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Native Ads Integration\"\n}\n[/block]\nImport AdsNative SDK classes into your activity by adding the following line of code to the imports section of the your activity class.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import com.adsnative.ads.*;\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nAdsNative SDK supports following ad formats. Depending on your requirement and the type of app you have, you can choose one of the below methods.\n\n  * [**Content Stream Ads**](http://dev.adsnative.com/docs/android-sdk#content-stream-ads) - These are ads that appear as part of a content stream. For Android, we support the RecyclerView and TableView/GridView layouts. If your app is using adapter to show content stream then we highly recommend using this integration.\n  * [**Standard Integration (Single Native Ad)**](http://dev.adsnative.com/docs/android-sdk#standard-integration) - If you have a custom requirement or would like to stitch the native ad assets yourself, AdsNative SDK supports this by requesting a single native ad\n\n**Integrating Other Networks**\nIf you wish to add other networks for mediation, [**click here**](http://dev.adsnative.com/docs/android-sdk#integrating-other-networks) to know how to do this.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Content Stream Ads\"\n}\n[/block]\nTo display ads in content stream, you just need to implement following 3 simple steps.\n1. Define ad layout(s)\n2. Define ad positions\n3. Create AdsNative custom adapter object and start loading ads\n\nDepending on which type of stream you want to load native ads into, see one of the below sections\n  * [**Recycler View Integration**](http://dev.adsnative.com/docs/android-sdk#recycler-view-integration)\n  * [**List or Grid View Integration**](http://dev.adsnative.com/docs/android-sdk#list-or-grid-view-integration)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Recycler View Integration\"\n}\n[/block]\nIf your Android application uses RecyclerView to show the content, you can use our SDK's RecyclerView wrapper class *ANRecyclerView* to load native ads.\n\n1. Create an instance of *ANRecyclerAdapter* class before onCreate() method so you can use the object to load ads later.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"private ANRecyclerAdapter anRecyclerAdapter;\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n2. Define Ad Layout\nCheck [**this section**](http://dev.adsnative.com/docs/android-sdk#native-ad-layout) for defining native ad layouts and dynamic layout switching.\n\n3. Define Ad Positions\nCheck [**this section**](http://dev.adsnative.com/docs/android-sdk#ad-positions) for defining server ad positions and client ad positions.\n\n4. Create *ANRecyclerAdapter* object and begin loading ads\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \":::at:::Override\\npublic View onCreate(...) {\\n    // ...\\n    // ...\\n    // create ANRecyclerAdapter object\\n    anRecyclerAdapter = new ANRecyclerAdapter(this, adapter,\\n                                      AD_UNIT_ID, serverPositions);\\n    // Register the renderer with the ANRecyclerAdapter\\n    anRecyclerAdapter.registerViewBinder(anAdViewBinder);\\n    // Set your original view's adapter to ANRecyclerAdapter instance\\n    listView.setAdapter(anRecyclerAdapter);\\n    // Start loading ads\\n    anRecyclerAdapter.loadAds();\\n}\\n\\n@Override\\npublic void onResume() {\\n    // We recommend loading new ads when the user returns to your activity\\n    anRecyclerAdapter.loadAds();\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"List or Grid View Integration\"\n}\n[/block]\nIf your Android application uses ListView or GridView or any view that uses Adapter, we recommend you to use our SDK's adapter class *ANListAdapter* to load native ads.\n\n1. Create an instance of *ANListAdapter* class before onCreate() method so you can use the object to load ads later.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"private ANListAdapter anListAdapter;\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n2. Define Ad Layout\nCheck [**this section**](http://dev.adsnative.com/docs/android-sdk#native-ad-layout) for defining native ad layouts and dynamic layout switching.\n\n3. Define Ad Positions\nCheck [**this section**](http://dev.adsnative.com/docs/android-sdk#ad-positions) for defining server ad positions and client ad positions.\n\n4. Create *ANListAdapter* object and begin loading ads\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\n@Override\\npublic View onCreate(...) {\\n    // ...\\n    // ...\\n    // create ANListAdapter object\\n    anListAdapter = new ANListAdapter(this, adapter,\\n                                      AD_UNIT_ID, serverPositions);\\n    // Register the renderer with the ANListAdapter\\n    anListAdapter.registerViewBinder(anAdViewBinder);\\n    // Set your original view's adapter to ANListAdapter instance\\n    listView.setAdapter(anListAdapter);\\n    // Start loading ads\\n    anListAdapter.loadAds();\\n}\\n\\n@Override\\npublic void onResume() {\\n    // We recommend loading new ads when the user returns to your activity\\n    anListAdapter.loadAds();\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Standard Integration\"\n}\n[/block]\nIf you are looking to load ads manually instead of using our RecyclerView or ListView wrappers, or if your Android application is not built using RecyclerView or ListView, then you can follow the integration steps below to manually load and render ads.\n\n1. Create an instance of *ANNativeAd* class before onCreate() method so you can use the object to load ads later.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"private ANNativeAd mNativeAd;\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n2. Initialize the instance and set listener for ad callbacks inside your *onCreate()* method\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"mNativeAd = new ANNativeAd(this, <AD_UNIT_ID>);\\nmNativeAd.setNativeAdListener(new ANAdListener() {\\n    @Override\\n    public void onAdLoaded(NativeAdUnit nativeAdUnit) {\\n    }\\n  \\n    @Override\\n    public void onAdFailed(String message) {\\n    }\\n\\n    @Override\\n    public void onAdImpressionRecorded() {\\n    }\\n  \\n    @Override\\n    public void onAdClicked() {\\n    }\\n});\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n3. Start loading ads in your *onStart()* and *onResume()* methods by adding the following line of code.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@Override\\npublic void onResume() {\\n    mNativeAd.loadAd();\\n    // ...\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n4. The next step is to extract the ad assets and build your custom UI for displaying native ads. Override the *onAdLoaded()* method as set in your ad listener above to retrieve the ad assets.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@Override\\npublic void onAdLoaded(NativeAdUnit nativeAdUnit) {\\n    String title = nativeAdUnit.getTitle();\\n    String summary = nativeAdUnit.getSummary();\\n    String iconImage = nativeAdUnit.getIconImage();\\n    String mainImage = nativeAdUnit.getMainImage();\\n    String cta = nativeAdUnit.getCallToAction();\\n\\n    // Define your custom layout and start loading assets into it\\n    // ...\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n5. AdsNative SDK internally handles impression and click tracking. You only need to register your ad view with the SDK as below.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"mNativeAd.attachViewForInteraction(nativeAdUnit, <NATIVE_AD_VIEW>);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nAlternatively, you can let the SDK handle loading assets into the layout defined by you and create an ad view. We recommend this approach as it's much cleaner and it only requires for you to define the layout XML.\n\nCheck [**this section**](http://dev.adsnative.com/docs/android-sdk#native-ad-layout) for defining ad layout.\n\nOnce you have defined the layout and registered the view binder, you can override *onAdLoaded()* method and add the following line to create ad view with the assets into the layout defined by you.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@Override\\npublic void onAdLoaded(NativeAdUnit nativeAdUnit) {\\n    View nativeAdView = mNativeAd.renderAdView(nativeAdUnit);\\n    // the above method only creates the ad view, you need to add the view to your container as desired\\n    <your_container_object>.addView(nativeAdView);\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nSince SDK is handling the creation of ad view, it implicitly takes care of tracking impressions and clicks.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Native Ad Layout\"\n}\n[/block]\nYou can define any custom layout for how your native ad should look within your app content. SDK will use this layout to load ads into it.\n\nStart by defining XML layout, the default assets available are title, summary, icon image, main image and call to action. Place the XML under **res/layout/<native_ad_layout>.xml** of your Android project.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"final ANAdViewBinder anAdViewBinder = new\\n  ANAdViewBinder.Builder(R.layout.<NATIVE_AD_LAYOUT_XML>)\\n  \\t.bindTitle(R.id.<title>)\\n\\t\\t.bindSummary(R.id.<summary>)\\n\\t\\t.bindIconImage(R.id.<iconImage>)\\n\\t\\t.bindMainImage(R.id.<mainImage>)\\n\\t\\t.bindCallToAction(R.id.<callToAction>)\\n\\t\\t.bindPromotedBy(R.id.<promotedBy>)\\n\\t\\t.build();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nOnce layout xml is defined, you need to register the same through with SDK, through *ANViewBinder*, which will take care of rendering the ads into the layout.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// For RecyclerView integration\\nanRecyclerAdapter.registerViewBinder(anAdViewBinder);\\n\\n// For List or Grid View integration\\nanListAdapter.registerViewBinder(anAdViewBinder);\\n\\n// For standard (single native ad) integration\\nmNativeAd.registerViewBinder(anAdViewBinder);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n**Dynamic Layout Switching**\n\nAdsNative SDK has the ability to dynamically switch between multiple ad layouts through just a click on the UI.\n\nDynamic layouts is enabled by default for every ad placement. Following steps are required during the integration to make use of dynamic layouts.\n\n1. Define all layout XMLs that you want to dynamically switch between. For example, if you have 4 layouts you would like to dynamically switch between then you need to create 4 XMLs and place them under **/res/layout/** of your Android project.\n\n2. Define layouts with default R.ids for assets for ease of integration. Please check the snippet below.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<TextView android:id=\\\"@+id/an_title\\\"\\n          .../>\\n<TextView android:id=\\\"@+id/an_summary\\\"\\n          .../>\\n<ImageView android:id=\\\"@+id/an_icon_image\\\"\\n          .../>\\n<ImageView android:id=\\\"@+id/an_main_image\\\"\\n          .../>\\n<Button android:id=\\\"@+id/an_call_to_action\\\"\\n          .../>\\n<TextView android:id=\\\"@+id/an_promoted_by\\\"\\n          .../>\\n<!--\\nan_title -> for title\\nan_summary -> for summary or description\\nan_icon_image -> icon image that appears usually top left\\nan_main_image -> large image that appears usually in the center\\nan_call_to_action -> cta or call-to-action button\\nan_promoted_by -> this is a sponsored by tag (mandatory)\\n-->\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n3. Register view binder using *bindAssetsWithDefaultKeys()* method. This method automatically binds assets using the default R.ids specified in the layout above.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"final ANAdViewBinder anAdViewBinder = new\\n  ANAdViewBinder.Builder(R.layout.<NATIVE_AD_LAYOUT_XML>)\\n  \\t.bindAssetsWithDefaultKeys(this)\\n\\t\\t.build();\\nmNativeAd.registerViewBinder(anAdViewBinder);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nNOTE: If you wish to use custom R.ids, you may do so. In which case you will not be able to use *bindAssetsWithDefaultKeys()*, you will have to use respective bind methods as shown in the beginning of the section. However, for dynamic layouts to work, you need to use same custom R.ids across all your XML layouts and also ensure you are binding all assets irrespective of which and how many assets are used in the currently active layout.\n\n**Backup Layouts**\n\nAdsNative SDK may sometimes serve ads without icon image. If you are using icon in one of your layouts, it will be blank in such cases. To counter this, SDK has a feature built-in to fallback automatically into a backup layout (if defined).\nTo make use of backup layouts, you need to define the xml with the same name as your original layout with _backup suffix added to it. For example, if your original layout file is named as **native_ad_layout.xml** then your backup layout should be named as **native_ad_layout_backup.xml**\n\n**Custom Assets**\n\nIf you have direct-sold native ads, AdsNative allows you to setup additional custom assets (text and/or images) which you can extract or render using the SDK.\nOnce you had setup additional assets in the UI, add them to your layout XML file(s) and bind them as shown below.\n(Example shown below assumes **customText** and **customImage** keys added in UI and **R.id.custom_text** and **R.id.custom_image** added to layout XML)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"final ANAdViewBinder anAdViewBinder = new\\n  ANAdViewBinder.Builder(R.layout.<NATIVE_AD_LAYOUT_XML>)\\n  \\t.bindAssetsWithDefaultKeys(this)\\n    .bindCustomField(\\\"customText\\\", R.id.custom_text\\n    .bindCustomField(\\\"customImage\\\", R.id.custom_image\\n\\t\\t.build();\\nmNativeAd.registerViewBinder(anAdViewBinder);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nSDK internally takes care of rendering the custom assets as per the layout specified. But if if you are using standard integration and want to extract custom assets to bind and render on your own, then you can do so as shown below.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"@Override\\npublic void onAdLoaded(NativeAdUnit nativeAdUnit) {\\n    Object customText = nativeAdUnit.getCustomField(\\\"customText\\\");\\n    // for images, the source url is returned\\n    Object customImage = nativeAdUnit.getCustomField(\\\"customImage\\\");\\n    \\n    // you can also extract all custom assets at once into a map and extract using the keys as specified in the UI\\n    Map<String, Object> customFields = nativeAdUnit.getCustomFields();\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n**Video Ads**\n\nAdsNative SDK supports showing video assets in-line with autoplay. To enable this you need to use **View** class to define the asset in your layout, instead of ImageView. Inline Video is usually shown in place of main image.\n\nSample layout XML definition for video\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<View android:id=\\\"@+id/an_video\\\"\\n    android:layout_width=\\\"match_parent\\\"\\n    android:layout_height=\\\"200dp\\\"\\n    android:background=\\\"@null\\\"\\n    android:layout_marginTop=\\\"10dp\\\"\\n    android:layout_marginLeft=\\\"10dp\\\"\\n    android:layout_marginRight=\\\"10dp\\\"\\n    android:layout_below=\\\"@+id/an_summary\\\"\\n    android:layout_alignParentLeft=\\\"true\\\"\\n    android:contentDescription=\\\"Native Inline Video\\\"\\n    android:scaleType=\\\"fitXY\\\"/>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Ad Positions\"\n}\n[/block]\nAd positions define where the ads should be loaded into your ListView. You can define ad positions on the server side or on the client side in your app.\n\n**Dynamic Ad Positions (Server Positions) - Recommended**\n\nYou can define ad positions on AdsNative UI at each placement level and you can change them anytime without republishing the app. The ad positions are dynamically updated as you make the changes on the UI.\nUse the following line of code to define server positions in your app before publishing. By passing the instance of *ServerPositions*, SDK knows that it has to fetch ad positions from server and will do so automatically.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ANAdPositions.ServerPositions serverPositions =\\n  \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tANAdPositions.serverPositioning();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n**Hardcode Ad Positions in the App (Client Positions)**\n\nIf you don't wish to use server positions and want to use static positions, then you can define them through *ClientPositions* as below.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ANAdPositions.ClientPositions clientPositions =\\n  \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tANAdPositions.clientPositioning();\\n// add fixed positions\\nclientPositions.addFixedPosition(5).addFixedPosition(10);\\n// add repeating position interval\\nclientPositions.enableRepeatingPositions(8);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Integrating Other Networks\"\n}\n[/block]\nThis section details how to integrate other networks for mediation.\n\n**Basic Integration Guidelines**\n\nCurrently, we have built adapters for 4 major ad networks. Depending on which network you wish to integrate, choose the corresponding sub section. However, before diving into one specific network, you have to follow these basic steps for any network you wish to integrate.\n\n1. Integrate network SDK into your project\n2. From the \"networks\" folder of the downloaded AdsNative SDK, copy the corresponding network adapter into your project\n3. Setup network specific JSON data on AdsNative dashboard.\n\n**Facebook**\n\n1. The easiest way to integrate Audience Network SDK from Facebook is by adding following line to your gradle dependencies.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"dependencies {\\n    compile 'com.facebook.android:audience-network-sdk:4.x.x'\\n}\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\nNOTE: Audience Network SDK version supported is 4.6.0 & above.\n\n2. Copy networks/FacebookAdNetwork.java from AdsNative SDK into your project. You can copy into any java package under **src/** (example **com.xyz.networks.FacebookAdNetwork**)\n3. On the AdsNative dashboard, go to the \"Networks -> Provider Data\" section and add the following JSON data\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{ \\\"adNetworkClassName\\\": \\\"com.xyz.networks.FacebookAdNetwork\\\", \\\"placementId\\\": \\\"<AUDIENCE_NETWORK_PLACEMENT_ID>\\\" }\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n**MoPub**\n\n1. The easiest way to integrate MoPub SDK is by adding following lines to your gradle dependencies.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"dependencies {\\n    compile 'com.mopub:mopub-sdk:4.x.x@aar'\\n    compile('com.mopub.volley:mopub-volley:1.1.0@aar')\\n}\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\nNOTE: MoPub SDK version supported is 4.0.0 & above.\n\n2. Copy networks/MoPubAdNetwork.java from AdsNative SDK into your project. You must copy into **com.mopub.nativeads** package under **src/**\n3. On the AdsNative dashboard, go to the \"Networks -> Provider Data\" section and add the following JSON data\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{ \\\"adNetworkClassName\\\": \\\"com.mopub.nativeads.MoPubAdNetwork\\\", \\\"placementId\\\": \\\"<MOPUB_AD_UNID_ID>\\\" }\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nNOTE: MoPub ads may not work if you copy mopub adapter class into a different package other than **com.mopub.nativeads**\n\n**InMobi**\n\n1. Download InMobi SDK from InMobi portal and copy InMobi-5.x.x.jar to your project's lib folder. Add add the following line to your gradle dependencies.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\nrepositories {\\n    flatDir {\\n        dirs 'libs'\\n    }\\n}\\n// ...\\ndependencies {\\n    compile(name:'InMobi-5.x.x', ext:'jar')\\n}\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\nNOTE: InMobi SDK version supported is 5.0.0 & above.\n\n2. Copy networks/InMobiAdNetwork.java from AdsNative SDK into your project. You can copy into any java package under **src/** (example **com.xyz.networks.InMobiAdNetwork**)\n3. On the AdsNative dashboard, go to the \"Networks -> Provider Data\" section and add the following JSON data\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{ \\\"adNetworkClassName\\\": \\\"com.xyz.networks.InMobiAdNetwork\\\", \\\"placementId\\\": \\\"<INMOBI_PLACEMENT_ID>\\\", \\\"accountId\\\": \\\"<INMOBI_ACCOUNT_ID>\\\" }\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n**Flurry**\n\n1. Download InMobi SDK from InMobi portal and copy InMobi-5.x.x.jar to your project's lib folder. Add add the following lines to your gradle dependencies.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"repositories {\\n    flatDir {\\n        dirs 'libs'\\n    }\\n}\\n// ...\\ndependencies {\\n    compile(name:'FlurryAds-6.x.x', ext:'jar')\\n    compile(name:'FlurryAnalytics-6.x.x', ext:'jar')\\n}\",\n      \"language\": \"groovy\"\n    }\n  ]\n}\n[/block]\nNOTE: Flurry SDK version supported is 6.1.0 & above.\n\n2. Copy networks/FlurryAdNetwork.java from AdsNative SDK into your project. You can copy into any java package under **src/** (example **com.xyz.networks.FlurryAdNetwork**)\n3. On the AdsNative dashboard, go to the \"Networks -> Provider Data\" section and add the following JSON data\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{ \\\"adNetworkClassName\\\": \\\"com.xyz.networks.FlurryAdNetwork\\\", \\\"placementId\\\": \\\"<FLURRY_AD_SPACE_ID>\\\", \\\"flurryApiKey\\\": \\\"<FLURRY_API_KEY>\\\" }\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"android-sdk","type":"basic","title":"Android SDK"}
Welcome to AdsNative Android SDK documentation. Please check out the "Getting Started" section below before integrating your app with the SDK. [block:api-header] { "type": "basic", "title": "Getting Started" } [/block] This section explains the process of including AdsNative SDK in your Android application and setting dependencies. ** Prerequisites and Dependencies ** * Android version 4.0.3 (API 15) and above Add following to your build.gradle [block:code] { "codes": [ { "code": "dependencies {\n compile 'com.android.support:support-v4:22.2.1'\n compile 'com.android.support:appcompat-v7:22.2.1'\n compile 'com.android.support:recyclerview-v7:22.2.1'\n compile 'com.google.android.gms:play-services:7.8.0'\n}", "language": "groovy" } ] } [/block] **Including AdsNative SDK in your Android project** Click [**here**](https://github.com/picatcha/adsnative-sdk-android/archive/master.zip) to download the SDK as zipped source. Extract **adsnative_sdk_2.0.0.aar** from <unzipped>/adsnative_sdk/ location and place it under your project's libs folder (create libs if not already done). Add the compiled .aar to your build.gradle file as below. [block:code] { "codes": [ { "code": "repositories {\n flatDir {\n dirs 'libs'\n }\n}\n// ...\ndependencies {\n compile(name:'adsnative_sdk_2.0.0', ext:'aar')\n}", "language": "groovy" } ] } [/block] **Required Permissions in Android Manifest** Following permissions are mandatory. Please add them to your AndroidManifest.xml file. [block:code] { "codes": [ { "code": "<uses-permission android:name=\"android.permission.INTERNET\" />\n<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />", "language": "xml" } ] } [/block] **Recommended Permissions in Android Manifest** We recommend adding following permissions to your AndroidManifest.xml. [block:code] { "codes": [ { "code": "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />\n<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" />", "language": "xml" } ] } [/block] **ProGuard** AdsNative SDK is already obfuscated and minified using ProGuard. If you are running ProGuard on your Android application, please add the following to your ProGuard configuration file. [block:code] { "codes": [ { "code": "-keep class com.adsnative.** { *; }\n-dontwarn com.adsnative.**", "language": "groovy" } ] } [/block] [block:api-header] { "type": "basic", "title": "Native Ads Integration" } [/block] Import AdsNative SDK classes into your activity by adding the following line of code to the imports section of the your activity class. [block:code] { "codes": [ { "code": "import com.adsnative.ads.*;", "language": "java" } ] } [/block] AdsNative SDK supports following ad formats. Depending on your requirement and the type of app you have, you can choose one of the below methods. * [**Content Stream Ads**](http://dev.adsnative.com/docs/android-sdk#content-stream-ads) - These are ads that appear as part of a content stream. For Android, we support the RecyclerView and TableView/GridView layouts. If your app is using adapter to show content stream then we highly recommend using this integration. * [**Standard Integration (Single Native Ad)**](http://dev.adsnative.com/docs/android-sdk#standard-integration) - If you have a custom requirement or would like to stitch the native ad assets yourself, AdsNative SDK supports this by requesting a single native ad **Integrating Other Networks** If you wish to add other networks for mediation, [**click here**](http://dev.adsnative.com/docs/android-sdk#integrating-other-networks) to know how to do this. [block:api-header] { "type": "basic", "title": "Content Stream Ads" } [/block] To display ads in content stream, you just need to implement following 3 simple steps. 1. Define ad layout(s) 2. Define ad positions 3. Create AdsNative custom adapter object and start loading ads Depending on which type of stream you want to load native ads into, see one of the below sections * [**Recycler View Integration**](http://dev.adsnative.com/docs/android-sdk#recycler-view-integration) * [**List or Grid View Integration**](http://dev.adsnative.com/docs/android-sdk#list-or-grid-view-integration) [block:api-header] { "type": "basic", "title": "Recycler View Integration" } [/block] If your Android application uses RecyclerView to show the content, you can use our SDK's RecyclerView wrapper class *ANRecyclerView* to load native ads. 1. Create an instance of *ANRecyclerAdapter* class before onCreate() method so you can use the object to load ads later. [block:code] { "codes": [ { "code": "private ANRecyclerAdapter anRecyclerAdapter;", "language": "java" } ] } [/block] 2. Define Ad Layout Check [**this section**](http://dev.adsnative.com/docs/android-sdk#native-ad-layout) for defining native ad layouts and dynamic layout switching. 3. Define Ad Positions Check [**this section**](http://dev.adsnative.com/docs/android-sdk#ad-positions) for defining server ad positions and client ad positions. 4. Create *ANRecyclerAdapter* object and begin loading ads [block:code] { "codes": [ { "code": "@Override\npublic View onCreate(...) {\n // ...\n // ...\n // create ANRecyclerAdapter object\n anRecyclerAdapter = new ANRecyclerAdapter(this, adapter,\n AD_UNIT_ID, serverPositions);\n // Register the renderer with the ANRecyclerAdapter\n anRecyclerAdapter.registerViewBinder(anAdViewBinder);\n // Set your original view's adapter to ANRecyclerAdapter instance\n listView.setAdapter(anRecyclerAdapter);\n // Start loading ads\n anRecyclerAdapter.loadAds();\n}\n\n@Override\npublic void onResume() {\n // We recommend loading new ads when the user returns to your activity\n anRecyclerAdapter.loadAds();\n}", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "List or Grid View Integration" } [/block] If your Android application uses ListView or GridView or any view that uses Adapter, we recommend you to use our SDK's adapter class *ANListAdapter* to load native ads. 1. Create an instance of *ANListAdapter* class before onCreate() method so you can use the object to load ads later. [block:code] { "codes": [ { "code": "private ANListAdapter anListAdapter;", "language": "java" } ] } [/block] 2. Define Ad Layout Check [**this section**](http://dev.adsnative.com/docs/android-sdk#native-ad-layout) for defining native ad layouts and dynamic layout switching. 3. Define Ad Positions Check [**this section**](http://dev.adsnative.com/docs/android-sdk#ad-positions) for defining server ad positions and client ad positions. 4. Create *ANListAdapter* object and begin loading ads [block:code] { "codes": [ { "code": "\n@Override\npublic View onCreate(...) {\n // ...\n // ...\n // create ANListAdapter object\n anListAdapter = new ANListAdapter(this, adapter,\n AD_UNIT_ID, serverPositions);\n // Register the renderer with the ANListAdapter\n anListAdapter.registerViewBinder(anAdViewBinder);\n // Set your original view's adapter to ANListAdapter instance\n listView.setAdapter(anListAdapter);\n // Start loading ads\n anListAdapter.loadAds();\n}\n\n@Override\npublic void onResume() {\n // We recommend loading new ads when the user returns to your activity\n anListAdapter.loadAds();\n}", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Standard Integration" } [/block] If you are looking to load ads manually instead of using our RecyclerView or ListView wrappers, or if your Android application is not built using RecyclerView or ListView, then you can follow the integration steps below to manually load and render ads. 1. Create an instance of *ANNativeAd* class before onCreate() method so you can use the object to load ads later. [block:code] { "codes": [ { "code": "private ANNativeAd mNativeAd;", "language": "java" } ] } [/block] 2. Initialize the instance and set listener for ad callbacks inside your *onCreate()* method [block:code] { "codes": [ { "code": "mNativeAd = new ANNativeAd(this, <AD_UNIT_ID>);\nmNativeAd.setNativeAdListener(new ANAdListener() {\n @Override\n public void onAdLoaded(NativeAdUnit nativeAdUnit) {\n }\n \n @Override\n public void onAdFailed(String message) {\n }\n\n @Override\n public void onAdImpressionRecorded() {\n }\n \n @Override\n public void onAdClicked() {\n }\n});", "language": "java" } ] } [/block] 3. Start loading ads in your *onStart()* and *onResume()* methods by adding the following line of code. [block:code] { "codes": [ { "code": "@Override\npublic void onResume() {\n mNativeAd.loadAd();\n // ...\n}", "language": "java" } ] } [/block] 4. The next step is to extract the ad assets and build your custom UI for displaying native ads. Override the *onAdLoaded()* method as set in your ad listener above to retrieve the ad assets. [block:code] { "codes": [ { "code": "@Override\npublic void onAdLoaded(NativeAdUnit nativeAdUnit) {\n String title = nativeAdUnit.getTitle();\n String summary = nativeAdUnit.getSummary();\n String iconImage = nativeAdUnit.getIconImage();\n String mainImage = nativeAdUnit.getMainImage();\n String cta = nativeAdUnit.getCallToAction();\n\n // Define your custom layout and start loading assets into it\n // ...\n}", "language": "java" } ] } [/block] 5. AdsNative SDK internally handles impression and click tracking. You only need to register your ad view with the SDK as below. [block:code] { "codes": [ { "code": "mNativeAd.attachViewForInteraction(nativeAdUnit, <NATIVE_AD_VIEW>);", "language": "java" } ] } [/block] Alternatively, you can let the SDK handle loading assets into the layout defined by you and create an ad view. We recommend this approach as it's much cleaner and it only requires for you to define the layout XML. Check [**this section**](http://dev.adsnative.com/docs/android-sdk#native-ad-layout) for defining ad layout. Once you have defined the layout and registered the view binder, you can override *onAdLoaded()* method and add the following line to create ad view with the assets into the layout defined by you. [block:code] { "codes": [ { "code": "@Override\npublic void onAdLoaded(NativeAdUnit nativeAdUnit) {\n View nativeAdView = mNativeAd.renderAdView(nativeAdUnit);\n // the above method only creates the ad view, you need to add the view to your container as desired\n <your_container_object>.addView(nativeAdView);\n}", "language": "java" } ] } [/block] Since SDK is handling the creation of ad view, it implicitly takes care of tracking impressions and clicks. [block:api-header] { "type": "basic", "title": "Native Ad Layout" } [/block] You can define any custom layout for how your native ad should look within your app content. SDK will use this layout to load ads into it. Start by defining XML layout, the default assets available are title, summary, icon image, main image and call to action. Place the XML under **res/layout/<native_ad_layout>.xml** of your Android project. [block:code] { "codes": [ { "code": "final ANAdViewBinder anAdViewBinder = new\n ANAdViewBinder.Builder(R.layout.<NATIVE_AD_LAYOUT_XML>)\n \t.bindTitle(R.id.<title>)\n\t\t.bindSummary(R.id.<summary>)\n\t\t.bindIconImage(R.id.<iconImage>)\n\t\t.bindMainImage(R.id.<mainImage>)\n\t\t.bindCallToAction(R.id.<callToAction>)\n\t\t.bindPromotedBy(R.id.<promotedBy>)\n\t\t.build();", "language": "java" } ] } [/block] Once layout xml is defined, you need to register the same through with SDK, through *ANViewBinder*, which will take care of rendering the ads into the layout. [block:code] { "codes": [ { "code": "// For RecyclerView integration\nanRecyclerAdapter.registerViewBinder(anAdViewBinder);\n\n// For List or Grid View integration\nanListAdapter.registerViewBinder(anAdViewBinder);\n\n// For standard (single native ad) integration\nmNativeAd.registerViewBinder(anAdViewBinder);", "language": "java" } ] } [/block] **Dynamic Layout Switching** AdsNative SDK has the ability to dynamically switch between multiple ad layouts through just a click on the UI. Dynamic layouts is enabled by default for every ad placement. Following steps are required during the integration to make use of dynamic layouts. 1. Define all layout XMLs that you want to dynamically switch between. For example, if you have 4 layouts you would like to dynamically switch between then you need to create 4 XMLs and place them under **/res/layout/** of your Android project. 2. Define layouts with default R.ids for assets for ease of integration. Please check the snippet below. [block:code] { "codes": [ { "code": "<TextView android:id=\"@+id/an_title\"\n .../>\n<TextView android:id=\"@+id/an_summary\"\n .../>\n<ImageView android:id=\"@+id/an_icon_image\"\n .../>\n<ImageView android:id=\"@+id/an_main_image\"\n .../>\n<Button android:id=\"@+id/an_call_to_action\"\n .../>\n<TextView android:id=\"@+id/an_promoted_by\"\n .../>\n<!--\nan_title -> for title\nan_summary -> for summary or description\nan_icon_image -> icon image that appears usually top left\nan_main_image -> large image that appears usually in the center\nan_call_to_action -> cta or call-to-action button\nan_promoted_by -> this is a sponsored by tag (mandatory)\n-->", "language": "xml" } ] } [/block] 3. Register view binder using *bindAssetsWithDefaultKeys()* method. This method automatically binds assets using the default R.ids specified in the layout above. [block:code] { "codes": [ { "code": "final ANAdViewBinder anAdViewBinder = new\n ANAdViewBinder.Builder(R.layout.<NATIVE_AD_LAYOUT_XML>)\n \t.bindAssetsWithDefaultKeys(this)\n\t\t.build();\nmNativeAd.registerViewBinder(anAdViewBinder);", "language": "java" } ] } [/block] NOTE: If you wish to use custom R.ids, you may do so. In which case you will not be able to use *bindAssetsWithDefaultKeys()*, you will have to use respective bind methods as shown in the beginning of the section. However, for dynamic layouts to work, you need to use same custom R.ids across all your XML layouts and also ensure you are binding all assets irrespective of which and how many assets are used in the currently active layout. **Backup Layouts** AdsNative SDK may sometimes serve ads without icon image. If you are using icon in one of your layouts, it will be blank in such cases. To counter this, SDK has a feature built-in to fallback automatically into a backup layout (if defined). To make use of backup layouts, you need to define the xml with the same name as your original layout with _backup suffix added to it. For example, if your original layout file is named as **native_ad_layout.xml** then your backup layout should be named as **native_ad_layout_backup.xml** **Custom Assets** If you have direct-sold native ads, AdsNative allows you to setup additional custom assets (text and/or images) which you can extract or render using the SDK. Once you had setup additional assets in the UI, add them to your layout XML file(s) and bind them as shown below. (Example shown below assumes **customText** and **customImage** keys added in UI and **R.id.custom_text** and **R.id.custom_image** added to layout XML) [block:code] { "codes": [ { "code": "final ANAdViewBinder anAdViewBinder = new\n ANAdViewBinder.Builder(R.layout.<NATIVE_AD_LAYOUT_XML>)\n \t.bindAssetsWithDefaultKeys(this)\n .bindCustomField(\"customText\", R.id.custom_text\n .bindCustomField(\"customImage\", R.id.custom_image\n\t\t.build();\nmNativeAd.registerViewBinder(anAdViewBinder);", "language": "java" } ] } [/block] SDK internally takes care of rendering the custom assets as per the layout specified. But if if you are using standard integration and want to extract custom assets to bind and render on your own, then you can do so as shown below. [block:code] { "codes": [ { "code": "@Override\npublic void onAdLoaded(NativeAdUnit nativeAdUnit) {\n Object customText = nativeAdUnit.getCustomField(\"customText\");\n // for images, the source url is returned\n Object customImage = nativeAdUnit.getCustomField(\"customImage\");\n \n // you can also extract all custom assets at once into a map and extract using the keys as specified in the UI\n Map<String, Object> customFields = nativeAdUnit.getCustomFields();\n}", "language": "java" } ] } [/block] **Video Ads** AdsNative SDK supports showing video assets in-line with autoplay. To enable this you need to use **View** class to define the asset in your layout, instead of ImageView. Inline Video is usually shown in place of main image. Sample layout XML definition for video [block:code] { "codes": [ { "code": "<View android:id=\"@+id/an_video\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"200dp\"\n android:background=\"@null\"\n android:layout_marginTop=\"10dp\"\n android:layout_marginLeft=\"10dp\"\n android:layout_marginRight=\"10dp\"\n android:layout_below=\"@+id/an_summary\"\n android:layout_alignParentLeft=\"true\"\n android:contentDescription=\"Native Inline Video\"\n android:scaleType=\"fitXY\"/>", "language": "xml" } ] } [/block] [block:api-header] { "type": "basic", "title": "Ad Positions" } [/block] Ad positions define where the ads should be loaded into your ListView. You can define ad positions on the server side or on the client side in your app. **Dynamic Ad Positions (Server Positions) - Recommended** You can define ad positions on AdsNative UI at each placement level and you can change them anytime without republishing the app. The ad positions are dynamically updated as you make the changes on the UI. Use the following line of code to define server positions in your app before publishing. By passing the instance of *ServerPositions*, SDK knows that it has to fetch ad positions from server and will do so automatically. [block:code] { "codes": [ { "code": "ANAdPositions.ServerPositions serverPositions =\n \t\t\t\t\t\t\t\t\t\t\t\t\t\tANAdPositions.serverPositioning();", "language": "java" } ] } [/block] **Hardcode Ad Positions in the App (Client Positions)** If you don't wish to use server positions and want to use static positions, then you can define them through *ClientPositions* as below. [block:code] { "codes": [ { "code": "ANAdPositions.ClientPositions clientPositions =\n \t\t\t\t\t\t\t\t\t\t\t\t\t\tANAdPositions.clientPositioning();\n// add fixed positions\nclientPositions.addFixedPosition(5).addFixedPosition(10);\n// add repeating position interval\nclientPositions.enableRepeatingPositions(8);", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Integrating Other Networks" } [/block] This section details how to integrate other networks for mediation. **Basic Integration Guidelines** Currently, we have built adapters for 4 major ad networks. Depending on which network you wish to integrate, choose the corresponding sub section. However, before diving into one specific network, you have to follow these basic steps for any network you wish to integrate. 1. Integrate network SDK into your project 2. From the "networks" folder of the downloaded AdsNative SDK, copy the corresponding network adapter into your project 3. Setup network specific JSON data on AdsNative dashboard. **Facebook** 1. The easiest way to integrate Audience Network SDK from Facebook is by adding following line to your gradle dependencies. [block:code] { "codes": [ { "code": "dependencies {\n compile 'com.facebook.android:audience-network-sdk:4.x.x'\n}", "language": "groovy" } ] } [/block] NOTE: Audience Network SDK version supported is 4.6.0 & above. 2. Copy networks/FacebookAdNetwork.java from AdsNative SDK into your project. You can copy into any java package under **src/** (example **com.xyz.networks.FacebookAdNetwork**) 3. On the AdsNative dashboard, go to the "Networks -> Provider Data" section and add the following JSON data [block:code] { "codes": [ { "code": "{ \"adNetworkClassName\": \"com.xyz.networks.FacebookAdNetwork\", \"placementId\": \"<AUDIENCE_NETWORK_PLACEMENT_ID>\" }", "language": "json" } ] } [/block] **MoPub** 1. The easiest way to integrate MoPub SDK is by adding following lines to your gradle dependencies. [block:code] { "codes": [ { "code": "dependencies {\n compile 'com.mopub:mopub-sdk:4.x.x@aar'\n compile('com.mopub.volley:mopub-volley:1.1.0@aar')\n}", "language": "groovy" } ] } [/block] NOTE: MoPub SDK version supported is 4.0.0 & above. 2. Copy networks/MoPubAdNetwork.java from AdsNative SDK into your project. You must copy into **com.mopub.nativeads** package under **src/** 3. On the AdsNative dashboard, go to the "Networks -> Provider Data" section and add the following JSON data [block:code] { "codes": [ { "code": "{ \"adNetworkClassName\": \"com.mopub.nativeads.MoPubAdNetwork\", \"placementId\": \"<MOPUB_AD_UNID_ID>\" }", "language": "json" } ] } [/block] NOTE: MoPub ads may not work if you copy mopub adapter class into a different package other than **com.mopub.nativeads** **InMobi** 1. Download InMobi SDK from InMobi portal and copy InMobi-5.x.x.jar to your project's lib folder. Add add the following line to your gradle dependencies. [block:code] { "codes": [ { "code": "\nrepositories {\n flatDir {\n dirs 'libs'\n }\n}\n// ...\ndependencies {\n compile(name:'InMobi-5.x.x', ext:'jar')\n}", "language": "groovy" } ] } [/block] NOTE: InMobi SDK version supported is 5.0.0 & above. 2. Copy networks/InMobiAdNetwork.java from AdsNative SDK into your project. You can copy into any java package under **src/** (example **com.xyz.networks.InMobiAdNetwork**) 3. On the AdsNative dashboard, go to the "Networks -> Provider Data" section and add the following JSON data [block:code] { "codes": [ { "code": "{ \"adNetworkClassName\": \"com.xyz.networks.InMobiAdNetwork\", \"placementId\": \"<INMOBI_PLACEMENT_ID>\", \"accountId\": \"<INMOBI_ACCOUNT_ID>\" }", "language": "json" } ] } [/block] **Flurry** 1. Download InMobi SDK from InMobi portal and copy InMobi-5.x.x.jar to your project's lib folder. Add add the following lines to your gradle dependencies. [block:code] { "codes": [ { "code": "repositories {\n flatDir {\n dirs 'libs'\n }\n}\n// ...\ndependencies {\n compile(name:'FlurryAds-6.x.x', ext:'jar')\n compile(name:'FlurryAnalytics-6.x.x', ext:'jar')\n}", "language": "groovy" } ] } [/block] NOTE: Flurry SDK version supported is 6.1.0 & above. 2. Copy networks/FlurryAdNetwork.java from AdsNative SDK into your project. You can copy into any java package under **src/** (example **com.xyz.networks.FlurryAdNetwork**) 3. On the AdsNative dashboard, go to the "Networks -> Provider Data" section and add the following JSON data [block:code] { "codes": [ { "code": "{ \"adNetworkClassName\": \"com.xyz.networks.FlurryAdNetwork\", \"placementId\": \"<FLURRY_AD_SPACE_ID>\", \"flurryApiKey\": \"<FLURRY_API_KEY>\" }", "language": "json" } ] } [/block]