gpt4 book ai didi

android - java.lang.NoClassDefFoundError : com. google.android.gms.ads.AdView 错误

转载 作者:行者123 更新时间:2023-11-29 14:49:25 25 4
gpt4 key购买 nike

我见过类似的问题,但他们无法解决我的问题。我已经安装了 Google Play SDK,作为库导入到我的应用程序中。按照 Admob 的说明,我在下面编写了该代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.oguz.nfcdatareaderwriter.MainPage$PlaceholderFragment" >


<Button
android:id="@+id/writeNFC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/openingMessage"
android:layout_centerHorizontal="true"
android:layout_marginTop="116dp"
android:text="Write Custom Data to a Card" />

<TextView
android:id="@+id/openingMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="174dp"
android:text=".."
android:textAppearance="?android:attr/textAppearanceLarge" />



</RelativeLayout>

主要 Activity :

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main_page);

// Create an ad.
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);

// Add the AdView to the view hierarchy. The view will have no size
// until the ad is loaded.
RelativeLayout layout = (RelativeLayout) findViewById(R.id.relative);
layout.addView(adView);

// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("4df1dccd39006f0f")
.build();

// Start loading the ad in the background.
adView.loadAd(adRequest);
}

最佳答案

如果您收到 NoClassDefFoundError,那么您没有正确包含 GooglePlayServices 库,或者您已经设法使用 Proguard 或类似工具排除了这些类。尝试重做这些步骤。

关于android - java.lang.NoClassDefFoundError : com. google.android.gms.ads.AdView 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23522741/

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