Build Failed In Sample SimpleMaths.java extension

CODE
package com.nisarga;

// Only these imports are required to interact with Kodular
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;

@DesignerComponent(version = 1, // Update version here, You must do for each new release to upgrade your extension
               description = "Simple Maths extension created by you",
               category = ComponentCategory.EXTENSION,
               nonVisible = true,
               iconName = "images/extension.png") // Change your extension's icon from here; can be a direct url
@SimpleObject(external = true)
public class SimpleMaths extends AndroidNonvisibleComponent {

public SimpleMaths(ComponentContainer container) {
    super(container.$form());
}

@SimpleFunction(description = "Simple addition of two numbers")
public int Add(int a, int b) {
    return a + b;
}

@SimpleFunction(description = "Simple subtraction of two numbers")
public int Subtract(int a, int b) {
    return a - b;
}
}

After giving ant command

$ ant
Buildfile: C:\Users\rubyd\Desktop\Code\extension-template-master\build.xml

javac:
[javac] Compiling 1 source file to C:\Users\rubyd\Desktop\Code\extension-template-master\build\classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:4: error: package com.google.appinventor.components.annotations does not exist
[javac] import com.google.appinventor.components.annotations.;
[javac] ^
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:5: error: package com.google.appinventor.components.runtime does not exist
[javac] import com.google.appinventor.components.runtime.
;
[javac] ^
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:6: error: package com.google.appinventor.components.common does not exist
[javac] import com.google.appinventor.components.common.*;
[javac] ^
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:14: error: cannot find symbol
[javac] public class SimpleMaths extends AndroidNonvisibleComponent {
[javac] ^
[javac] symbol: class AndroidNonvisibleComponent
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:8: error: cannot find symbol
[javac] @DesignerComponent(version = 1, // Update version here, You must do for each new release to upgrade your extension
[javac] ^
[javac] symbol: class DesignerComponent
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:13: error: cannot find symbol
[javac] @SimpleObject(external = true)
[javac] ^
[javac] symbol: class SimpleObject
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:16: error: cannot find symbol
[javac] public SimpleMaths(ComponentContainer container) {
[javac] ^
[javac] symbol: class ComponentContainer
[javac] location: class SimpleMaths
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:20: error: cannot find symbol
[javac] @SimpleFunction(description = "Simple addition of two numbers")
[javac] ^
[javac] symbol: class SimpleFunction
[javac] location: class SimpleMaths
[javac] C:\Users\rubyd\Desktop\Code\extension-template-master\src\com\nisarga\SimpleMaths\SimpleMaths.java:25: error: cannot find symbol
[javac] @SimpleFunction(description = "Simple subtraction of two numbers")
[javac] ^
[javac] symbol: class SimpleFunction
[javac] location: class SimpleMaths
[javac] 9 errors
[javac] 1 warning

BUILD FAILED
C:\Users\rubyd\Desktop\Code\extension-template-master\build.xml:29: Compile failed; see the compiler error output for details.

Total time: 0 seconds

How to fix?

1 Like

It looks like copy pasted code

1 Like

Yes it is!

I ran the same build with online cloud compiler it worked but it is not working in PC.

You are adding extension maybe you should change Category of your extension ,Package and some other small change then you might try it should work.

2 Likes

I think there is problem with my JAVA version.
I am currently using JAVA 8

No there is no problem

Your extension templete does not have libs

what? how to add?

According to the readme:

Since you've already cloned it, you should instead run

git submodule update --init

to download the libraries.

4 Likes