ClassNotFoundException的:没有找到类" com.google.android.gms.ads.AdView" [英] ClassNotFoundException: Didn't find class "com.google.android.gms.ads.AdView"

查看:1543
本文介绍了ClassNotFoundException的:没有找到类" com.google.android.gms.ads.AdView"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了很多的研究,这似乎是一个常见的​​错误对于许多用户,但非常不同的原因。其中无我发现很适合我。

我收到

 了java.lang.RuntimeException:无法启动活动ComponentInfo {
[...] / [...] activities.StartActivity}:android.view.InflateException:
二进制XML文件行#173:错误充气类[...] BannerAd
    [...]
致:android.view.InflateException:二进制XML文件中的行#8:错误
充气类com.google.android.gms.ads.AdView
    [...]
抛出java.lang.ClassNotFoundException:产生的原因没有找到类
在路径com.google.android.gms.ads.AdView:DexPathList [zip文件
/data/app/[...]-1.apk"],nativeLibraryDirectories=[/data/app-lib/[...]-1,
/供应商/ lib中/系统/ lib目录]
 

我在安装ADT和SDK软件包的最新版本。我复制了谷歌播放的,services_lib到我的工作区和进口它作为一个Android项目。我增加一条,作为一个库我的应用程序的项目。我在排序和导出。

检查一切

我有一个banner_ad.xml:

 <的LinearLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_gravity =center_horizo​​ntal |顶
    机器人:方向=垂直>

    < com.google.android.gms.ads.AdView
        的xmlns:广告=htt​​p://schemas.android.com/apk/res-auto
        机器人:ID =@ + ID / AD浏览报
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        广告:adSize =大旗
        广告:adUnitId =[...]/>

< / LinearLayout中>
 

和我正在使用BannerAd.java:

 包[...]

进口android.content.Context;
进口android.util.AttributeSet;
进口android.view.LayoutInflater;
进口android.widget.LinearLayout;

。进口[...] R;
进口[...] general.Settings。
进口com.google.android.gms.ads.AdRequest;
进口com.google.android.gms.ads.AdView;


公共类BannerAd扩展的LinearLayout {
    公共BannerAd(上下文的背景下,ATTRS的AttributeSet){
        超(背景下,ATTRS);

        如果(!Settings.PRO){
            LayoutInflater mInflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mInflater.inflate(R.layout.banner_ad,这一点,真正的);

            AD浏览报AD浏览报=(AD浏览报)this.findViewById(R.id.adView);
            AdRequest adRequest =新AdRequest.Builder()建立()。
            adView.loadAd(adRequest);
        }
    }
}
 

难道必须是与ProGuard的?我不知道,这是我的ProGuard-project.txt文件,但是:

 #为ProGuard的在你的项目中,编辑project.properties
#为在该文件中描述的定义proguard.config财产。
#
#添加项目的具体ProGuard的规则在这里。
#默认情况下,该文件中的标志被附加到指定的标志
#在$ {sdk.dir} /tool​​s/proguard/proguard-android.txt
#您可以编辑通过改变ProGuard的包含路径和秩序
#包括project.properties财产。
#
#详情请参阅
#http://developer.android.com/guide/developing/tool​​s/proguard.html

#添加任何具体项目保持选择这里:

#如果你的项目使用的WebView与JS,取消以下
#并指定完全限定类名给JavaScript接口
# 类:
#-keepclassmembers类fqcn.of.javascript.interface.for.webview {
#   上市 *;
#}

-keep类*扩展java.util.ListResourceBundle {
    保护的对象[] [] getContents();
}

-keep公共类com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    公共静态最终*** NULL;
}

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

-keepnames类*实现android.os.Parcelable {
    公共静态最后的** CREATOR;
}
 

任何想法我可以尝试解决这一问题?

编辑:有时候,我也得到这样的输出在控制台(我每次编译但不是,只是有时):

  [2014年7月24日12时49分05秒 -  [...]]霉素
故障处理:
[2014年7月24日12时49分○五秒 -  [...]]霉素不良类文件魔术(cafebabe)或版本(0033.0000)
......在解析COM /谷歌/安卓/ GMS /内部/ mb.class
...在处理COM /谷歌/安卓/ GMS /内部/ mb.class
[2014年7月24日12时49分○五秒 -  [...]]霉素
故障处理:
[2014年7月24日12时49分○五秒 -  [...]]霉素不良类文件魔术(cafebabe)或版本(0033.0000)
......在解析COM /谷歌/安卓/ GMS /内部/ mc.class
...在处理COM /谷歌/安卓/ GMS /内部/ mc.class
[2014年7月24日12时49分○五秒 -  [...]]霉素
[...]
[很多类似的警告这里]
[...]
故障处理:
[2014年7月24日12时49分25秒 -  [...]]霉素不良类文件魔术(cafebabe)或版本(0033.0000)
......在解析COM /谷歌/广告/调停/自定义事件/ CustomEventAdapter $的A.class
...在处理COM /谷歌/广告/调停/自定义事件/ CustomEventAdapter $的A.class
[2014年7月24日12时49分25秒 -  [...]]霉素
故障处理:
[2014年7月24日12时49分25秒 -  [...]]霉素不良类文件魔术(cafebabe)或版本(0033.0000)
......在解析COM /谷歌/广告/调停/自定义事件/ CustomEventServerParameters.class
...在处理COM /谷歌/广告/调停/自定义事件/ CustomEventServerParameters.class
[2014年7月24日12时49分25秒 -  [...]]霉素2786警告
 

解决方案

我做了@ user1684030所说的(升级后的And​​r​​oid SDK构建工具;改变编译器1.7),但不是为我工作。我已经写了我的情况下,发现它可以帮助任何人以同样的问题的解决方案:

设置谷歌播放服务说:

  

在你的应用程序的项目,参照谷歌Play业务库项目。   请参阅引用库项目为Eclipse的更多信息   如何做到这一点。

     

注意:您要引用的库您复制一个副本   您的开发工作区,你不应该引用库   直接从Android SDK目录

解决方案:不要做手工复制。相反,只是检查了Eclipse中的盒子,上面写着复制项目到工作区

我做到了,那么,一切重新工作。

由于这个计算器的问题:<一href="http://stackoverflow.com/questions/14142496/how-to-fix-google-play-services-2-library-install-to-eclipse">How修复谷歌播放服务2库安装到Eclipse (Admob的是谷歌播放服务的一部分)

I did a lot of research and this seems to be a common error for many users but for very different reasons. None of which I found worked for me.

I'm getting

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

I'm having the newest versions of ADT and SDK packages installed. I copied google-play-services_lib to my workspace and imported it as a Android project. I added it as a library to my app project. I checked everything under "Order and Export".

I'm having a 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>

And a BannerAd.java which I am using:

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);
        }
    }
}

Could it have something to do with proguard? I have no idea, this is my proguard-project.txt file, however:

# 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;
}

Any ideas what I could try to fix this?

Edit: Sometimes, I also get such output in the console (but not every time I compile, only sometimes):

[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

解决方案

I did what @user1684030 said (upgraded Android SDK Build Tools; changed compiler to 1.7), but not worked for me. I've written the solution that I found in case it could help anyone with the same problem:

In the step 3 of Setting Up Google Play Services says:

In your app project, reference Google Play services library project. See Referencing a Library Project for Eclipse for more information on how to do this.

Note: You should be referencing a copy of the library that you copied to your development workspace—you should not reference the library directly from the Android SDK directory.

Solution: Don't do the copy manually. Instead just check the box in Eclipse that says "Copy projects into workspace"

I did it so and everything worked again.

Thanks to this StackOverFlow question: How to fix Google Play Services 2 Library install to Eclipse (Admob is part of Google Play Services)

这篇关于ClassNotFoundException的:没有找到类&QUOT; com.google.android.gms.ads.AdView&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆