整合AdMob时的ActivityNotFoundException

时间:2015-06-12 12:07:16

标签: java android xml android-studio admob

我已经看到类似这样的问题,但没有解决方案对我有所帮助。我按照此链接https://developers.google.com/admob/android/quick-start中提供的指南行将AdMob集成到我的应用中。

我的xml文件和java类如下:

的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<!-- Include required permissions for Google Mobile Ads to run-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.NoActionBar">
    <!--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=".SpoilerActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!--Include the AdActivity configChanges and theme. -->
    <activity android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />


</application>

我已将<string name="banner_ad_unit_id"></string>添加到 strings.xml

<com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" ads:adSize="BANNER" ads:adUnitId="@string/banner_ad_unit_id"> </com.google.android.gms.ads.AdView>加入 activity_main.xml

它已集成到 Activity.java类中,如下所示:

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

我正在使用Android Studio 1.2.2。我的minSdkVersion是14,targetSdk是22.

有什么想法吗?

0 个答案:

没有答案