Extension Causing Bug report Bug event

Hi,
I was trying to make an extensions and when it is not visible it is working fine but when i set it to visible it is crashing,
This is my code :
package co.sgext.startappads;

import com.google.appinventor.components.annotations.;
import com.google.appinventor.components.runtime.
;
import com.google.appinventor.components.common.;
import com.google.appinventor.components.annotations.SimpleProperty;
import android.content.pm.
;
import com.startapp.android.publish.adsCommon.StartAppSDK;
import com.startapp.android.publish.adsCommon.StartAppAd;
import com.startapp.android.publish.adsCommon.VideoListener;
import com.startapp.android.publish.adsCommon.StartAppAd.AdMode;
import com.startapp.android.publish.adsCommon.adListeners.AdDisplayListener;
import com.startapp.android.publish.adsCommon.adListeners.AdEventListener;
import com.startapp.android.publish.adsCommon.Ad;
import com.startapp.android.publish.ads.banner.Mrec;
import com.startapp.android.publish.ads.banner.Banner;
import com.google.appinventor.components.common.YaVersion;
import android.view.View;
import android.widget.LinearLayout;
import android.app.Activity;
import android.content.Context;

@DesignerComponent(
version = YaVersion.IMAGE_COMPONENT_VERSION,
description = “Start App Ads Extension Made By Abhijith”,
category = ComponentCategory.EXTENSION,
iconName = “”)

@SimpleObject(external = true)
@UsesLibraries(libraries = “startapp.jar”)
@UsesPermissions(permissionNames = “android.permission.ACCESS_WIFI_STATE, android.permission.ACCESS_NETWORK_STATE, android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION, android.permission.RECEIVE_BOOT_COMPLETED, android.permission.BLUETOOTH”)

public class StartAppAds extends AndroidViewComponent {
//values
private Context context;
private final Activity activity;
public LinearLayout layout;
private Banner startAppBanner;

/**

  • Creates a new VideoPlayer component.
  • @param container
    */
public StartAppAds(ComponentContainer container) {
super(container);


this.activity = container.$context();
  startAppBanner = new Banner(container.$context());
startAppBanner.setFocusable(true);
layout = new LinearLayout(container.$context());
container.$add(this);

// LinearLayout.LayoutParams bannerParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
//layout.addView(startAppBanner, bannerParameters);
//container.$add(this);
StartAppSDK.init(activity, “201101496”, false);
StartAppAd.disableSplash();
}

@Override
public View getView(){
  return layout;
}

Any Idea How to fix this?
Thanks

PS: I am a Complete Noob at making extensions

You are trying to create a visible component.
Thats your error

But you can not create visible components in this way you trying it…
You should really learn before do something like that.

I checked the AppInventor Documentation and Read the source code of Some Extensions. I think learning By Doing helps me out in remembering things. Can you Help me out in this?
Any idea On how to do this as well?


Thanks