How to create an Extension

This guide is old. Please follow this updated guide: Create Extensions - Kodular Docs

Hello,

I this Tutorial I am going to teach you how to create Extensions for AppInventor and Makeroid.


Tools you will need:


Step 1: Download and Install Java JDK

Click to Download

  • Install Java JDK
  • Set the Environmental Variables:
  • SetJAVA_HOME” to your install Java install path. Example: “C:/Java/jdk1.8.0_31
  • EditPATH” and add those:
    %JAVA_HOME%/bin
    %JAVA_HOME%/jre/bin
  • SetCLASSPATH” to “%JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tools.jar

Step 2: Download and Install Apache Ant

Click to Download

  • Download Apache Ant 1.10.1
  • Unzip the folder and move it to a place where it is safe
  • Set the Environmental Variables:
  • SetANT_HOME” to the Folder where ant is. Example: “C:/Ant/apache-ant-1.10.1
  • EditPath” and add “Folder where ant is+ \bin”. Example: “C:/Ant/apache-ant-1.10.1\bin
  • EditClassPath” and add “Folder where ant is+ \lib”. Example: “C:/Ant/apache-ant-1.10.1\lib

Step 3: Download and Install Git Bash

Click to Download

  • Download and Install Git Bash

Step 4: Download AppInventor Sources

Click to Download

  • Download appinventor-sources
  • Unzip the folder and move it to a place where it is safe

Step 5: Testing if it works

  • Go to your appinventor-sources folder and open the appinventor folder
  • Right click in the folder and select “Git Bash Here
  • Type “ant” and click on enter

If says: “BUILD SUCCESSFUL”, then you can go to Step 6
If says: “BUILD FAILED”, then you did something wrong or missed a step


Step 6: Building an Extension

SimpleExtension.java (2.8 KB)

  • Download the file and move it to “appinventor-sources/appinventor/components/src/com/sanderjochems/
    Note: If you want a other package name, then you need to put the SimpleExtensions.java in a other folder and update the package name in the file
  • Go back to the “appinventor” folder
  • Right click in the folder and select “Git Bash Here
  • Type “ant extensions” and click on enter

If says: “BUILD SUCCESSFUL”, then you can create Extensions :tada:
If says: “BUILD FAILED”, then you did something wrong

18 Likes

BEST TUTORIAL LINK: YouTube

3 Likes

but voice of the host was not clear

I will try to create a video tutorial on how to make extensions. With my high quality microphone according to a very cheap chinees webshop

7 Likes

good going to be helpful for freshers

3 Likes

any way to resolve this error
java.lang.RuntimeException: Cannot convert Java type 'java.net.URL' to Yail type
:sob::sob:

What object is your parameter? You take Strings, int, boolean, views as params

1 Like

It is url.
imported this
import java.net.*;
i am just try to learn how to create extension.
my methord is

public long getFileSize(URL url) {
  HttpURLConnection conn = null;
  try {
    conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("HEAD");
    return conn.getContentLengthLong();
  } catch (IOException e) {
    return -1;
   
  } finally {
    if (conn != null) {
      conn.disconnect();
    }
  }
}

You can only use that objects as params which can be dragged and snapped into a socket like number block (int), text block (String), etc

1 Like

thanks @pavi2410

You can look into source of Web component for how to get URL input.

4 Likes

yeah i am finding it .
right now i am thinking to take string as parameter and later on convert in URL.
i will update when i find it

#HINDI
Mere essataement me kya glti hai ?

ye eror aarha hai

C:\appinventor-extensions-master\appinventor\components\src\com\aashriyatechnology\Abcbar.java:238: error: int cannot be dereferenced
[javac] if (VERSION.SDK_INT >= 21) {
[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.

Konsa package import kiya?

import android.os.Build.VERSION;

public static final int VERSION = 1;

import android.os.Build;

Check -->

if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP /* 21 */) {
...
}

Aise conflict nahi hoga.

pahale ye use kiya tha

if (VERSION.SDK_INT >= 21) {
this.ll2.setElevation((float) pixelsElevation);
}

aur ab

if (Version.SDK_INT >= VERSION_CODES.LOLLIPOP /* 21 */) {
this.ll2.setElevation((float) pixelsElevation);
}

ab ka error ye hai

C:\appinventor-extensions-master\appinventor\components\src\com\aashriyatechnology\Abcbar.java:240: error: cannot find symbol
[javac] if (Version.SDK_INT >= VERSION_CODES.LOLLIPOP /* 21 /) {
[javac] ^
[javac] symbol: variable Version
[javac] location: class Abcbar
[javac] C:\appinventor-extensions-master\appinventor\components\src\com\aashriyatechnology\Abcbar.java:240: error: cannot find symbol
[javac] if (Version.SDK_INT >= VERSION_CODES.LOLLIPOP /
21 */) {
[javac] ^
[javac] symbol: variable VERSION_CODES
[javac] location: class Abcbar
[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] 2 errors

matlab ?

TRY THIS

int sdk = android.os.Build.VERSION.SDK_INT;
      if (sdk < android.os.Build.VERSION_CODES.LOLLIPOP) {
// YOUR CODE
}