Procedure for Creating new Component

78 views
Skip to first unread message

Methos Shas

unread,
Apr 3, 2018, 12:20:57 AM4/3/18
to App Inventor Open Source Development
Hi,

Is there any documentation or sample template available for adding new components to AppInventor? I mean to say which files do I need to modify if I create a component java file in /appinventor/components/src/com/google/appinventor/runtime/CustomProgressBar.java... 

Thanks,

Jose Dominguez

unread,
Apr 3, 2018, 3:43:37 AM4/3/18
to app-inventor-open-source-dev
Hi there, yes, there are plenty of docs at
http://appinventor.mit.edu/appinventor-sources/#documentation
Two of them specifically for new components.

cheers,
José
> --
> You received this message because you are subscribed to the Google Groups
> "App Inventor Open Source Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to app-inventor-open-so...@googlegroups.com.
> To post to this group, send email to
> app-inventor-o...@googlegroups.com.
> Visit this group at
> https://groups.google.com/group/app-inventor-open-source-dev.
> For more options, visit https://groups.google.com/d/optout.

Methos Shas

unread,
Apr 8, 2018, 3:22:19 PM4/8/18
to App Inventor Open Source Development
Hi Jose,

I read that documentation. And I think I successfully implemented it. Though I am having some kind of class not found issue. I have the class ItemGrid in components/src/com/google/appinventor/components/runtime/. 

Error from Companion: java.lang.RuntimeException: invalid syntax in eval form: :1:320: caught exception in inliner for # - java.lang.RuntimeException: no such class: com.google.appinventor.components.runtime.ItemGrid gnu.bytecode.ObjectType.getReflectClass(ObjectType.java:179) gnu.bytecode.ClassType.getModifiers(ClassType.java:103) gnu.bytecode.ClassType.isInterface(ClassType.java:471) gnu.expr.InlineCalls.checkType(InlineCalls.java:56) gnu.expr.InlineCalls.visit(InlineCalls.java:49) gnu.expr.InlineCalls.visitSetExpValue(InlineCalls.java:363) gnu.expr.InlineCalls.visitSetExpValue(InlineCalls.java:28) gnu.expr.ExpVisitor.visitSetExp(ExpVisitor.java:114) gnu.expr.InlineCalls.visitSetExp(InlineCalls.java:369) gnu.expr.InlineCalls.visitSetExp(InlineCalls.java:28) gnu.expr.SetExp.visit(SetExp.java:406) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitLetExp(InlineCalls.java:317) gnu.expr.InlineCalls.visitLetExp(InlineCalls.java:28) gnu.expr.LetExp.visit(LetExp.java:207) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.LambdaExp.visitChildrenOnly(LambdaExp.java:1664) gnu.expr.LambdaExp.visitChildren(LambdaExp.java:1651) gnu.expr.InlineCalls.visitScopeExp(InlineCalls.java:279) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:349) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:28) gnu.expr.LambdaExp.visit(LambdaExp.java:1640) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.ExpVisitor.visitAndUpdate(ExpVisitor.java:161) gnu.expr.ExpVisitor.visitExps(ExpVisitor.java:175) gnu.expr.ApplyExp.visitArgs(ApplyExp.java:416) gnu.kawa.reflect.CompileInvoke.validateApplyInvoke(CompileInvoke.java:23) java.lang.reflect.Method.invoke(Native Method) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.kawa.functions.CompilationHelpers.validateApplyToArgs(CompilationHelpers.java:66) java.lang.reflect.Method.invoke(Native Method) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:119) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:28) gnu.expr.ApplyExp.visit(ApplyExp.java:411) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.QuoteExp.validateApply(QuoteExp.java:162) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.kawa.functions.CompilationHelpers.validateApplyToArgs(CompilationHelpers.java:66) java.lang.reflect.Method.invoke(Native Method) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:119) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:28) gnu.expr.ApplyExp.visit(ApplyExp.java:411) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.LambdaExp.visitChildrenOnly(LambdaExp.java:1664) gnu.expr.LambdaExp.visitChildren(LambdaExp.java:1651) gnu.expr.InlineCalls.visitScopeExp(InlineCalls.java:279) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:349) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:28) gnu.expr.ExpVisitor.visitModuleExp(ExpVisitor.java:103) gnu.expr.ModuleExp.visit(ModuleExp.java:482) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.inlineCalls(InlineCalls.java:33) gnu.expr.Compilation.walkModule(Compilation.java:994) gnu.expr.Compilation.process(Compilation.java:1965) gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:330) gnu.expr.ModuleExp.evalModule1(ModuleExp.java:238) gnu.expr.ModuleExp.evalModule(ModuleExp.java:198) gnu.expr.Language.eval(Language.java:943) gnu.expr.Language.eval(Language.java:883) gnu.expr.Language.eval(Language.java:865) com.google.appinventor.components.runtime.util.AppInvHTTPD.serve(AppInvHTTPD.java:191) com.google.appinventor.components.runtime.util.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:489) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) java.lang.Thread.run(Thread.java:761)


Also I am a bit confused about creating my components as I am trying to create a visible component with a table view in which you can specify some amount and it will create grid with image. Something like the first box or last box.



I am really new to AppInventor. So can anyone suggest me best way to create it?

Thanks,

Taifun

unread,
Apr 8, 2018, 3:59:04 PM4/8/18
to App Inventor Open Source Development

How to avoid runtime errors with the companion app

  1. After importing an extension, please restart the companion app.
  2. If you like to use an extension on a different screen, in Screen1 additionally drag the extension into the working area.

While starting the companion app, all necessary assets and also the imported extensions of your project will be copied to your device. So in case the no such class error shows up, the extension code to run the extension is not available on your device. Without that code the companion app is not able to execute methods from the extension.


Taifun


Jose Dominguez

unread,
Apr 9, 2018, 4:38:51 AM4/9/18
to app-inventor-open-source-dev
If this is a visible component and the error is when using the
companion, make sure you build a new companion and sideload it before
trying to use you component.
'ant comps' will push the new Companion to your phone if it is
connected through USB.

cheers,
José

Methos Shas

unread,
Apr 11, 2018, 12:38:02 PM4/11/18
to App Inventor Open Source Development
Hi Jose,

Thanks for getting back. The error is coming when I am trying to run application on AI2 companion app. Also here is what I did, please let me know if the error is caused by any of the following steps.

I created a MockComponent extending MockVisibleComponent. 
Then I created a component extending TableArrangement in components/src/google/appinventor/runtime/.
After that I build them using ant extensions followed by ant.
Both of these builds were successfull without any error.

Also I have attached both files here for reference.

Thanks,
ItemGrid.java
MockItemGrid.java

Jose Dominguez

unread,
Apr 11, 2018, 12:59:23 PM4/11/18
to app-inventor-open-source-dev
Hi Methos,

first of all, are you building a component or an extension? only
non-visible components are supported as extensions, unless you are
using a hack that has recently been discussed in this list and works
in certain cases.

If it is a component, the you don't need to 'ant extensions' and then
'ant'. 'ant' would suffice, but you will need to use the new version
of the companion that is built during process and that includes the
new component you created. The stock companion will not contain it and
will fail with an error similar to the one you reported.

If this is an extension, then it should work with the stock companion,
but then I am not sure if you are writing the correct code for a
visible component which is not allowed as an extension (except for
that hack mentioned).

This is what needs to be done with the Companion if you are working on
a Component (not an extension):
https://docs.google.com/document/u/1/pub?id=1Xc9yt02x3BRoq5m1PJHBr81OOv69rEBy8LVG_84j9jc#h.3aibbept75tt

Hope that helps!

cheers,
José
Reply all
Reply to author
Forward
0 new messages