title: My android app Crash when trying to load a facebook Native Ad (java.lang.NoSuchMethodError: No static method isChildDirected())
body: <p>My application crashes when trying to load a facebook Native Ad, here is the log Error :</p>
  <pre><code>2020-11-14 12:31:15.968 5710-5710/? E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.demopackage.name, PID: 5710
      java.lang.NoSuchMethodError: No static method isChildDirected()Z in class Lcom/facebook/ads/AdSettings; or its super classes (declaration of 'com.facebook.ads.AdSettings' appears in /data/app/com.demopackage.name-meNj0dpRfln7Tuz2WwJzdQ==/base.apk)
          at com.facebook.ads.redexgen.X.1l.A01(:3647)
          at com.facebook.ads.redexgen.X.S9.A0B(:53051)
          at com.facebook.ads.redexgen.X.S9.A0Q(:53123)
          at com.facebook.ads.redexgen.X.S9.A0R(:53125)
          at com.facebook.ads.redexgen.X.cR.A1M(:74774)
          at com.facebook.ads.redexgen.X.Jy.loadAd(:41976)
          at com.facebook.ads.redexgen.X.cR.loadAd(:74897)
          at com.facebook.ads.NativeAdBase.loadAd(NativeAdBase.java:242)
          at com.demopackage.name.activities.MainActivity.loadNativeAd(MainActivity.java:216)
          at com.demopackage.name.activities.MainActivity.onCreate(MainActivity.java:157)
          at android.app.Activity.performCreate(Activity.java:6975)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
          at android.app.ActivityThread.-wrap11(Unknown Source:0)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
          at android.os.Handler.dispatchMessage(Handler.java:105)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6541)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
  </code></pre>
  <p>Im using the latest version of Facebook Audience Network SDK <code>'com.facebook.android:audience-network-sdk:6.2.0'</code> and also tried the <code>'com.facebook.android:audience-network-sdk:6.0.0'</code></p>
  <p>here is the implementation that used on many other app and its working but not for this app:</p>
  <pre><code>        nativeAd = new NativeAd(this, getString(R.string.fb_native));
  
          NativeAdListener nativeAdListener = new NativeAdListener() {
              @Override
              public void onMediaDownloaded(Ad ad) {
                  // Native ad finished downloading all assets
                  Log.e(TAG, &quot;Native ad finished downloading all assets.&quot;);
              }
  
              @Override
              public void onError(Ad ad, AdError adError) {
                  // Native ad failed to load
                  Log.e(TAG, &quot;Native ad failed to load: &quot; + adError.getErrorMessage());
              }
  
              @Override
              public void onAdLoaded(Ad ad) {
  
                  // Render the Native Ad Template
                  View adView = NativeAdView.render(MainActivity.this, nativeAd);
                  LinearLayout nativeAdContainer = (LinearLayout) findViewById(R.id.native_ad_container);
                  // Add the Native Ad View to your ad container.
                  // The recommended dimensions for the ad container are:
                  // Width: 280dp - 500dp
                  // Height: 250dp - 500dp
                  // The template, however, will adapt to the supplied dimensions.
                  nativeAdContainer.addView(adView, new ViewGroup.LayoutParams(MATCH_PARENT, 800));
                  // Native ad is loaded and ready to be displayed
                  Log.d(TAG, &quot;Native ad is loaded and ready to be displayed!&quot;);
              }
  
              @Override
              public void onAdClicked(Ad ad) {
                  // Native ad clicked
                  Log.d(TAG, &quot;Native ad clicked!&quot;);
              }
  
              @Override
              public void onLoggingImpression(Ad ad) {
                  // Native ad impression
                  Log.d(TAG, &quot;Native ad impression logged!&quot;);
              }
          };
  
          // Request an ad
          nativeAd.loadAd(
                  nativeAd.buildLoadAdConfig()
                          .withAdListener(nativeAdListener)
                          .withMediaCacheFlag(NativeAdBase.MediaCacheFlag.ALL)
                          .build());
     
  </code></pre>
  <p>the app is working fine when not calling the <code>loadAd</code> method.</p>
  <p>and here is the dependencies that i'm using on my app:</p>
  <pre><code>dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation 'androidx.appcompat:appcompat:1.2.0'
      implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
      testImplementation 'junit:junit:4.13'
      androidTestImplementation 'androidx.test:runner:1.3.0'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
  
      implementation 'androidx.legacy:legacy-support-v4:1.0.0'
      implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
      implementation 'androidx.exifinterface:exifinterface:1.3.1'
      implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
      implementation 'androidx.recyclerview:recyclerview:1.1.0'
      implementation 'androidx.cardview:cardview:1.0.0'
      implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
      implementation 'androidx.browser:browser:1.2.0'
      implementation 'com.google.android.material:material:1.0.0'
      implementation 'androidx.annotation:annotation:1.1.0'
      implementation 'androidx.multidex:multidex:2.0.1'
      implementation &quot;androidx.work:work-runtime:2.4.0&quot;
      implementation 'androidx.appcompat:appcompat:1.2.0'
  
  
      implementation 'com.hold1:keyboardheightprovider:0.0.9'
      implementation 'org.wysaid:gpuimage-plus:2.6.3'
      implementation 'com.karumi:dexter:6.2.1'
      implementation 'com.squareup.picasso:picasso:2.71828'
      implementation 'com.steelkiwi:cropiwa:1.0.3'
      implementation 'com.github.bumptech.glide:glide:4.11.0'
      annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
      implementation 'com.airbnb.android:lottie:3.4.1'
      implementation 'com.github.pavlospt:circleview:1.3'
      implementation 'de.hdodenhof:circleimageview:3.1.0'
      implementation 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
      implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'
      implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
      implementation 'com.makeramen:roundedimageview:2.3.0'
      implementation 'com.agrawalsuneet.androidlibs:dotsloader:1.4'
      implementation 'com.isseiaoki:simplecropview:1.1.8'
  
      implementation 'com.google.android.gms:play-services-ads:19.5.0'
      implementation 'androidx.annotation:annotation:1.1.0'
      implementation 'com.facebook.android:audience-network-sdk:6.2.0'
  
  
  //    implementation 'com.unity3d.ads:unity-ads:3.4.6'
  
  }
  </code></pre>