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

35 Likes

BEST TUTORIAL LINK: YouTube

6 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

8 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

This post was flagged by the community and is temporarily hidden.

This post was flagged by the community and is temporarily hidden.

import android.os.Build.VERSION;

public static final int VERSION = 1;

import android.os.Build;

Check -->

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

This post was flagged by the community and is temporarily hidden.

This post was flagged by the community and is temporarily hidden.

TRY THIS

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