2013-08-27 11 views
16

मैं एंड्रॉइड स्टूडियो में अपने एंड्रॉइड ऐप में एडोब जोड़ने की कोशिश कर रहा हूं। मैं लगभग वहाँ लेकिन की त्रुटि हो रही है:नामस्थान 'विज्ञापन' बाध्य नहीं

Namespace 'ads' not bound 

यहाँ भी विज्ञापन के साथ अपना एक्सएमएल है:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 

बस इसे पेस्ट:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

     <com.google.ads.AdView android:id="@+id/adView" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           ads:adUnitId="MY_AD_UNIT_ID" 
           ads:adSize="BANNER" 
           ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" 
           ads:loadAdOnCreate="true"/> 


    <TextView 
     android:id="@+id/beerTitle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:textSize="20sp" 
     android:textStyle = "bold" 
     android:padding="5dip" 
     > 
    </TextView> 

    <ImageView android:id="@+id/image" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_margin="10dip"/> 



    <TableLayout 

    android:id="@+id/tableLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_horizontal" 
    android:shrinkColumns="*" 
    android:stretchColumns="*"> 

    <TableRow 
     android:id="@+id/tableStatTitles" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:padding="5dip" > 

     <TextView 
      android:id="@+id/abvTitle" 
      android:text="ABV" 
      android:gravity="center" 
      android:textStyle = "bold" 
      android:textSize="20sp" 
      android:layout_weight="1" 

      ></TextView> 

     <TextView 
      android:id="@+id/IBUTitle" 
      android:text="IBU" 
      android:gravity="center" 
      android:textStyle = "bold" 
      android:textSize="20sp" 
      android:layout_weight="1" 

      ></TextView> 

     <TextView 
      android:id="@+id/glassTitle" 
      android:text="Glass" 
      android:gravity="center" 
      android:textStyle = "bold" 
      android:textSize="20sp" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      ></TextView> 




     </TableRow> 

    <TableRow 
     android:id="@+id/tableStat" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:padding="5dip" > 

     <TextView 
      android:id="@+id/abv" 
      android:text="" 
      android:gravity="center" 
      android:textSize="15sp" 
      android:layout_width="wrap_content" 
      ></TextView> 

     <TextView 
      android:id="@+id/IBU" 
      android:text="" 
      android:gravity="center" 
      android:textSize="15sp" 
      android:layout_width="wrap_content" 
      ></TextView> 

     <TextView 
      android:id="@+id/glass" 
      android:text="" 
      android:gravity="center" 
      android:textSize="15sp" 
      android:layout_width="wrap_content" 
      ></TextView> 


     </TableRow> 

    </TableLayout> 

    <View 
    android:layout_width="1dp" 
    android:layout_height="30dp"> 
</View> 

    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Average Rating: " 
     android:textStyle = "bold" 
     android:textSize="20sp" 
     /> 

    <TextView 
     android:id="@+id/beerRating" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" 
     android:textSize="20sp" 
     /> 

    </LinearLayout> 

    <View 
    android:layout_width="1dp" 
    android:layout_height="30dp"> 
</View> 

    <Button 
     android:id="@+id/buttonBrewery" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dip" 
     android:text="" 
     android:onClick="viewBrewery" 
     /> 



    <Button 
     android:id="@+id/buttonStyle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dip" 
     android:text="" 
     android:onClick="viewStyle" 

     /> 

    <View 
    android:layout_width="1dp" 
    android:layout_height="30dp"> 
</View> 

    <TextView 
     android:id="@+id/yourPortfolio" 
     android:textStyle = "bold" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:textSize="20sp" 
     android:text="Your Portfolio:" 
     android:padding="5dip" 
     ></TextView> 

    <LinearLayout 
    android:id="@+id/addBeerLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

     </LinearLayout> 

    <TextView 
     android:id="@+id/beerDescriptionTitle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:padding="5dip" 
     android:text="Description:" 
     android:textSize="20sp" 
     android:textStyle="bold" > 
</TextView> 
    <TextView 
     android:id="@+id/beerDescription" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:textSize="15sp" 
     android:padding="5dip" 

     ></TextView> 


    <Button 
     android:id="@+id/buttonTasteTag" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dip" 
     android:text="Taste Profile" 
     android:onClick="viewTasteTags" 

     /> 



</LinearLayout> 
</ScrollView> 

उत्तर

32

आप इस नाम स्थान जोड़ने के लिए एंड्रॉइड नेमस्पेस के नीचे:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

साथ ही, ध्यान रखें कि एसडीके टूल्स के अपडेट 17 के बाद से, आप पूरी तरह से योग्य नेमस्पेस + पैकेज-नाम (more info) के बजाय http://schemas.android.com/apk/res-auto का उपयोग कर सकते हैं।

तो यह भी काम करना चाहिए:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:auto="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
+1

रेस-ऑटो काम करता है, लेकिन पहले एक –

+0

@NelsonWu से सहमत नहीं था! पहला रनटाइम अपवाद में पहला परिणाम [विज्ञापन आकार और विज्ञापन इकाई आईडी लोडएड से पहले सेट की जानी चाहिए] (http://stackoverflow.com/questions/23337802/ad-size-and-ad-unit-id-must -be-set-before-loadad-is-called) –

0

एक नाम अंतरिक्ष अपने xml मूल तत्व में जोड़ा जाना चाहिए: डी

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 

अपने xml फ़ाइल के अंदर शीर्ष टैग या तत्व है कि पंक्ति जोड़ें , और आप जाने के लिए तैयार हो जाएगा।

0

अपने मूल तत्व करने के लिए कोड की इस पंक्ति जोड़ें

xmlns: विज्ञापन = "http://schemas.android.com/apk/lib/com.google.ads"

संबंधित मुद्दे