gpt4 book ai didi

java - 无法实例化以下类 : - com. google.android.gms.ads

转载 作者:行者123 更新时间:2023-12-02 05:14:30 26 4
gpt4 key购买 nike

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="50dp"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-32763440xxxxxxxxxxxx" />

当我在图形布局中添加此代码时,会出现此错误,并且不会在设备上安装该应用程序。我该如何解决这个问题?

The following classes could not be instantiated:
- com.google.android.gms.ads.AdView (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
java.lang.ClassNotFoundException: com.google.android.gms.R$styleable
at java.net.URLClassLoader$1.run( at java.net.URLClassLoader$1.run( at java.security.AccessController.doPrivileged( at java.net.URLClassLoader.findClass( at java.lang.**strong text**ClassLoader.loadClass( at java.lang.ClassLoader.loadClass( at com.google.android.gms.internal.bb.<init>( at com.google.android.gms.internal.bh.<init>( at com.google.android.gms.internal.bh.<init>( at com.google.android.gms.internal.bh.<init>( at com.google.android.gms.ads.AdView.<init>( at sun.reflect.NativeConstructorAccessorImpl.newInstance0( at sun.reflect.NativeConstructorAccessorImpl.newInstance( at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( at java.lang.reflect.Constructor.newInstance( at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:442)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:194)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385)

最佳答案

确保您的布局中定义了正确的 xml 命名空间:

因此,xmlns:ads="http://schemas.android.com/apk/res-auto":

<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="50dp"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-32763440xxxxxxxxxxxx" />

在 list 的应用程序标记中,不要忘记添加:

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

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

关于java - 无法实例化以下类 : - com. google.android.gms.ads,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27081413/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com