我的Android应用中存在问题。错误是:
\ res \ layout \ main.xml:37:错误:找不到属性' adUnitId'在包' com.sherdle.base'
\ res \ layout \ main.xml:37:错误:找不到属性' adSize'的资源标识符在包' com.sherdle.base'
为什么会这样?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/layoutholder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/theme"
android:orientation="vertical" >
<!-- splash -->
<ImageView
android:contentDescription="@string/app_name"
android:id="@+id/imageLoading1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="@android:color/white"
android:visibility="gone"
android:src="@drawable/vert_loading"
/>
<RelativeLayout
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center_horizontal" >
<!-- advertisements-->
<LinearLayout
android:id="@+id/adViewH"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
ads:adUnitId="ca-app-pub-xxxxxx"
ads:adSize="SMART_BANNER"/>
</LinearLayout>
<WebView
android:id="@+id/webkit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/adViewH"
android:layout_below="@+id/progressbar"
android:visibility="visible" />
<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:max="100"
android:progress="50"
android:progressDrawable="@drawable/myprogressbar"
android:secondaryProgress="0" />
<!-- Include the slide down view. -->
<include layout="@layout/slide_down_view"
android:id="@+id/slide_down_view_include"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="20dp"
android:layout_marginBottom="-20dp"/>
</RelativeLayout>
</LinearLayout>
此外,我的Eclipse在此部分的 mainactivity.java 中显示了一个十字标记:
// admob
if (!(getResources().getString(R.string.publisher_id).equals(""))) {
// Look up the AdView as a resource and load a request.
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
} else {
AdView adView = (AdView) findViewById(R.id.adView);
adView.setVisibility(View.GONE);
}