Problem in Eclipse Android

54 views
Skip to first unread message

CarLoL Puyol

unread,
Mar 6, 2014, 12:18:16 PM3/6/14
to google-adm...@googlegroups.com
When i try to run my project I have an error in the xml file that says:
"error: Error parsing XML: unbound prefix"
It shows in the <com.google.ads.AdView , I think Eclipse is not recognizing this label but i don´t understand why,
because I have the SDK of AdMob installed well (Eclipse recognizes the variable AdView in the class).
I have updated my SDK of Android and Google APIs using the SDK Manager.

Some ideas?

Kunal Verma

unread,
Mar 6, 2014, 12:22:14 PM3/6/14
to Google AdMob Ads Developers

Can you show your xml code?

--

---
You received this message because you are subscribed to the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

CarLoL Puyol

unread,
Mar 6, 2014, 12:39:02 PM3/6/14
to google-adm...@googlegroups.com
My xml code is the next:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/burbuj"
    android:gravity="center_vertical" >
   
    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="ca-app-pub-5323768818468484/4988481850"
        ads:adSize="BANNER"
        ads:testDevices="TEST_EMULATOR, 3aa08c18d779fa2d"
        ads:loadAdOnCreate="true"  />
   
    <ImageView
       .../>

    <Button
        ... />

    <Button
        ... />

    <Button
       ... />

</RelativeLayout>

Kunal Verma

unread,
Mar 6, 2014, 1:16:43 PM3/6/14
to Google AdMob Ads Developers
Instead of xmlns:tools="http://schemas.android.com/tools"


It works for me in this way when including the AdMob 6.4.1 SDK library.

Best,
Kunal


CarLoL Puyol

unread,
Mar 6, 2014, 1:45:27 PM3/6/14
to google-adm...@googlegroups.com
Thanks it Debugs now... but now I have a execution error
import ...

import com.google.ads.*;

public class Inicio extends Activity {
    public static SQLiteDatabase db;
    static BDhelper dbhelper;
     private AdView adView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);    //null
        setContentView(R.layout.activity_inicio);
       
        // Crear el objeto adView, el id se obtiene de admob
        adView = new AdView(this, AdSize.BANNER, "ca-app-pub-5323768818468484/4988481850");
          // Buscar LinearLayout suponiendo que se le ha asignado
          // el atributo android:id="@+id/mainLayout"
         RelativeLayout layout = (RelativeLayout)findViewById(R.layout.activity_inicio);
         // Añadirle adView
         layout.addView(adView);
         // Iniciar una solicitud genérica para cargarlo con un anuncio
         //AdView adView = (AdView)this.findViewById(R.id.adView);
         adView.loadAd(new AdRequest()); 
    }

It crashes exactly in layout.addView(adView); I copy pasted the code from the web of admob except the layout that i change the Linear into my Relative (it didn´t works without this change neither)

Kunal Verma

unread,
Mar 6, 2014, 1:55:30 PM3/6/14
to Google AdMob Ads Developers
You need to better understand the tutorials on the AdMob website. They are two ways to implement Ads in your app. You are mixing both of them. 

You don't need Java code when loading the Ad from XML.
Just this enough:-

<com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="ca-app-pub-5323768818468484/4988481850"
        ads:adSize="BANNER"
        ads:testDevices="TEST_EMULATOR, 3aa08c18d779fa2d"
        ads:loadAdOnCreate="true"  />

 So remove all of the java code related to Adview. ( this is for AdMob SDK 6.4.1 and not for AdMob implementation using Google Play Services which you are not using).


Best,
Kunal


--
Reply all
Reply to author
Forward
0 new messages