How to fix error build extensions method getView()?


#1

How to fix error build extensions is override abstract method getView() ?

Im try learn about build extension,and im get error
"is not abstract and does not override abstract method getView() in AndroidViewComponent"

This my sample java :

package com.kangris.MiniAds;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Parcelable;
import android.util.Log;
import android.view.LayoutInflater;
import android.webkit.*;
import android.widget.*;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.common.YaVersion;
import com.google.appinventor.components.runtime.util.EclairUtil;
import com.google.appinventor.components.runtime.util.SdkLevel;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import java.io.IOException;
import static android.app.Activity.RESULT_OK;
import com.google.appinventor.components.runtime.*;
@SimpleObject(external = true)
@DesignerComponent(category = ComponentCategory.EXTENSION, 
                   description = "MiniAds Code Extension", 
				   iconName = "images/extension.png", 
				   nonVisible = true, 
				   version = 1)
@UsesPermissions(permissionNames = "android.permission.INTERNET,android.permission.WAKE_LOCK,android.permission.INTERNET,android.permission.ACCESS_NETWORK_STATE")
public final class MiniAds extends AndroidViewComponent implements ActivityResultListener {
    
	private final String LOG_TAG = "MiniAds";
    public static final int VERSION = 1;
	private ComponentContainer container;
	private Context context;
    private final WebView miniview;

    public MiniAds(ComponentContainer container) {
        super(container);
		this.container = container;
        this.context = container.$context();
		miniview = new WebView(container.$context());
        miniview.getSettings().setJavaScriptEnabled(true);
        miniview.setWebChromeClient(new WebChromeClient());
        container.$add(this);

        Width(LENGTH_FILL_PARENT);
        Height(LENGTH_FILL_PARENT);
    }
   @SimpleFunction(description = "Load MiniAds;")
   public void LoadHtml(String htmlContent) {
        miniview.loadData(htmlContent, "text/html", "UTF-8");
    }
}

And Log error:

init:
CommonVersion:
[exec] Result: 128
AndroidRuntime:
[mkdir] Created dir: D:\ApkTool\AppyBuilder\AppyBuilder\appinventor-sources\appinventor\components\build\classes\AndroidRuntime
[javac] Compiling 267 source files to D:\ApkTool\AppyBuilder\AppyBuilder\appinventor-sources\appinventor\components\build\classes\AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
[javac] D:\ApkTool\AppyBuilder\AppyBuilder\appinventor-sources\appinventor\components\src\com\kangris\MiniAds\MiniAds.java:37: error: MiniAds is not abstract and does not override abstract method getView() in AndroidViewComponent
[javac] public final class MiniAds extends AndroidViewComponent implements ActivityResultListener {
[javac] ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error
[javac] 1 warning
BUILD FAILED

Thanks you :wink:


#2

You can’t make visible extensions if you want to do that, else just change AndroidViewComponent to AndroidNonvisibleComponent


#3

Ok sir @Ben
Thank you very much :slight_smile:

I wll try again :slight_smile:


#4

Sir @Ben :slight_smile:
change AndroidViewComponent to AndroidNonvisibleComponent
its work to build component/extension …

but not be visible component/extension :neutral_face:

I need visible component …
How to do or make its?

thanks


#5

It is not possible to make visible components as extensions. I stated that in the first reply


#6

Ok sir,now i understand :smile:
haha…

Thank you