Eclipse的AdMob问题

时间:2014-11-11 22:17:59

标签: android eclipse admob

我正在尝试让AdMob使用Eclipse处理我的应用程序。为此,我已经实施了以下步骤:

  1. 在AdMob上注册并制作了广告

  2. 在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. 已安装和导入google-play-services_lib(已检查的副本文件到工作区)

  4. google-play-services_lib作为库添加到项目

  5. 在我的布局xml中我有这个:

    <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>
    

  6. 我还加入了xmlns:ads="http://schemas.android.com/apk/res-auto"

    6.在我的活动中添加了以下内容:

    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.现在,当我尝试在设备上运行应用程序时,我总是得到关注     错误:

    unable to execute dex gc overhead limit exceeded
    

    我尝试过,但没有成功:在eclipse.ini中增加内存大小,有时Eclipse无法启动,我必须执行以下步骤:https://stackoverflow.com/a/18282716/3829021

2 个答案:

答案 0 :(得分:0)

我可以通过重新安装Eclipse和Android SDK以及将google play服务库导入到项目中来解决这个问题,并且它可以正常工作。

答案 1 :(得分:0)

我刚刚尝试整合admob。这是一个通用的eclipse内存问题,并不是特定于AdMob集成的。

这是对我有用的修复:

  1. 在eclipse安装文件夹中编辑eclipse.ini(在我的情况下: C:\ Program Files \ eclipse \ eclipse.ini)
  2. 增加内存值 以Xms *

    开头的行

    -Xms40m 
    -Xmx512m
    

    -Xms512m
    -Xmx1024m
    
  3. 信用:Unable to execute dex: GC overhead limit exceeded in Eclipse