MrEngineer13 MrEngineer13 - 1 month ago 12
Android Question

AdMob error: Didn't find class "com.google.ads.AdView"

So I'm on Android Studio v 0.3.6 and I'm having problems with Google Play Services. I was already using the Admob jar in my project but I had to update it so I tried to add them via the instructions. My project compiles fine however when I try to run an activity I get the following error:

Didn't find class "com.google.ads.AdView" on path: /data/app/com.mre. example-1. apk


See the full error output here Relevant portion of my build.gradle:

apply plugin: 'android'

dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.google.android.gms:play-services:4.0.30'
//compile project(':libraries:google-play-services_lib')
//compile files('libs/google-play-services.jar')
...
}

android {
compileSdkVersion 18
buildToolsVersion '18.0.1'
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}


Here's my manifest



<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />

<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"ex">

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />

<meta-data
android:name="com.google.android.gms.appstate.APP_ID"
android:value="@string/app_id" />
...
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

</application>


Here's the layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
...
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="50dp"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
android:gravity="center" />
...
</RelativeLayout>


Over the past two days I have tried every variation of adding the GPS library to my project, to just the jar to both to none. At first I deleted the jar from my /libs and added the required lines to my build.gradle but that didn't work either. I thank you in advance for any help you can provide.

Answer

The package changed to com.google.android.gms.ads.AdRequest and com.google.android.gms.ads.AdView

Change your import and your layouts

Follow this tutorial to migrate your apk.

Comments