0

I am trying to get AdMob to work on my app with Eclipse. For that I already implemented following steps:

  1. Signed up on AdMob and created an ad

  2. Inserted following to Manifest.xml:

    <!-- This meta-data tag is required to use Google Play Services. -->
    <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" />
    
  3. Installed and imported google-play-services_lib (checked copy files into workspace)

  4. Added google-play-services_lib as library to project

  5. In my layout xml I have this:

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-2756687115022088/XXXXXXXXXX" >
    </com.google.android.gms.ads.AdView>
    

Also I included xmlns:ads="http://schemas.android.com/apk/res-auto"

6.Added following to my Activity:

import android.app.Activity;
import android.os.Bundle;
import com.example.adexample.R;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;


public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);

    }
}

7.Now when I try to run the app on my device I always get following error:

unable to execute dex gc overhead limit exceeded

What I tried, but no success: increase memory size in eclipse.ini and sometimes Eclipse doesn't start and I have to do following step: https://stackoverflow.com/a/18282716/3829021

Community
  • 1
  • 1
Sini Inis
  • 407
  • 1
  • 5
  • 16
  • Are you sure that this error comes from the admob integration? – Michael Nov 12 '14 at 09:39
  • I think due to google-play-service_lib... When I try to launch projects without google play service lib then there are no problems. I have no clue why google play services causes this gc overhead. – Sini Inis Nov 12 '14 at 14:13
  • Are you testing it on emulator? Also you should enable test-ads for emulator by adding `.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)` to your AdRequest. – donfuxx Nov 12 '14 at 18:28

2 Answers2

0

I could solve this issue just by re-installing Eclipse and Android SDK and imported google play service lib into project and it worked.

Sini Inis
  • 407
  • 1
  • 5
  • 16
0

I ran into this just now trying to integrate admob. This is a generic eclipse memory issue and not specific to AdMob integration.

Here's the fix that worked for me:

  1. Edited eclipse.ini in the eclipse installation folder (In my case: C:\Program Files\eclipse\eclipse.ini)
  2. Increased the memory values in the lines starting with Xms*

    from

    -Xms40m 
    -Xmx512m
    

    to

    -Xms512m
    -Xmx1024m
    

Credit: Unable to execute dex: GC overhead limit exceeded in Eclipse

Community
  • 1
  • 1
Dileep P G
  • 541
  • 5
  • 12