RoadMap : Admob, Getting Started > Android 요구사항 > Banners 1 > 실습




앞서 번역한 'AdMob 예제 Banners 1, Android'를 실습해 본 페이지 입니다.



코딩으로만 생성 실습.

1. 구글 AdMob 사이트에서 게시자 계정을 생성합니다.

2. AdMob SDK를 계정에 추가합니다.

3. 예제 코드와 같이 코딩을 하면 되는데, 주의 할 점은 메인 LayOut 에 아이디가 없을 것 입니다. 아이디를 설정해 주시고, 그 아이디로 조회해 레이아웃을 찾아 옵니다.
    - 참고로 전 RelativeLayout으로 했는데도 잘되었습니다.
    - 처음에 예제와 같이 코딩을 했는데 오류를 만났습니다. 메시지는 'Not enough space to show ad! Wants : <480, 75>, has <432, 642>', 대강 해석하면, 광고가 보여질 공간이 모자릅니다. (스타 생각이 나더군요. Not enough mienral ㅠ,.ㅜ) <480, 75> 사이즈의 크기를 원하는데, 뷰는 <432, 642> 입니다. 스마트폰을 90도로 돌렸더니, 가로 모드가 되면서, 광고가 나왔습니다. 저 같은 경우는 reLativeLayout을 써 여백이 자동설정되어 공간이 좁게 나왔습니다. 되었습니다. 따라 하시는 분들은 참고해 주시면 좋겠습니다.

4. 완성된 예제 : AdMomBannerI-Allcoding.zip




XML을 이용한 간편한 방법 실습.

1. 구글 AdMob 사이트에서 게시자 계정을 생성합니다.

2. AdMob SDK를 계정에 추가합니다.

3. 버튼을 누를 때 광고가 뜨도록 버튼을 추가합니다.

- 버튼 이벤트 관련 참고 페이지 : http://blog.naver.com/minsoub?Redirect=Log&logNo=60153961557

4. 주의 해야 할 점은 ads 네임스페이스(xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads")를 추가해야 한다는 것입니다. 메인 레이아웃이나, 애드 뷰 자체에 추가하면되지만, 메인 레이아웃에 추가 하는 것을 권장합니다.

5. 그 외에 별다른 문제점은 없었습니다. 완성된 예제 :  AdMobBanner1-SimplyCodingForXML.zip


'Mobile Ads > AdMob Android' 카테고리의 다른 글

AdMob 예제 Interstitial Ads, Android  (0) 2013.08.14
AdMob Banners 2, Android 예제 실습  (0) 2013.08.14
AdMob 예제 Banners 2, Android  (0) 2013.08.13
AdMob 예제 Banners 1, Android  (0) 2013.08.12
Andoird AdMob 요구사항  (0) 2013.08.12
Posted by 창업자닉군
,

RoadMap : Admob, Getting Started > Android 요구사항 > Banners 1

Menus : 실습




https://developers.google.com/mobile-ads-sdk/docs/ 주소에 접속하시면, 구글 애드몹 SDK 관련 문서를 보실 수 있고, 그 속에는 몇몇 예제들이 있습니다. 본 페이지는 그 중 'Banners I' 이라는 예제를 번역하고 따라 해본 페이지 입니다. 예제의 원문서는 https://developers.google.com/mobile-ads-sdk/docs/ 접속 후 좌측 메뉴 'AdMob > Banner Ads I'을 선택하면, 보실 수 있습니다.




선행 작업.

- Android AdMob 요구사항 진행 : http://it-backup.tistory.com/10





본격 적인 번역.


Banners I

Google AdMob Ads banners use a small portion of the screen to entice users to "click through" to a richer, full-screen experience such as a website or app store page. This guide shows you how to enable your app to serve a banner ad.
구글 애드몹 광고 배너들은 화면의 작은 부분을 사용해 유저가 클릭을 통해 richer(글꼴의 크기 변경 및 이미지 표현이 가능한 문서), 모든 화면을 통해 웹사이트나 앱스토어 페이지를 경함하게끔 유혹합니다. 이 가이드는 앱에 배너 광고 제공 방법을 보여줍니다.


To display banners in your Android app, simply add a com.google.ads.AdView to your UI.
앱속 배너 배너를 표시하려면, 간단히 UI에 'com.google.ads.AdView'추가합니다.

Adding a com.google.ads.AdView

Android apps are composed of View objects, Java instances the user sees as text areas, buttons and other controls. AdView is simply another View subclass displaying small HTML5 ads that respond to user touch.
안드로이드 앱은 뷰 객체들, 유저가 보는 텍스트 영역의 자바 인스턴스, 버튼과 기타 컨트롤로 구성되어 있습니다. AdView는 사용자 터치에 반응(응답)하는 작은 HTML5 광고를 표시하는 또 다른 뷰의 subclass 뷰 입니다.

Like any View, an AdView may be created either purely in code or largely in XML.
다른 뷰와 같이, 순수한 코드나 주로 사용되는 XML로 AdView 생성할 수 있습니다.

The five lines of code it takes to add a banner:
배너를 추가하는데 이용되는 5줄의 코드 :

  • Import com.google.ads.*
    com.google.ads.* (패키지) 추가

  • Declare an AdView instance
    AdView 인스턴스 선언.

  • Create it, specifying a unit ID—your AdMob publisher ID
    장치 아이디 (당신의 AdMob 게시자 ID), 생성.

  • Add the view to the UI
    UI속에 view(AdView) 추가.

  • Load it with an ad
    광고 로드.

The easiest place to do all this is in your app's Activity.
아래 위치는 당신의 앱 Activity속 코드를 추가하기 좋은 장소 입니다.

import com.google.ads.*; // 패키지 추가.

public class BannerExample extends Activity {
 
private AdView adView;                            // adView 선언.

 
@Override
 
public void onCreate(Bundle savedInstanceState) {
   
super.onCreate(savedInstanceState);
    setContentView
(R.layout.main);

   
// Create the adView; adView 추가.
    adView
= new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);

   
// Lookup your LinearLayout assuming it's been given
   
// the attribute android:id="@+id/mainLayout" // "@+id/mainLayout" 속성 ID의 LinearLayout을 조회하는 것을 가정하고 있다.

    LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);

   
// Add the adView to it.                위에서 조회된 LinearLayout 에 adView를 추가한다.
    layout
.addView(adView);

   
// Initiate a generic request to load it with an ad.            광고와 adView 응답의 초기화를 시작한다.
    adView
.loadAd(new AdRequest());
 
}

 
@Override
 
public void onDestroy() {
   
if (adView != null) {
      adView
.destroy();
   
}
   
super.onDestroy();
 
}
}

You can download an example project containing this code here.
당신은 위 코드가 포함된 예제 프로젝트를 여기(here)에서 다운로드 할 수 있습니다.



Create your banner in XML. (XML 속에서 배너 만들기)

Rather than creating your AdView in Java, it's also possible to set one up entirely in XML. To do so simply:
(당신이 자바속에서 AdView를 만드는 것 보다, 한번에 쉽게 XML 속에서 설정하는 것이 가능합니다. 훨씬 간결하게 :

  • Incorporate the SDK into your app
    당신의 앱속에 SDK를 통합합니다.

  • Define a com.google.ads.AdView in res/layout/main.xml, specifying it should immediately load an ad by using the ads:loadAdOnCreate attribute.
    'res/layout/main.xml' 속에 com.google.ads.AdView를 정의합니다. 'ads:loadAdOnCreate' 속성을 이용해 정의된 AdView에 빠르게 광고가 로드됩니다.

  • Alternately, instead of forcing the AdView to load an ad immediately, Look up the AdView as a resource at runtime and tell it to request an ad.
    또는 강제로 AdView에 바로 로드되는 대신, 런타임과 광고를 요청하는 시점에 리소스를 조회해 찾은 AdView에 보여지게 할 수 있습니다.

Defining a com.google.ads.AdView (com.google.ads.AdView 정의)

The easiest way to incorporate an ad is to simply define your AdView as you would any other part of yourres/layout/main.xml:

광고를 통합하는 쉬운 방법은 광고뷰를 'res/layout/main.xml'에 정의하는 간단히 정의하는 것이다.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
             
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
             
android:orientation="vertical"
             
android:layout_width="fill_parent"
             
android:layout_height="fill_parent">
 
<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"/>
</LinearLayout>

As usual you must replace MY_AD_UNIT_ID with your AdMob publisher ID. You must also add your own device ID in theads:testDevices attribute to get test ads on your device. Note the inclusion of the ads namespace referenced in specifyingadUnitId and adSize. This code will immediately attempt to load an ad as soon as the AdView is created by Android's layout engine.

 하던데로, MY_AD_UNIT_ID와 당신의 Admob publisher ID (애드몹 게시자 ID)를 치환하고 합니다. 또한 당신의 장치에서 테스트 광고를 얻기 위해 'ads:testDevices' 속성속에 자신의  장비 ID를 추가해야 합니다. 지정된 'adUnitId'와 'adSize'가 ads 네임스페이스에 포함된 되었는지 확인하세요. 이코드는 안드로이드 레이아웃 엔진에 의해 생성되는 즉시 AdView에 광고를 로드합니다.



Lookup and Load (조회와 로드)

If you have a need to control the AdRequest used to load an ad in your application, you can remove theads:loadAdOnCreate="true" line from the above code. Instead, you will want to look up the AdView as a resource viafindViewById and instruct it to loadAd:

만약 당신이 app속에서 AdRequest를 이용한 광고 로드 제어가 필요하다면, 위의 코드로 부터 'ads:loadAdOnCreate="true"' 라인을 제거할 수 있습니다. 대신, 'findViewById'를 통해 리소스에서 조회된 AdView에 'loadAd'(메소드)로 지시합니다.

import com.google.ads.*;

public class BannerExample extends Activity {
 
@Override
 
public void onCreate(Bundle savedInstanceState) {
   
super.onCreate(savedInstanceState);
    setContentView
(R.layout.main);

   
// Look up the AdView as a resource and load a request.
   
AdView adView = (AdView)this.findViewById(R.id.adView);
    adView
.loadAd(new AdRequest());
 
}
}

You can download an example project containing this code here.
이 코드가 들어 있는 예제 프로젝트는 이곳(here)에서 다운로드 할 수 있습니다.


The Result

When you now run your app you should see a banner at the top of the screen:


Posted by 창업자닉군
,

RoadMap : Admob, Getting Started > Android 요구사항

Menus : Banners 1Banners 2Interstitial AdsSmart BannersAd Network Mediation - Publisher Instructions




워낙 발 번역이라, 오류가 있을 수 있습니다. 오류나 이상한 점은 댓글로 남겨주세요.


구글 AdMob SDK 첫 페이지(https://developers.google.com/mobile-ads-sdk/docs/)에 들어가면, 플랫폼 별 요구사항을 확인할 수 있습니다. 상단의 Introduction 부분 번역은 'http://it-backup.tistory.com/9'페이지를 참고하시면 됩니다. 첫 페이지에 들어가면, iOS탭이 선택되어 있는데, Android를 선택해 Requirements(요구사항)을 확인합니다.





- 본격적인 번역 -

Requirements (요구사항)

  • Make sure you have the latest copy of the Android SDK and that you're compiling against at least Android v3.2 (settarget in default.properties to android-13).
  • The Google AdMob Ads SDK for Android requires a run-time of Android 1.5 or later (set android:minSdkVersion to at least 3 in your AndroidManifest.xml). This means you can develop with the latest version of the Android SDK and your app will still run on an earlier Android version (1.5 minimum). 
-> 구글  Android SDK 최신버전과 최소한 Android v3.2 버전의 컴파일이 가능한지 확인하세요. (dufault.properties는 Android-13 버전에 타겟팅 되어 있습니다.)
-> 구글 AdMob Ads SDK Android 용 요구사항은 Android sdk 1.5 이상. ('AndroidManifest.xml' 파일 속 'android:minSdkVersion' 최소 3 이상으로 설정해야 합니다.) 이 의미는 가장 최신 버전은 Android SDK로 개발하여, 이전버전에서 여전히 동작 될 수 있음을 뜻합니다. (최소 1.5)


Warning: All new Android apps created after October 14, 2011 will require an AdMob SDK that was released on or after May 11, 2011. This corresponds to version 4.1.0+ for Android. If you downloaded the library from our official download site, then you're already set. Otherwise you may have an old version of the AdMob SDK that was released prior to May 11, 2011, and your new app will not receive any ad impressions until you update your SDK.


경고 : 2011년 8월 14일 이후 만들어진 모든 새로운 앱들은 2011년 5월 11일 이후에 출시된 AdMob SDK를 요구합니다. 이는 안드로이드용 SDK 4.1.0+ 버전에 해당합니다.만약 우리가 운영하는 다운로드 사이트에서 library 다운로드 했다면, 준비가 완료된 것입니다. 그렇지 안으면 2011년 5월 11일 이전에 배포된 버전의 AdMob SDK를 가지고 있을 수 있으며, 당신의 새로운 앱은 당신이 SDK를 업데이트 할 때까지, 어떤 광고는 노출이 지원되지 않는다.



Incorporating the SDK (SDK 통합)

Incorporating Google AdMob Ads into your app is a three step process:
당신의 엡에 구글 AdMob 광고를 통합(넣는 것)하는 3단계 작업 :

  1. Add the SDK JAR to your Eclipse project.
    SDK JAR 파일을 당신의 Eclipse 프로젝트에 넣는다.

  2. Declare com.google.ads.AdActivity in AndroidManifest.xml.
    'AndroidManifest.xml'파일 속 'com.google.ads.AdActivity'를 선언한다.

  3. Set up required network permissions in the manifest.
    manifest 속에 요구되는 네트워크 퍼미션을 설정한다.



Adding the SDK JAR ( SDK JAR 추가)

The decompressed SDK consists of a JAR, a javadoc folder and a README.
압축이 풀린 SDK는 JAR, javadoc 폴더, 그리고 README 로 구성되어 있습니다.

1. Right click on your app project in Eclipse and chooseProperties.                     당신의 이클립스 프로젝트 속 프로퍼티를 마우스 오른쪽 버튼으로 선택하세요.

 

2. Select Java Build Path and the Libraries tab. Then clickAdd External JARs... to add the Google AdMob Ads JAR.             'Java Build Path'와 'Libraries'탭을 선택세요. 'Add External JARs...'을 눌러 구글 AdMob  Ads JAR을 추가하세요.

3. Select the Order and Exporttab; then, check the Google AdMob Ads JAR to include it when compiling your project.                                               'Order and Export' 탭을 선택하고, 'Google AdNob Ads JAR'을 체크해 프로젝트가 컴파일될 때 추가되게 합니다.


com.google.ads.AdActivity

The AdMob Ads SDK requires that com.google.ads.AdActivity be declared in your app's AndroidManifest.xml:
AdMob Ads SDK는 앱의 'AndroidManifest.xml' 속에 'com.google.ads.AdActivity'가 선언되어 있기를 요구합니다. :
(굵은 글씨로 되어 있는 부분만 추가 AndroidManifest.xml에 추가하면됩니다.)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
         
package="com.company"
         
android:versionCode="1" android:versionName="1.0">
 
<application android:icon="@drawable/icon" android:label="@string/app_name"
               
android:debuggable="true">
   
<activity android:label="@string/app_name" android:name="BannerExample">
     
<intent-filter>
       
<action android:name="android.intent.action.MAIN"/>
       
<category android:name="android.intent.category.LAUNCHER"/>
     
</intent-filter>
   
</activity>
   
<activity android:name="com.google.ads.AdActivity"
             
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

 
</application>
</manifest>



Permissions

Making ad requests requires the networking permissions INTERNET and ACCESS_NETWORK_STATE, so these must also be declared in the manifest:
광고 요청을 생성에 요구되는 것은 네트워킹 퍼미션 INTERNET 과 ACCESS_NETWORK_STATE, 그리고 이들이 manifest 속에 선언되어 잇는 것이다:
(굵은 글씨로 된 퍼미션만 추가하면 됩니다.)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
         
package="com.company"
         
android:versionCode="1" android:versionName="1.0">
 
<application android:icon="@drawable/icon" android:label="@string/app_name"
               
android:debuggable="true">
   
<activity android:label="@string/app_name" android:name="BannerExample">
     
<intent-filter>
       
<action android:name="android.intent.action.MAIN"/>
       
<category android:name="android.intent.category.LAUNCHER"/>
     
</intent-filter>
   
</activity>
   
<activity android:name="com.google.ads.AdActivity"
             
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
 
</application>
 
<uses-permission android:name="android.permission.INTERNET"/>
 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

</manifest>
You should now be able to rebuild your project without any errors.
지금 오류없이 다시 빌드해야 합니다. (의미는 알겠는데, 우리말로 어떻게 매끄럽게 표현해야 할지 모르겠습니다 ㅠ,.ㅜ)

Posted by 창업자닉군
,