问题描述
我想实现我的Android应用程序AdMob广告横幅时,得到一个非常恼人的ClassNotFound的异常,则使用AdMob的SDK 4.3.1。我已经使用了下面的实现:
I am getting a very annoying ClassNotFound exception when trying to implement an admob banner in my android app, using admob sdk 4.3.1. I have used the following implementation:
清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10"
/>
....
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
的main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/bigmainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/grey">
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxxx"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR"
ads:loadAdOnCreate="true"/>
</LinearLayout>
Project.properties
target=android-14
错误:
03-21 22:00:25.993:E / AndroidRuntime(333):致命异常:主要03-21 22:00:25.993:E / AndroidRuntime(333):java.lang.RuntimeException的: 无法启动活动 ComponentInfo {com.xxxx / com.xxxx.MainActivity}: android.view.InflateException:二进制XML文件中的行#125:错误 充气类com.google.ads.AdView 03-21 22:00:25.993: E / AndroidRuntime(333):在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 03-21 22:00:25.993:E / AndroidRuntime(333):在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 03-21 22:00:25.993:E / AndroidRuntime(333):在 android.app.ActivityThread.access $ 1500(ActivityThread.java:117)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.app.ActivityThread $ H.handleMessage(ActivityThread.java:931) 03-21 22:00:25.993:E / AndroidRuntime(333):在 android.os.Handler.dispatchMessage(Handler.java:99)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.os.Looper.loop(Looper.java:123)03-21 22:00:25.993: E / AndroidRuntime(333):在 android.app.ActivityThread.main(ActivityThread.java:3683)03-21 22:00:25.993:E / AndroidRuntime(333):在 java.lang.reflect.Method.invokeNative(本机方法)03-21 22:00:25.993:E / AndroidRuntime(333):在 java.lang.reflect.Method.invoke(Method.java:507)03-21 22:00:25.993: E / AndroidRuntime(333):在 com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839) 03-21 22:00:25.993:E / AndroidRuntime(333):在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)03-21 22:00:25.993:E / AndroidRuntime(333):在 dalvik.system.NativeStart.main(本机方法)03-21 22:00:25.993: E / AndroidRuntime(333):android.view.InflateException:产生的原因: 二进制XML文件行#125:错误充气类com.google.ads.AdView 03-21 22:00:25.993:E / AndroidRuntime(333):在 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) 03-21 22:00:25.993:E / AndroidRuntime(333):在 android.view.LayoutInflater.rInflate(LayoutInflater.java:623)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.view.LayoutInflater.rInflate(LayoutInflater.java:626)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.view.LayoutInflater.inflate(LayoutInflater.java:408)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.view.LayoutInflater.inflate(LayoutInflater.java:320)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.view.LayoutInflater.inflate(LayoutInflater.java:276)03-21 22:00:25.993:E / AndroidRuntime(333):在 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207) 03-21 22:00:25.993:E / AndroidRuntime(333):在 android.app.Activity.setContentView(Activity.java:1657)03-21 22:00:25.993:E / AndroidRuntime(333):在 com.xxxx.MainActivity.onCreate(FreeMedsActivity.java:55)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 03-21 22:00:25.993:E / AndroidRuntime(333):在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 03-21 22:00:25.993:E / AndroidRuntime(333):11 ...更多03-21 22:00:25.993:E / AndroidRuntime(333):产生的原因: 抛出java.lang.ClassNotFoundException:com.google.ads.AdView装载机 dalvik.system.PathClassLoader [/data/app/com.xxxx-2.apk] 03-21 22:00:25.993:E / AndroidRuntime(333):在 dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 03-21 22:00:25.993:E / AndroidRuntime(333):在 java.lang.ClassLoader.loadClass(ClassLoader.java:551)03-21 22:00:25.993:E / AndroidRuntime(333):在 java.lang.ClassLoader.loadClass(ClassLoader.java:511)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.view.LayoutInflater.createView(LayoutInflater.java:471)03-21 22:00:25.993:E / AndroidRuntime(333):在 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570
)
我创造了code AD浏览报,并将其添加到布局时遇到了类似的ClassNotFound的异常。我得到的OS 2.2,2.3.3,2.3.7和4.0此错误。我已经加入了admobsdk.jar到构建路径。我已经试过我使用日食靛蓝切换minSSdkVersion到14。
I get a similar classnotfound exception when creating the adview in code and adding it to the layout. I get this error on OS 2.2, 2.3.3, 2.3.7, and 4.0. I have added the admobsdk.jar to the build path. I have tried switching the minSSdkVersion to 14. I am using eclipse indigo.
我想知道如果这有做有多大我加入的.jar。我把它复制到/ lib文件夹中的项目,然后要么加入到构建路径或preferences - >构建路径 - >添加JAR。我想知道如果以某种方式应用程序不知道在哪里可以找到的.jar仍...
I am wondering if this has to do with how I am adding the .jar. I have it copied into a /lib folder in the project, and then either do add to build path or preferences-->build path-->add JAR. I am wondering if somehow the app doesn't know where to find the .jar still...
推荐答案
原来的Android工具的R17要求 / lib目录
文件夹是 /库
,系统和SDK必须放置在那里和内部参考,以便它被包括在的apk
Turns out r17 of Android Tools requires the /lib
folder to be /libs
, and the SDK has to be placed in there and referenced internally in order for it to be included in the apk.
查看更多信息,此链接。
这篇关于ClassNotFound的努力来实现AdMob的横幅时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!