I'm writing an Android app with cocos2dx with AdMob embedded. It works well except that the app crashes when launch an external intent. It doesn't always happen, but with about 1/3 chance.
The log when it crashes:
09-15 00:23:23.540: I/Choreographer(18986): Skipped 30 frames! The application may be doing too much work on its main thread.
09-15 00:23:33.451: I/Ads(19125): onReceiveAd()
09-15 00:23:34.232: W/A(19125): share
09-15 00:23:34.272: W/crash_handler(19125): Caught a crash, signum=11
09-15 00:23:34.272: E/webcore(19125): Report WebCore crash to the ErrorReportUtils at:Sun Sep 15 00:23:34 格林尼治标准时间+0800 2013
My layout xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
xmlns:ads="
http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ADLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<org.cocos2dx.lib.Cocos2dxGLSurfaceView
android:id="@+id/game_gl_surfaceview"
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"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="a152345aae52285"
ads:loadAdOnCreate="true" />
</RelativeLayout>
The routine launches external intent:
private void _share(String text) {
Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("image/*");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
File file = new File(Environment.getExternalStorageDirectory().getPath() + "/dodgegame.jpg");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, "How do you want to share?"));
}
The crashes happen after "startActivity". Without AdMob, there was no problem with the program, so I'm pretty sure it's a bug of AdMob.
My environment:
AdMob: GoogleAdMobAdsSdk-6.4.1.jar
Android SDK: android-18
Android Ver: 4.1.1JRO03L