I am creating a simple gradient extension and I found some error
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:
[javac] Compiling 1 source file to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
common_CommonVersion:
init:
CommonVersion:
[exec] Result: 128
[exec] Result: 128
AndroidRuntime:
[javac] Compiling 332 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/farazfiroz2472/Gradient/Gradient.java:48: error: cannot find symbol
[javac] View view = component.getview();
[javac] ^
[javac] symbol: method getview()
[javac] location: variable component of type AndroidViewComponent
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/farazfiroz2472/Gradient/Gradient.java:68: error: incompatible types: unexpected return value
[javac] return GradientDrawable.Orientation.TOP_BOTTOM;
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/farazfiroz2472/Gradient/Gradient.java:73: error: incompatible types: unexpected return value
[javac] return GradientDrawable.Orientation.BOTTOM_TOP;
[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] 3 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: 7 seconds
472/Gradient/Gradient.java:48: error: cannot find symbol
[javac] View view = component.getview();
[javac] ^
[javac] symbol: method getview()
[javac] location: variable component of type AndroidViewComponent
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/farazfiroz2472/Gradient/Gradient.java:68: error: incompatible types: unexpected return value
[javac] return GradientDrawable.Orientation.TOP_BOTTOM;
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/farazfiroz2472/Gradient/Gradient.java:73: error: incompatible types: unexpected return value
[javac] return GradientDrawable.Orientation.BOTTOM_TOP;
[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] 3 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: 7 seconds
My Code
import android.content.Context;
import android.util.Log;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.AndroidViewComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.View;
@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 Gradient extends AndroidNonvisibleComponent {
private ComponentContainer container;
/**
* @param container container, component will be placed in
*/
public Gradient(ComponentContainer container) {
super(container.$form());
this.container = container;
}
@SimpleFunction
public void SetGradient(AndroidViewComponent component, Object orientation, int color1, int color2) {
try {
View view = component.getview();
GradientDrawable gradientDrawable = new GradientDrawable(
(GradientDrawable.Orientation) orientation,
new int[] {color1,color2});
view.setBackground(gradientDrawable);
}
catch(Exception e) {
ErrorOccured(e.getMessage());
}
}
@SimpleEvent
public void ErrorOccured(String error) {
EventDispatcher.dispatchEvent(this, "ErrorOccured", error);
}
@SimpleProperty
public void TopToBottom() {
return GradientDrawable.Orientation.TOP_BOTTOM;
}
@SimpleProperty
public void BottomToTop() {
return GradientDrawable.Orientation.BOTTOM_TOP;
}
@SimpleProperty
public Object LeftToRight() {
return GradientDrawable.Orientation.LEFT_RIGHT;
}
@SimpleProperty
public Object RightToLeft() {
return GradientDrawable.Orientation.RIGHT_LEFT;
}
@SimpleProperty
public Object BottomLeftToTopRight() {
return GradientDrawable.Orientation.BL_TR;
}
@SimpleProperty
public Object TopRightToBottomLeft() {
return GradientDrawable.Orientation.TR_BL;
}
@SimpleProperty
public Object TopLeftToBottomRight() {
return GradientDrawable.Orientation.TL_BR;
}
@SimpleProperty
public Object BottomRightToTopLeft() {
return GradientDrawable.Orientation.BR_TL;
}
@SimpleFunction
public int ParseColor(String color) {
return Color.parseColor(color);
}
}