无法加载" com.google.android.gms.r styleable"

时间:2016-08-26 22:17:13

标签: android admob google-play-services

我想在我的应用程序中集成admob。我正在尝试在https://firebase.google.com/docs/admob/android/quick-start运行测试代码。

我当前的google-play-service版本是32.之前我正在使用版本29.由于google将play_service库拆分为多个库,我习惯于从m2repository中的每个库存储中选择和提取。目前我选择了play-services-ads-lite-9.0.0 .jar。这是我在项目中包含的唯一jar文件。当我运行代码时,应用程序崩溃了。编译器中没有警告或错误。

我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.richa.salemob"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8"
          android:targetSdkVersion="23"/>

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

<application android:icon="@drawable/icon"
             android:label="@string/app_name"
             android:allowBackup="true"
             android:theme="@android:style/Theme.Black.NoTitleBar">
    <activity android:name=".Start">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <activity android:name="com.google.android.gms.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode"/>

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

</application></manifest>

我的布局XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:ads="http://schemas.android.com/apk/lib/com.richa.salesmob"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@color/white">
<com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>

我的Java代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
MobileAds.initialize(StartFields.context, "ca-app-pub-3940256099942544~3347511713");
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new
AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
adView.loadAd(adRequest);
init();
}

我无法理解并解决错误: java.lang.ClassNotFoundException:没找到类&#34; com.google.android.gms.R $ styleable&#34; on path:DexPathList [[zip file&#34; /data/app/com.richa.India_Sales-1/base.apk"],nativeLibraryDirectories = [/ vendor / lib,/ system / lib]]

请帮忙。谢谢

1 个答案:

答案 0 :(得分:0)

您使用的是错误的应用ID,您必须获得新的个人ID

  

要查找您的应用ID,请单击下方的应用管理选项   设置下拉列表(位于右上角)上   AdMob帐户页面。应用ID具有表单   为ca-app-PUB-XXXXXXXXXXXXXXXX〜NNNNNNNNNN。