Many Runtime Errors after placing Extension

63 views
Skip to first unread message

Arne Mailand

unread,
Oct 2, 2016, 3:25:57 PM10/2/16
to App Inventor Open Source Development
Hey guys,

I just successfully built my first extension (huurayyy). Here is the Source code which I used:

package com.google.appinventor.components.runtime;

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.common.YaVersion;
import com.google.appinventor.components.runtime.util.AsynchUtil;
import com.google.appinventor.components.runtime.util.ErrorMessages;
import com.google.appinventor.components.runtime.util.FileUtil;
import com.google.appinventor.components.runtime.Form;
import com.google.appinventor.components.runtime.ReplForm;

import android.app.Activity;
import android.content.Context;
import android.os.Environment;
import android.util.Log;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.Socket;

@DesignerComponent(version = YaVersion.FILE_COMPONENT_VERSION,
        description = "Meine erste Extension",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,
        iconName = "images/extension.png")
@SimpleObject(external = true)
@UsesPermissions(permissionNames = "android.permission.WRITE_EXTERNAL_STORAGE, android.permission.INTERNET, android.permission.READ_EXTERNAL_STORAGE")
public class Filet extends AndroidNonvisibleComponent implements Component{

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

@SimpleFunction(description = "Funktionsbeschreibung hier")

    public void Filet2(){

        Socket socket;

        File file = new File(Environment.getExternalStorageDirectory(), "bild.jpg");


        byte[] bytes = new byte[(int) file.length()];

        try {

            socket = new Socket("192.168.178.32", 80);

            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));


            BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());

            bis.read(bytes, 0, bytes.length);

            bos.write(bytes, 0, bytes.length);

            bos.flush();


            socket.close();


        } catch (FileNotFoundException e) {

            e.printStackTrace();

        } catch (IOException e) {

            e.printStackTrace();

        } finally {
        }

    }


As soon as I place the extension in the designer view while my companion is connected, I get this Runtime Error Message on the Blocks View:

Error from Companion: java.lang.RuntimeException: invalid syntax in eval form: :1:1510: caught exception in inliner for # - java.lang.RuntimeException: no such class: com.google.appinventor.components.runtime.Filet 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.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:511) 

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.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:511) 

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.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:511) 

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:476) 

java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 

java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 

java.lang.Thread.run(Thread.java:856)


I am absoluetely. overstrained with these errors. Can anybody help me out?


I guess it has something to do with the import files... right? To be honest, I couldn't comprehend at this point which files have to get imported. I just copied these lines from the built in web and file component.


I really appreciate any help. Thank you in advance


Arne

Evan Patton

unread,
Oct 2, 2016, 3:35:12 PM10/2/16
to App Inventor Open Source Development
This is a known issue. After loading the extension into the companion, you will need to restart and reconnect the companion so that it can properly link your extension code on the device.

Evan

Arne Mailand

unread,
Oct 2, 2016, 5:34:32 PM10/2/16
to App Inventor Open Source Development
Thanks, Evan. I am really glad to hear that! What exactly does restart mean? I reopended the companion app a few times, also reconnected with AI. Do I have to reboot the phone?

Arne Mailand

unread,
Oct 2, 2016, 5:46:54 PM10/2/16
to App Inventor Open Source Development
Oh well, I just restarted my phone and I am still getting the same runtime error :-(

Apart from the first line

java.lang.RuntimeException: invalid syntax in eval form: :1:1510


all lines are the same. I doubt if this is the known issue... Any ideas what could cause these errors?


I read that network connections have to be established in different threads. I also experienced that in Android Studio. Could that be causing the errors maybe?

Arne Mailand

unread,
Oct 3, 2016, 8:52:42 AM10/3/16
to App Inventor Open Source Development
Please help me. I need to get my extension working for my graduation thesis.

Arne Mailand

unread,
Oct 3, 2016, 9:34:12 AM10/3/16
to App Inventor Open Source Development
Update:

The same error occurs, when I place the modified (just name-changed), original built-in component from the tutorial as an extension(AltCamera) ! So I assume that my ant builder is maybe doing something wrong.

Also, when I try to compile on the online ai2 platform, I will get a compiler error if that extension component is part of the non-visible-components (design view). The component does not have to be used to cause the compiler error, just dragging and placing it in the designer view is sufficient to let the error occur during compiling.

What is going wrong during the extension building process?

App Inventor is unable to compile this project. 
The compiler error output was 
________Preparing application icon
________Creating animation xml
________Determining BR names and actions
________Generating manifest file
________Attaching native libraries
________Attaching component assets
________Compiling source files
(compiling appinventor/ai_armai123mai/Test1/Screen1.yail to appinventor.ai_armai123mai.Test1.Screen1)
(compiling /tmp/runtime8872982264086122834.scm to com.google.youngandroid.runtime)
Kawa compile time: 1.83 seconds
________Invoking DX
YAIL compiler - DX execution failed.

By the way, all elements are shown properly in the blocks view.

Arne Mailand

unread,
Oct 3, 2016, 9:35:42 AM10/3/16
to App Inventor Open Source Development
I attached the compiled .aix file here.
com.google.appinventor.components.runtime.AltCamera.aix

Arne Mailand

unread,
Oct 3, 2016, 10:02:48 AM10/3/16
to App Inventor Open Source Development
By the way, I don't have git or phantomjs installed. Could this be related to the errors?

Arne Mailand

unread,
Oct 3, 2016, 11:42:09 AM10/3/16
to App Inventor Open Source Development
Also, I noticed that all built .aix files have the file size of 1075kb +-1kb. That seems a bit large to me. All extensions i got so farm from other developers had less than 100kb.

I am using Apache Ant 1.9.7

Java 1.8.0_101

Arne Mailand

unread,
Oct 3, 2016, 2:08:59 PM10/3/16
to App Inventor Open Source Development
Allright, I think I got it:

I changed the package name. This reduced the .aix file size from 1075kb to 4kb and app compiling seems to work now. Also, I don't get any runtime errors in the blocks view from just placing the component anymore (I should have better realized the first sentence in Chapter 4... ;)).

Tadaaa
Reply all
Reply to author
Forward
0 new messages