问题描述
我有我使用HTML和CSS。我建立使用手机的差距基于Web的应用程序,它工作得很好,当我试图在我的应用程序集成AdMob的它显示AdActivity中缺少清单file.I搜索,并没有发现任何answers.Kindly帮助!
I have my web based app using html and css .I build using phone gap and it works well,When i try to integrate admob in my app it shows AdActivity is missing in manifest file.I have searched and didn't found any answers.Kindly help!.
这是我的mainactivity.java文件:
This is my mainactivity.java file:
public class MainActivity extends DroidGap {
private Handler mHandler = new Handler();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
mHandler.postDelayed(new Runnable() {
public void run() {
doAdmob();
}
}, 1000);
}
private void doAdmob() {
// Create the adView
AdView adView = new AdView(this);
adView.setAdUnitId("ca-app-pub-000000000000000000000000");
adView.setAdSize(AdSize.BANNER);
// Lookup your LinearLayout - get the super.root
LinearLayout layout = super.root;
// Add the adView to it
layout.addView(adView);
// This centers the ads in landscape mode.
layout.setHorizontalGravity(android.view.Gravity.CENTER_HORIZONTAL);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
}
这是我的Android清单文件:
This is my android manifest file:
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="20" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.phonegap.DroidGap" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
</intent-filter>
</activity>
<!--Include the AdActivity configChanges and theme. -->
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
/>
</application>
请帮助...........
Kindly help...........
推荐答案
在PhoneGap的,你可以尝试建立在每个特定平台的应用程序,然后通过修改code,这似乎它是你整合AdMob的正在尝试做的。你必须为你做它要支持的每个平台上,你也得写本地code每个平台以及。 我建议你使用一个插件,与你已经做了本地和明显的整合。
In phonegap you can try to build the app in each specific platform and then integrate admob by modifying the code, which it seems that it is what you are trying to do. You will have to do it for each platform you want to support and also you'll have to write the native code for each platform as well. I recommend you to use a plugin, with which you'll have already done the native and manifest integration.
如果要修改原生code,可以看到这里如何在Android和iOS整合AdMob的。
If you want to modify the native code, you can see here how to integrate admob in android and ios.
如果您决定使用一个插件,我建议我保持了一句: admob-谷歌,科尔多瓦
If you decide to use a plugin, I recommend the one that I'm maintaining: admob-google-cordova
这是很容易集成:
cordova plugin add com.admob.google
或者,如果你想使用PhoneGap的CLI:
Or if you want to use phonegap cli:
phonegap local plugin add https://github.com/appfeel/admob-google-cordova.git
和使用它,在javascript:
And to use it, in javascript:
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
document.removeEventListener('deviceready', onDeviceReady, false);
// Set AdMobAds options:
admob.setOptions({
publisherId: "ca-app-pub-8440343014846849/3119840614",
interstitialAdId: "ca-app-pub-8440343014846849/4596573817"
});
// Start showing banners (atomatic when autoShowBanner is set to true)
admob.createBannerView();
// Request interstitial (will present automatically when autoShowInterstitial is set to true)
admob.requestIntertitial();
}
(更换code用你的Publisher ID的)希望它可以帮助!
(Replace the code with your publisher id's) Hope it helps!
修改
最简单,最快捷的方式就是使用科尔多瓦插件添加com.admob.google
命令行。无论如何,我离开这里的说明添加支持在Eclipse:
The easiest and fastest way is to use cordova plugin add com.admob.google
from command line. Anyway I leave here the instructions to add support in Eclipse:
- 下载的插件 Github上或通过命令行:
git的克隆https://github.com/appfeel/admob-google-cordova.git
- Uncom preSS的donwloaded插件
- 复制
的src /安卓/ *。java的
到YourProjectFolder /平台/安卓/ src目录/ COM / appfeel /科尔多瓦/ AdMob的/
- 复制
的src /安卓/ RES /价值/ admob.xml
到YourProjectFolder /平台/安卓/ RES /价值/ android.xml
- 添加支持Android的支持-V4 一>
- 增加支持谷歌播放-服务
- 打开您的清单文件,并添加以下在
&lt;应用...&GT;
标签:
- Download the plugin from Github or via command line:
git clone https://github.com/appfeel/admob-google-cordova.git
- Uncompress the donwloaded plugin
- Copy
src/android/*.java
intoYourProjectFolder/platforms/android/src/com/appfeel/cordova/admob/
- Copy
src/android/res/values/admob.xml
intoYourProjectFolder/platforms/android/res/values/android.xml
- Add support for android-support-v4
- Add support for google-play-services
- Open your manifest file and add the following under
<application...>
tag:
code:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
这篇关于在PhoneGap的应用程序加入AdMob的需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!