ClassNotFoundException: Ne pas à trouver de la classe “com.google.android.gms.les annonces.AdView”

J'ai fait beaucoup de recherche, et cela semble être une erreur commune pour de nombreux utilisateurs, mais pour des raisons très différentes. Rien de ce que j'ai trouvé a fonctionné pour moi.

Je suis

java.lang.RuntimeException: Unable to start activity ComponentInfo{
[...]/[...].activities.StartActivity}: android.view.InflateException:
Binary XML file line #173: Error inflating class [...].BannerAd
    [...]
Caused by: android.view.InflateException: Binary XML file line #8: Error
inflating class com.google.android.gms.ads.AdView
    [...]
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.google.android.gms.ads.AdView" on path: DexPathList[[zip file
"/data/app/[...]-1.apk"],nativeLibraryDirectories=[/data/app-lib/[...]-1,
/vendor/lib, /system/lib]]

Je vais avoir les versions les plus récentes de l'ADT et le SDK installé les paquets. J'ai copié google-play-services_lib à mon espace de travail et importé comme un projet Android. Je l'ai ajouté comme une bibliothèque de mon projet d'application. J'ai tout vérifié, en vertu de "l'Ordre et à l'Exportation".

Je vais avoir un banner_ad.xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|top"
    android:orientation="vertical" >

    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="[...]" />

</LinearLayout>

Et un BannerAd.java qui je suis en utilisant:

package [...];

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import [...].R;
import [...].general.Settings;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;


public class BannerAd extends LinearLayout {
    public BannerAd(Context context, AttributeSet attrs) {
        super(context, attrs);

        if (!Settings.PRO) {
            LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mInflater.inflate(R.layout.banner_ad, this, true);

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

Pourrait-il avoir quelque chose à voir avec proguard? Je n'ai aucune idée, c'est mon proguard-project.txt fichier, cependant:

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

Toutes les idées que je pourrais essayer de résoudre ce problème?

Edit: Parfois, je reçois aussi de cette sortie dans la console (mais pas à chaque fois que je compile, parfois seulement):

[2014-07-24 12:49:05 - [...]] Dx 
trouble processing:
[2014-07-24 12:49:05 - [...]] Dx bad class file magic (cafebabe) or version (0033.0000)
...while parsing com/google/android/gms/internal/mb.class
...while processing com/google/android/gms/internal/mb.class
[2014-07-24 12:49:05 - [...]] Dx 
trouble processing:
[2014-07-24 12:49:05 - [...]] Dx bad class file magic (cafebabe) or version (0033.0000)
...while parsing com/google/android/gms/internal/mc.class
...while processing com/google/android/gms/internal/mc.class
[2014-07-24 12:49:05 - [...]] Dx 
[...]
[Lots of similar warnings here]
[...]
trouble processing:
[2014-07-24 12:49:25 - [...]] Dx bad class file magic (cafebabe) or version (0033.0000)
...while parsing com/google/ads/mediation/customevent/CustomEventAdapter$a.class
...while processing com/google/ads/mediation/customevent/CustomEventAdapter$a.class
[2014-07-24 12:49:25 - [...]] Dx 
trouble processing:
[2014-07-24 12:49:25 - [...]] Dx bad class file magic (cafebabe) or version (0033.0000)
...while parsing com/google/ads/mediation/customevent/CustomEventServerParameters.class
...while processing com/google/ads/mediation/customevent/CustomEventServerParameters.class
[2014-07-24 12:49:25 - [...]] Dx 2786 warnings
Pourquoi ne pas vous désactiver Proguard et essayer encore une fois ?
Viens de découvrir que je ne suis pas à l'utiliser de toute façon. proguard.config=[...] est commenté dans le projet.les propriétés.
Essayez d'ajouter "xmlns:annonces="schemas.android.com/apk/res-auto" LinearLayout et supprimer à partir de AdView. Vous pouvez consulter ici
N'aide pas non plus. Découvrez mon montage.

OriginalL'auteur flxapps | 2014-07-24