2014-09-15 5 views
0

먼저 admob없이 코드를 실행 해 보았습니다. 그것은 잘 작동합니다. 그런 다음 admob을 사용하여 코드를 실행 해 보았습니다. 앱 시작시 충돌이 발생해도 메시지가 표시되지 않습니다. main 및 layout.xml 작업에 대한 코드를 제공하고 매니페스트를 제공합니다. 당신이 imageAdapter와 GalleryFlow를 볼 필요가 있다면 나는 그것을 게시 할 것이다. 다음은 내 코드입니다 :Admob 앱 충돌

public class ActivityMain extends Activity { 
    private GalleryFlow mGalleryFlow; 
    private AdView adView; 
    private InterstitialAd interstitial; 

     private int[] imageIds = new int[] { R.drawable.gal1, R.drawable.gal2, 
      R.drawable.gal3, R.drawable.gal4, R.drawable.gal5, 
      R.drawable.gal6, R.drawable.gal7, R.drawable.gal8, 
      R.drawable.gal9, R.drawable.gal10, R.drawable.gal11, 
      R.drawable.gal12, R.drawable.gal13, R.drawable.gal14, 
      R.drawable.gal15, R.drawable.gal16, R.drawable.gal17,}; 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.layout_gallery); 

    findViews(); 
    initViews(); 
    adView = new AdView(this); 
    adView.setAdSize(AdSize.SMART_BANNER); 
    adView.setAdUnitId("MY ID HERE"); 


    RelativeLayout layout = (RelativeLayout) findViewById(R.id.layoutAdView); 
    layout.addView(adView); 


    AdRequest adRequest = new AdRequest.Builder() 
     .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
     .addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE") 
     .build(); 


    adView.loadAd(adRequest); 

    interstitial = new InterstitialAd(this); 
    interstitial.setAdUnitId("MY ID HERE"); 

     AdRequest adRequest1 = new AdRequest.Builder().build(); 
    interstitial.loadAd(adRequest); 
    interstitial.setAdListener(new AdListener() { 
     public void onAdLoaded() { 
      displayInterstitial(); 
     } 
    }); 
    } 

    public void displayInterstitial() { 
    if (interstitial.isLoaded()) { 
     interstitial.show(); 
    } 
    } 






    private void findViews() { 
     mGalleryFlow = (GalleryFlow) findViewById(R.id.Gallery01); 
    } 

    private void initViews() { 
     ImageAdapter adapter = new ImageAdapter(this, imageIds); 

     adapter.createReflectedImages(); 
     mGalleryFlow.setAdapter(adapter); 
    } 


}  

레이아웃 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/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".Runhere" 
    android:background="#FFA500" > 


<com.norka.gallery.GalleryFlow 
android:id="@+id/Gallery01" 
android:layout_width="match_parent" 
android:layout_height="match_parent"/> 

    <RelativeLayout 
android:id="@+id/layoutAdView" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="50dp" 
android:layout_alignParentBottom="true" 
android:gravity="center_horizontal" /> 

</RelativeLayout> 

내 manifest.xml

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

     <uses-permission android:name="android.permission.INTERNET"/> 
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-sdk 
    android:minSdkVersion="10" 
    android:targetSdkVersion="10" /> 



    <application android:icon="@drawable/icon" android:label="@string/app_name"> 

    <activity android:name="com.google.android.gms.ads.AdActivity" 
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> 
     <activity android:name="com.norka.gallery.ActivityMain" 
       android:label="@string/app_name"> 


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


     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 


</manifest> 

로그 캣

09-15 07:32:38.798: I/MultiDex(30217): install 
09-15 07:32:38.798: I/MultiDex(30217): MultiDexExtractor.load(/data/downloads/PrebuiltGmsCore.apk, false) 
09-15 07:32:38.808: I/MultiDex(30217): loading existing secondary dex files 
09-15 07:32:38.808: I/MultiDex(30217): load found 1 secondary dex files 
09-15 07:32:38.808: I/MultiDex(30217): install done 
09-15 07:32:38.808: I/ProviderInstaller(30217): Insert disabled by gate 'gms:security:enable_conscrypt_in_gms_application' 
09-15 07:32:38.828: I/MultiDex(30234): install 
09-15 07:32:38.828: I/MultiDex(30234): MultiDexExtractor.load(/data/downloads/PrebuiltGmsCore.apk, false) 
09-15 07:32:38.838: D/PackageBroadcastService(30217): Received broadcast action=android.intent.action.PACKAGE_REMOVED and uri=com.norka.gallery 
09-15 07:32:38.838: D/dalvikvm(30217): Trying to load lib /data/downloads/libAppDataSearch.so 0x95fb0a40 
09-15 07:32:38.838: E/dalvikvm(30217): dlopen("/data/downloads/libAppDataSearch.so") failed: dlopen failed: "/data/downloads/libAppDataSearch.so" has unexpected e_machine: 40 
09-15 07:32:38.838: E/Icing(30217): Native load error: dlopen failed: "/data/downloads/libAppDataSearch.so" has unexpected e_machine: 40 
09-15 07:32:38.838: I/MultiDex(30234): loading existing secondary dex files 
09-15 07:32:38.838: I/MultiDex(30234): load found 1 secondary dex files 
09-15 07:32:38.838: I/MultiDex(30234): install done 
09-15 07:32:38.848: I/Icing(30217): Storage manager: low false usage 9.34KB avail 6.17GB capacity 6.59GB 
09-15 07:32:38.858: I/ProviderInstaller(30234): Insert disabled by gate 'gms:security:enable_conscrypt_in_gms_application' 
09-15 07:32:38.868: D/dalvikvm(30217): GC_FOR_ALLOC freed 430K, 21% free 2955K/3728K, paused 0ms, total 0ms 
09-15 07:32:38.938: E/Icing(30217): Error initializing, resetting corpora: Could not create native index 
09-15 07:32:38.938: E/Icing(30217): Internal init failed 
09-15 07:32:38.938: E/Icing(30217): Couldn't handle android.intent.action.PACKAGE_REMOVED intent due to initialization failure. 
09-15 07:32:39.108: D/PackageBroadcastService(30217): Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=com.norka.gallery 
09-15 07:32:39.178: E/Icing(30217): Couldn't handle android.intent.action.PACKAGE_ADDED intent due to initialization failure. 
09-15 07:32:39.218: I/PeopleContactsSync(30217): CP2 sync disabled 
09-15 07:32:39.318: D/dalvikvm(30217): GC_FOR_ALLOC freed 590K, 17% free 3189K/3812K, paused 0ms, total 0ms 
09-15 07:32:39.758: D/PackageBroadcastService(30217): Received broadcast action=android.intent.action.PACKAGE_REPLACED and uri=com.norka.gallery 
09-15 07:32:39.758: E/Icing(30217): Couldn't handle android.intent.action.PACKAGE_REPLACED intent due to initialization failure. 

7월 9일에서 15일까지 : 32 : 39.758 : I/PeopleContactsSync (30217) : CP2 동기화 중단 led

+3

그냥 게시물 logcat –

+1

오류를 게시하십시오! – WannaBeGeek

+0

지금 추가했습니다. –

답변

-1

XML 코드에서 adView를 선언하는 것이 훨씬 더 좋습니다. 그것은 당신이 일어나는 것을보고있는 것과 같은 이상한 것들을 방지 할 것입니다. 다음은 XML로 선언하는 방법의 예입니다.

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" style="@style/background"> 

    <com.google.ads.AdView android:id="@+id/adView" 
    ads:loadAdOnCreate="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/admob_unit_id" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 
    </com.google.ads.AdView> 
</RelativeLayout> 
+0

선호되는 방법은 실제로 감가 상각되지 않지만 실제로 프로그래밍 방식으로 ID와 크기를 설정하는 것이라고 생각합니다. – RyPope

+0

이것은 기존 admob을 의미하지만 질문은 새로운 [Google Play 버전의 admob] (https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration#create- 광고보기) – donfuxx