2014-09-10 2 views
0

이되지 관련 몹 존재 파일 가져 오기 18 (android4.2) 이상하지 실행 앱 (가져 오기

MainActivity.java

오류 API를 사용하여 작업을 테스트 몹을 보내 주시기 바랍니다 com.google.android.gms.ads.AdRequest을 가져, 가져 오기 com.google.android.gms.ads.AdView,

package com.a.test; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.MenuItem; 
import com.google.android.gms.ads.AdRequest; 
import com.google.android.gms.ads.AdView; 

public class MainActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     AdRequest adRequest = new AdRequest.Builder() 
     .build(); 
     AdView adView = (AdView) view.findViewById(R.id.adView); 
     adView.loadAd(adRequest); 
    } 
} 

AndroidManifest를을 .XML

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.a.test" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="19" /> 


    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name="com.a.test.MainActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity android:name="com.google.android.gms.ads.AdActivity" 
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> 

    </application> 

</manifest> 

레이아웃 main.xml에

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="${packageName}.${activityClass}" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/hello_world" /> 

    <com.google.android.gms.ads.AdView android:id="@+id/adView" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          ads:adSize="BANNER" 
          ads:adUnitId="MY ID"/> 
</RelativeLayout> 
+0

admob jar를 포함 시켰습니까? –

+0

어떻게 얻을 수 admobsdk – user3783249

답변

1

는 이미 구글은 프로젝트 내에서 서비스 라이브러리를 재생 참조했습니다 바랍니다. 아직 가지고 있지 않다면, /libs/폴더에서 admob sdk jar를 제거하고 프로젝트에서 Google Play 서비스 라이브러리 버전 4 이상을 참조하십시오. 그런 다음 레이아웃에

변경 :

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

에 : 매니페스트에서

xmlns:ads="http://schemas.android.com/apk/res-auto" 

는 추가 :

<meta-data 
     android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version" /> 

확인 당신이 <application 태그 내에 추가 확인

관련 문제