本文主要是介绍(新手植入有米广告教程)根据官方例子给简单的应用加入有米广告,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
第一步,到有米官网中申请一个开发者账户并新建一个应用,之后获取应用的应用秘钥和发布ID。如下图:
第二步,下载有米广告SDD,并解压该SDK,把其中libs文件夹中以.arr结尾的文件复制到AS的新工程libs文件夹中,然后编译一下。如下图:选中arr包,然后并点击工具栏红圈中的东东,这样arr包就和工程绑定了。
第二点二步:配置应用的build.gradle文件,记住是应用的,不是工程build.gradle文件。具体如下图红圈所示:加入文件所没有的代码即可,后编译一下。
第三步:配置AndroidMainfest.xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.weihuan.youmiguanggaotest">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 以下为可选权限 -->
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".BaseActivity"></activity>
<activity
android:name=".SplashActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter >
</activity >
<activity android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout">
</activity>
<activity
android:name=".SpotAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name" >
</activity >
<activity
android:name=".SlideableSpotAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name" >
</activity >
<activity
android:name=".NativeSpotAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name" >
</activity >
<activity
android:name=".VideoAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name"
android:resizeableActivity="false"
android:screenOrientation="portrait" >
</activity >
<activity
android:name=".NativeVideoAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name" >
</activity >
<!-- 视频组件 -->
<activity
android:name="net.youmi.android.nm.vdo.VideoActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:resizeableActivity="false" <
第二步,下载有米广告SDD,并解压该SDK,把其中libs文件夹中以.arr结尾的文件复制到AS的新工程libs文件夹中,然后编译一下。如下图:选中arr包,然后并点击工具栏红圈中的东东,这样arr包就和工程绑定了。
第二点二步:配置应用的build.gradle文件,记住是应用的,不是工程build.gradle文件。具体如下图红圈所示:加入文件所没有的代码即可,后编译一下。
第三步:配置AndroidMainfest.xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.weihuan.youmiguanggaotest">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 以下为可选权限 -->
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".BaseActivity"></activity>
<activity
android:name=".SplashActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter >
</activity >
<activity android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout">
</activity>
<activity
android:name=".SpotAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name" >
</activity >
<activity
android:name=".SlideableSpotAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name" >
</activity >
<activity
android:name=".NativeSpotAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name" >
</activity >
<activity
android:name=".VideoAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name"
android:resizeableActivity="false"
android:screenOrientation="portrait" >
</activity >
<activity
android:name=".NativeVideoAdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:label="@string/app_name" >
</activity >
<!-- 视频组件 -->
<activity
android:name="net.youmi.android.nm.vdo.VideoActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:resizeableActivity="false" <
这篇关于(新手植入有米广告教程)根据官方例子给简单的应用加入有米广告的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!