Creating New Extension


Hi Developers,
I am exploring creating extensions using App Inventor Sources. I have written my sample java file but on compile i have got error like this.

One quick question i have, in our java file whatever imports we are writing, are we supposed to include jars for the same??


There is no need to include the .jars for the common stuff.
In fact it would cause a Conflict since the .jar is already included and the .apk wouldn’t compile.


3.3.1 Change your extension to have the desired package name

To make your extension have the desired package name, you need put its Java code in a directory tree whose subdirectories mirror the package name. This tree should sit under appinventor/components/src. For example, to make the Imageprocessor extension be in the package, you would go to the appinventor/components/src directory and in there create the treeedu/mit/appinventor. In more detail

  • go to the folder /appinventor/components/src, and in that folder
  • create a folder edu, and in that folder
  • create a folder mit, and in that folder
  • create a folder appinventor, and in that folder
  • put the file

Learn More Here:


See previous post and then add these imports.

import*; import*; import*; import*;


Hi Ken,
Thanks for your valuable inputs. I have done what you have suggested. My java file is currently here:

C:\App Inventor\appinventor-sources\appinventor\components\src\com\meghraj\extensions

I have tried “ant extensions” again and saw some error again.

In case you would like to see my java file it:

package com.meghraj.extensions;


import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;

import android.os.Handler;

import android.util.Log;

import android.view.Surface;
import android.view.WindowManager;

import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

@DesignerComponent(version = YaVersion.LENGTH_UNIT_CONVERTER_VERSION,
description = “This is the extension to convert one length unit to other”,
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = “”)
@SimpleObject(external = true)
public class LengthConversion extends AndroidNonvisibleComponent implements Component {

public static final int VERSION=1;
@SimpleFunction(Description="this function will return number string")
public String FirstConverion(String str1) {
	if(str1.equalsIgnoreCase("1")) {
		return "one";
	}else if(str1.equalsIgnoreCase("2")) {
		return "two";



Check out my, maybe it will help:


Hi Kevin,
I just placed your file as it is within my package folder and changed package info in the file itself and then initiate the compilation. Again i got error


Remove all SPACE characters from the path


Yeah two things i have corrected.

  1. Removed any spaces from the path
  2. Added constructor to my class.

Works like a charm.

Thanks Ken for your quick responses. Really appreciate.