2

i have an admob-view at the bottom of my activity, the XML Looks like this:

<RelativeLayout
    android:id="@+id/ad_wrapper" 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id">
    </com.google.android.gms.ads.AdView>
</RelativeLayout>

so i'm not using a Fragment! I also tried this: How to avoid Admob blocking the UI thread. So my in my onCreate i do the following:

new Thread(new Runnable() {
    @Override
    public void run() {
        // TODO Auto-generated method stub
        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
    }
}).run();

But the Problem stays the same. If i run my app with bad Network Connection my whole activity waits until the ad has finished loading. Sometimes this takes up to 20 seconds. So it Looks like he is blocking the UIThread. Maybe someone has a solution? It's really obfuscating because behind the Scenes Google Play Services must also use a Background Thread to establish a Network Connection to download the Ad so why is it blocking my UI?

Here the log filtered for ads:

01-01 15:26:55.960: D/dalvikvm(18253): open_cached_dex_file : /data/data/com.android.faccess/cache/ads-1555443625.jar /data/data/com.android.faccess/cache/ads-1555443625.dex 01-01 15:26:55.961: D/dalvikvm(18253): DexOpt: --- BEGIN 'ads-1555443625.jar' (bootstrap=0) ---

01-01 15:26:56.046: D/dalvikvm(18253): DexOpt: --- END 'ads-1555443625.jar' (success) ---

01-01 15:26:56.046: D/dalvikvm(18253): DEX prep '/data/data/com.android.faccess/cache/ads-1555443625.jar': unzip in 0ms, rewrite 84ms

01-01 15:26:56.074: I/Ads(18253): Use AdRequest.Builder.addTestDevice("8AF8C1D3A935E64B84C4CBBFDF5F33F7") to get test ads on this device.

01-01 15:27:12.351: I/dalvikvm(18253): Could not find method android.webkit.WebView.evaluateJavascript, referenced from method com.google.android.gms.ads.internal.o.a.evaluateJavascript

01-01 15:27:12.357: I/webkit/webview_proxy(18253): WebView() constructor=com.google.android.gms.ads.internal.o.a{41f75b30 VFE.HV.. ......I. 0,0-0,0}

01-01 15:27:12.390: I/webkit/webview_proxy(18253): Webview.loadDataWithBaseURL() this=com.google.android.gms.ads.internal.o.a{41f75b30 VFEDHVCL ......ID 0,0-960,150} baseUrl: http://googleads.g.doubleclick.net:80/mads/gma

Update

You are right guys, my UI isn't blocked. It's my Background Thread (AsyncTask) which is blocked. onPreExecute is called and finished(!) immediatly but doInBackground has a delay about 5-20seconds till it is called if Network Connection is bad. What i noticed is that doInBackground starts immediatly after following logcat Messages:

01-02 02:23:23.289: E/NativeCrypto(16015): ssl=... cert_verify_callback ..._store_ctx=... arg=...
01-02 02:23:23.289: E/NativeCrypto(16015): ssl=... cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_ECDSA
01-02 02:23:23.889: E/NativeCrypto(16015): ssl=... cert_verify_callback ..._store_ctx=... arg=...
01-02 02:23:23.890: E/NativeCrypto(16015): ssl=... cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_ECDSA

I have only implemented Admob, Facebook for sharing Content and Google+ for sharing Content. What of These can cause this Problem, or generally when does a Native Crypto error log appears? Thank you for your help!

Update 2

Figured out the line which cause the Problem.. it's Facebook and his UILifeCycleHelper in my onCreate:

myLifeCycleHelper = new UiLifecycleHelper(this, null);
myLifeCycleHelper.onCreate(savedInstanceState);

the Problem is, Facebook recommends to instantiate the UILifeCycleHelper in onCreate.. if i comment that line out, everythink works with the expected Speed. So my final question, what is the solution to implement the LifeCycleHelper with the expected Speed, it doesn't block my UI, but it Looks like it's blocking my BackgroundThread.

Community
  • 1
  • 1
MMike
  • 598
  • 3
  • 23
  • there you got it......@NoName – MMike Jan 01 '15 at 14:33
  • @MMike What version of Google Play Services are you using for your ads? – Jared Burrows Jan 01 '15 at 15:32
  • @JaredBurrows latest Version, everything is up 2 date! – MMike Jan 01 '15 at 16:11
  • 1
    @MMike What version of Google Play Services are you using? – Jared Burrows Jan 01 '15 at 23:27
  • 2
    Post all of your onCreate. AdView#loadAd doesn't block the UI thread. There is something else n your app causing the problem. – William Jan 01 '15 at 23:30
  • @JaredBurrows got an Update, it has nothing to do with the UIThread, my Asynctask `doInBackground` is being blocked. Please see update. – MMike Jan 02 '15 at 01:31
  • @William you were right, it isn't the UIThread which is being blocked, it is my `AsyncTask` especially the `doInBackground` which is blocked. Please have a look at my update – MMike Jan 02 '15 at 01:32
  • @MMike You never answered my question. What is the version number? I just want to make sure. – Jared Burrows Jan 02 '15 at 01:41
  • @JaredBurrows sorry Jared, it's Revision number 22 from the Android sdk Manager in eclipse. I figured the line which cause the Problem out i will update in 2mins! – MMike Jan 02 '15 at 01:43
  • @Jared updated, please see update – MMike Jan 02 '15 at 01:46
  • @MMike Alright. You are using Eclipse and including the library project? The latest version of Google Play Services has an ANR issue, do you see any UI? https://code.google.com/p/android/issues/detail?id=82157. If you were using Gradle, you can change your Google Player Services version easier. – Jared Burrows Jan 02 '15 at 02:08
  • @JaredBurrows yes i'm using eclipse including libary Project, i see UI and UI is responding. it's not the UI which is freezed it's my backgroundthread who doesn't start because of the Facebook UILifeCicleHelper please see my question bottom :) – MMike Jan 02 '15 at 13:53

0 Answers0