Yash  
                
               
                 
              
                  
                    October 1, 2019,  7:08am
                   
                   
              1 
               
             
            
              hello everyone ive completed creating my game…but iam facing so much trouble from 2 weeks implementing either interstitial or video ads.The code executes without any error ads doesnt show.i want to publish my app…any help will be so much appreciated…pls help.
import android.os.Looper;//for setup() if needed 
import android.os.Bundle; 
import android.view.Window; 
import android.widget.RelativeLayout; 
import android.app.Activity; 
//import com.google.ads.*;// 
import com.google.android.gms.ads.AdRequest; 
import com.google.android.gms.ads.AdView; 
import com.google.android.gms.ads.AdSize; 
import com.google.android.gms.ads.MobileAds;
private InterstitialAd mInterstitialAd;
public void setup() { 
size(800, 1000); 
}
public void draw() { 
background(100); 
rect(100, 100, 100, 100); 
} 
@ Override 
public void onCreate(Bundle savedInstanceState) { 
print(“on create”); 
super.onCreate(savedInstanceState); 
Window window = getActivity().getWindow(); 
RelativeLayout adsLayout = new RelativeLayout(this.getActivity()); 
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams( 
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT); 
MobileAds.initialize(this.getActivity(), “ca-app-pub-3940256099942544~3347511713”); 
mInterstitialAd = new InterstitialAd(this.getActivity()); 
mInterstitialAd.setAdUnitId(“ca-app-pub-3940256099942544/1033173712”); 
mInterstitialAd.loadAd(new AdRequest.Builder().build()); 
if (mInterstitialAd.isLoaded()) { 
mInterstitialAd.show(); 
} else 
{ 
print(“not loaded”); 
}
window.addContentView(adsLayout, lp2); 
}
             
            
               
               
               
            
            
           
          
            
              
                kll  
                
               
              
                  
                    October 1, 2019,  8:09am
                   
                   
              2 
               
             
            
              please format your code 
using the </> Preformatted text button from the editor header menu
and repair above code posting. 
( it shows many errors regarding “” as we use "" in JAVA )
 
i hope someone can help you ( i not even know what you are talking about ) 
still i think that you should get a error about a missing import
import com.google.android.gms.ads.InterstitialAd;
 
??
             
            
               
               
               
            
            
           
          
            
              
                Yash  
                
               
              
                  
                    October 1, 2019,  9:21am
                   
                   
              3 
               
             
            
              Thanks for the reply…after a whole 2 weeks of struggle i ve able to display a interstitial test ad today.Thanks for the concern.BUT i need video ads…i wl post it if i dont succeed.
             
            
               
               
               
            
            
           
          
            
              
                Yash  
                
               
              
                  
                    October 1, 2019, 10:26am
                   
                   
              4 
               
             
            
              hi.this produces no error but ad doesnt show.The code is fine but the oncreate method doesnt get called because it is inside a class ,Any Solution?
import android.os.Looper;//for setup() if needed
import android.os.Bundle;
import android.view.Window;
import android.widget.RelativeLayout;
import android.app.Activity;
//import com.google.ads.*;//
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;
    
class Main extends Activity implements RewardedVideoAdListener
{
private RewardedVideoAd mRewardedVideoAd;
@ Override
  public void onCreate(Bundle savedInstanceState) {
  print("on create"); 
  super.onCreate(savedInstanceState);
  Window window = getActivity().getWindow();
  RelativeLayout adsLayout = new RelativeLayout(this);
  RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
    RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
  MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
    // Use an activity context to get the rewarded video instance.
window.addContentView(adsLayout,lp2);
    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
   mRewardedVideoAd.setRewardedVideoAdListener(this);    
    loadRewardedVideoAd();
}
   private void loadRewardedVideoAd() {
    mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
            new AdRequest.Builder().build());
}
@Override
public void onRewardedVideoAdLoaded() {
if (mRewardedVideoAd.isLoaded()) {
    mRewardedVideoAd.show();
}
}
@Override
public void onRewarded(RewardItem reward) {
    
}
@Override
public void onRewardedVideoAdLeftApplication() {
}
@Override
public void onRewardedVideoAdClosed() {
}
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
}
@Override
public void onRewardedVideoAdOpened() {
   
}
@Override
public void onRewardedVideoStarted() {
}
}