android - adMob.jar library and google play service.jar not working together -


i have app on market admod banner, , trying add google maps api application.

i know how handle admobs library or google maps api separately. when try run app admob , google maps api (google play service), seems have collision or that. or google-play-services.jar , googleadmobadssdk.jar have same class name admob. maybe due reason getting multiple .dex files.

my error on console is:

trouble writing output: prepared [2014-05-18 18:24:40 - dex loader] unable execute dex: multiple dex files define lcom/google/ads/adrequest$errorcode; [2014-05-18 18:24:40 - workc 3.0.9 actionbar] conversion dalvik format failed: unable execute dex: multiple dex files define lcom/google/ads/adrequest$errorcode;

i'm afraid bad admob update application version. how can fix that?

you can rid of jar file , use google play services both ads , maps. make following changes:

in layout, change ad xml namespace from:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"     -----/> 

to :

 <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:ads="http://schemas.android.com/apk/res-auto"     ----/> 

then, change:

 <com.google.ads.adview   android:id="@+id/ad"  android:layout_width="wrap_content"   android:layout_height="wrap_content"  android:layout_gravity="bottom|center"   android:layout_margintop="300dp"   ads:adsize="banner"  ads:adunitid="***************"   ads:loadadoncreate="true" /> 

to :

<com.google.android.gms.ads.adview  android:id="@+id/ad"  android:layout_width="wrap_content"   android:layout_height="wrap_content"  android:layout_gravity="bottom|center"   android:layout_margintop="300dp"   ads:adsize="banner"  ads:adunitid="***************" /> 

note ads:loadadoncreate no longer available you'd have load ad via java code in oncreate():

adview adview = (adview)this.findviewbyid(r.id.ad); adrequest adrequest = new adrequest.builder().build(); adview.loadad(adrequest); 

then in manifest's application tag, change:

<activity android:name="com.google.ads.adactivity"/> 

to:

<activity android:name="com.google.android.gms.ads.adactivity"                    android:configchanges="keyboard|keyboardhidden|orientation|screenlayout|uimode|screensize|smallestscreensize"/> 

add:

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

don't forget permissions:

 <uses-permission android:name="android.permission.access_network_state"/>    <uses-permission android:name="android.permission.internet"/> 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -