How To Add A Component To Extension


#21

my error
Buildfile: /projects/goldv2/appinventor-sources/appinventor/build.xml

extensions:

clean:

init:

common_CommonUtils:

init:

CommonUtils:

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

CopyToRunLibDir:

components_AndroidRuntime:

init:

CommonConstants:
[javac] Compiling 6 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning

HtmlEntities:

common_CommonVersion:

init:

CommonVersion:
[exec] Result: 128
[exec] Result: 128

AndroidRuntime:
[javac] Compiling 331 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:15: error: WebView is already defined in this compilation unit
[javac] import android.webkit.WebView;
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:51: error: cannot find symbol
[javac] WebView myWebView = new WebView(activity);
[javac] ^
[javac] symbol: variable activity
[javac] location: class WebView
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:52: error: cannot find symbol
[javac] myWebView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
[javac] ^
[javac] symbol: method setLayoutParams(LayoutParams)
[javac] location: variable myWebView of type WebView
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:54: error: incompatible types: WebView cannot be converted to View
[javac] myViewGroup.addView(myWebView);// add webview to arrangement
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:56: error: cannot find symbol
[javac] myWebView.getSettings().setJavaScriptEnabled(true);
[javac] ^
[javac] symbol: method getSettings()
[javac] location: variable myWebView of type WebView
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:59: error: cannot find symbol
[javac] String encodedHtml = Base64.encodeToString(html.getBytes(), Base64.NO_PADDING);
[javac] ^
[javac] symbol: variable Base64
[javac] location: class WebView
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:59: error: cannot find symbol
[javac] String encodedHtml = Base64.encodeToString(html.getBytes(), Base64.NO_PADDING);
[javac] ^
[javac] symbol: variable Base64
[javac] location: class WebView
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:60: error: cannot find symbol
[javac] myWebView.loadData(encodedHtml, “text/html”, “base64”);
[javac] ^
[javac] symbol: method loadData(String,String,String)
[javac] location: variable myWebView of type WebView
[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] Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
[javac] 8 errors
[javac] 1 warning

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 6 seconds
String encodedHtml = Base64.encodeToString(html.getBytes(), Base64.NO_PADDING);
[javac] ^
[javac] symbol: variable Base64
[javac] location: class WebView
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:59: error: cannot find symbol
[javac] String encodedHtml = Base64.encodeToString(html.getBytes(), Base64.NO_PADDING);
[javac] ^
[javac] symbol: variable Base64
[javac] location: class WebView
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/krishjha07/WebView/WebView.java:60: error: cannot find symbol
[javac] myWebView.loadData(encodedHtml, “text/html”, “base64”);
[javac] ^
[javac] symbol: method loadData(String,String,String)
[javac] location: variable myWebView of type WebView
[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] Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
[javac] 8 errors
[javac] 1 warning

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 6 seconds

my code
/** ~~~~~

  • Created with the AppyBuilder Code Editor.
  • This is a template for basic Extension.
  • Modify this template to customize your extension.
  • **** NOTE: DO NOT use a package name.
  • **** The package name will be created for you automatically.
  • **** Adding a package name will cause a compile error
    /
    import android.app.Activity;
    import android.os.Bundle;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.content.Context;
    import android.content.res.TypedArray;
    import android.util.AttributeSet;
    import android.view.Gravity;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.RemoteViews;
    import android.view.ViewGroup.LayoutParams;
    import android.view.ViewGroup;
    import android.content.Context;
    import android.util.Log;
    import com.google.appinventor.components.annotations.
    ;
    import com.google.appinventor.components.runtime.*;
    import com.google.appinventor.components.common.ComponentCategory;

@DesignerComponent(version = 1, description = “This Extension was created with the AppyBuilder Code Editor.
” +
“Create your own here:
https://editor.appybuilder.com
”,
category = ComponentCategory.EXTENSION,
nonVisible = true, iconName = “http://appyBuilder.com/extensions/icons/extension.png”)
@SimpleObject(external = true)
public class WebView extends AndroidNonvisibleComponent {
private ComponentContainer container;
/**
* @param container container, component will be placed in
*/
public WebView(ComponentContainer container) {
super(container.$form());
this.container = container;
}

@SimpleFunction(description=“createWebView”)
public void createWebView(AndroidViewComponent arrangement, String html){
ViewGroup myViewGroup = (ViewGroup)arrangement.getView();

        WebView myWebView = new WebView(activity);
        myWebView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        
        myViewGroup.addView(myWebView);// add webview to arrangement 
    
    myWebView.getSettings().setJavaScriptEnabled(true);
    //myWebView.loadUrl(url);
    //String unencodedHtml = "<html><body>Hello World!</body></html>";
    String encodedHtml = Base64.encodeToString(html.getBytes(), Base64.NO_PADDING);
    myWebView.loadData(encodedHtml, "text/html", "base64");
   }

}

what should i add more