title: Android AdMob AIR Native Extension crashes when adding AdView to LinearLayout
body: <p>I'm creating an AIR native extension to integrate AdMob.</p>
  
  <p>I've followed the guidelines for using external resources described here: <a href="http://www.adobe.com/devnet/air/articles/ane-android-devices.html" rel="nofollow noreferrer">http://www.adobe.com/devnet/air/articles/ane-android-devices.html</a></p>
  
  <p>and packaged google's adMob jar in my native extension jar as described here: <a href="https://stackoverflow.com/questions/7732742/air-3-native-extensions-for-android-can-i-how-to-include-3rd-party-libraries?answertab=votes#tab-top">AIR 3 Native Extensions for Android - Can I/How to include 3rd party libraries?</a></p>
  
  <p>I have a <code>NewAdFunction</code> class which implements <code>FREFunction</code> and is called by the actionscript side. The <code>NewAdFunction.call()</code> function contains essentially the following: (in my actual code I have the necessary try catches)</p>
  
  <pre><code>Intent intent = new Intent(context.getActivity(), AdMobActivity.class);
  layoutID = context.getResourceId("layout.adlayout");
  intent.putExtra("layoutID", layoutID);
  context.getActivity().startActivity(intent);
  </code></pre>
  
  <p>In the above code <code>adlayout</code> is an xml located in res/layout. I package the entire res folder in my final jar and include the following code in my test AIR project's xml.</p>
  
  <pre><code>&lt;application android:enabled="true" android:debuggable="true"&gt;
              &lt;activity android:name="com.mycompany.admob.AdMobActivity"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>In the following code everything works up until it reaches <code>layout.addView(adView);</code> At this point the program crashes but nothing is printed through the console.</p>
  
  <pre><code>public class AdMobActivity extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          int layoutID = getIntent().getIntExtra("layoutID", -1);
          setContentView(layoutID);
          LinearLayout layout = (LinearLayout)findViewById(layoutID);
          AdView adView = new AdView(this, AdSize.BANNER, MY_DEVELOPER_ID);
          layout.addView(adView);
      }
  }
  </code></pre>
  
  <p>All I could think of is that layout could be null, but I added a trace function and it isn't null.</p>