Reputation: 8972
I am trying to use AdMobs on Android. This is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.krinsen.javadocreader"
android:versionCode="2"
android:versionName="1.0.1" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".app.SimpleApp"
android:hardwareAccelerated="true"
android:icon="@drawable/icon_about"
android:label="@string/app_name"
android:theme="@style/Theme.Javadoc" >
<activity
android:name=".ui.DocTypeActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.default_searchable"
android:value=".ui.SearchableJavadocActivity" />
</activity>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
</manifest>
This is my view:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ads"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id"
ads:testDevices="@string/test_devices"
ads:loadAdOnCreate="true" />
And I have admob library up to date. I am still getting this strange error in logcat:
INTERNET permissions must be enabled in AndroidManifest.xml
I have internet permission. My app uses internet and uses it very well. Only ads don't want to cooperate. Where I can look for a bug?
Upvotes: 8
Views: 1395
Reputation: 4667
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Just add the last two lines.I solved it by this.
Upvotes: 0
Reputation: 24181
i think you have added the permissions
in wrong place , add the full AndroidManifest.xml
file ,
instead , your manifestFile should look something like this :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.novaapps.android.couponmanager"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".CouponManager"
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.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
and in your Layout
you should include following namespace
code in the Layout
tag :
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
NOTE : refer this tutorial for more details
Upvotes: 5
Reputation: 23638
Just try to add the below lines in your Manifest.xml
file outside the application
tag.
<meta-data android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" android:value="true" />
Upvotes: 0
Reputation: 1952
sennin,
admob needs the adUnitId of yours to work with your account.
Get the admob adUnitId that is linked with your account and use it.
Don't forget to add ad:testDevices in XML if you are currently in development.
Rest are fine with Chinmoy's code snippet.
Create an application entry in admob and get the adUnitId from settings of that entry.
Hopes this will help you.
Upvotes: 0
Reputation: 2824
Please try to copy this then check what happened as i didn't find any error in your code.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xChinmoy.babywallpaperhd"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.xChinmoy.babywallpaperhd.BabyWallPaperActivity"
android:screenOrientation="portrait"
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.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
</application>
</manifest>
and the view is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.ads.AdView
android:id="@+id/advw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="a150cd49f90925f"
ads:backgroundColor="#FFFF00"
ads:loadAdOnCreate="true"
ads:primaryTextColor="#FFFFFF"
ads:refreshInterval="30"
ads:secondaryTextColor="#CCCCCC"
android:visibility="visible" />
</RelativeLayout>
I have created it yesterday and perfectly display the add, and admob jar version is 6.0.1.
Upvotes: 1