Extension Building error

I have made an extension and while compiling it, I am getting this error :point_down:

Cannot convert Java type ''java.lang.String[]' to Yail type

how can I fix this?

Here's the full code :point_down:
I don't know if it works or not but I fell that it does not have any error

package com.blogspot.videotoaudiomanni;

import android.app.Activity;

import android.content.Context;

import com.google.appinventor.components.annotations.*;

import com.google.appinventor.components.common.ComponentCategory;

import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;

import com.google.appinventor.components.runtime.ComponentContainer;

import com.google.appinventor.components.runtime.EventDispatcher;

import java.io.File;

import it.sauronsoftware.jave.AudioAttributes;

import it.sauronsoftware.jave.Encoder;

import it.sauronsoftware.jave.EncoderException;

import it.sauronsoftware.jave.EncodingAttributes;

import it.sauronsoftware.jave.FFMPEGLocator;

import it.sauronsoftware.jave.InputFormatException;

@DesignerComponent(

        version = 1,

        description = "Simple Extension for conveting video to Audio by Manni",

        category = ComponentCategory.EXTENSION,

        nonVisible = true,

        iconName = "_")

@SimpleObject(external = true)

//Libraries

@UsesLibraries(libraries = "jave-1.0.2.jar")

//Permissions

@UsesPermissions(permissionNames = "")

public class VideoToAudio extends AndroidNonvisibleComponent {

    //Activity and Context

    private Context context;

    private Activity activity;

    public VideoToAudio(ComponentContainer container){

        super(container.$form());

        this.activity = container.$context();

        this.context = container.$context();

    }

    @SimpleFunction(description = "Initialize")

    public static void ConvertToAudio(String video){

        

        File Audio =new File("/storage/emulated/0/Download/VideoTranslator/ExtractedAudio");

        AudioAttributes audio = new AudioAttributes();

        audio.setCodec("libmp3lame");

        audio.setBitRate(new Integer(128000));

        audio.setChannels(new Integer(2));

        audio.setSamplingRate(new Integer(44100));

        EncodingAttributes attrs = new EncodingAttributes();

        attrs.setFormat("wav");

        attrs.setAudioAttributes(audio);

        Encoder encoder = new Encoder();

        encoder.encode(video, target, attrs);

        JFileChooser fileChooser = new JFileChooser();

        int response = fileChooser.showOpenDialog(null);}

    

    @SimpleFunction(description = "Convert video to audio")

    public static void main(String[] args){

        File video=new File(fileChooser.getSelectedFile().getAbsolutePath());

        VideoToAudio.convertToAudio(video);

        

   }

}

Here's the error log package :point_down:

Started Compiling Project VideoToAudio
Buildfile: /compiler/android/build.xml

javac:
[mkdir] Created dir: /compiler/android/build/DMxPa/classes
[javac] Compiling 1 source file to /compiler/android/build/DMxPa/classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac]
[javac]
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.IllegalArgumentException: Cannot convert Java type 'java.lang.String' to Yail type
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.javaTypeToYailType(ComponentProcessor.java:2056)
[javac] at com.google.appinventor.components.scripts.ComponentDescriptorGenerator.outputParameters(ComponentDescriptorGenerator.java:367)
[javac] at com.google.appinventor.components.scripts.ComponentDescriptorGenerator.outputBlockMethod(ComponentDescriptorGenerator.java:346)
[javac] at com.google.appinventor.components.scripts.ComponentDescriptorGenerator.outputComponent(ComponentDescriptorGenerator.java:157)
[javac] at com.google.appinventor.components.scripts.ComponentDescriptorGenerator.outputResults(ComponentDescriptorGenerator.java:385)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.process(ComponentProcessor.java:1091)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:802)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:713)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1043)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1184)
[javac] at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
[javac] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:523)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:381)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:370)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:361)
[javac] at com.sun.tools.javac.Main.compile(Main.java:56)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[javac] at java.lang.reflect.Method.invoke(Method.java:498)
[javac] at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:57)
[javac] at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1388)
[javac] at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1117)
[javac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[javac] at java.lang.reflect.Method.invoke(Method.java:498)
[javac] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
[javac] at org.apache.tools.ant.Task.perform(Task.java:350)
[javac] at org.apache.tools.ant.Target.execute(Target.java:449)
[javac] at org.apache.tools.ant.Target.performTasks(Target.java:470)
[javac] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1391)
[javac] at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
[javac] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[javac] at org.apache.tools.ant.Project.executeTargets(Project.java:1254)
[javac] at org.apache.tools.ant.Main.runBuild(Main.java:830)
[javac] at org.apache.tools.ant.Main.startAnt(Main.java:223)
[javac] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
[javac] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

Compile error is much longer ...

2 Likes

Show your code and full error

1 Like

Your extension's methods cannot return or accept any types except the ones listed in 1e. Types
https://docs.google.com/document/d/1xk9dMfczvjbbwD-wMsr-ffqkTlE3ga0ocCE1KOb2wvw/pub#h.tagpg4ic9t5m

1 Like

You are doing something like

public void Something(File something) {
. . . . . . . . . . . . . . . . .
}

If you are doing something like this then this is wrong way correct way is

public void Something(String something) {
File file = new File(something);
}

1 Like

I tried that but it still throws the same error :slightly_frowning_face:

what is the substitute for

public static void ConvertToAudio(String video)

I edited the question......You can see it now

I edited the question.......You can see the full code and full error now.

There's a lot of error and that is not public static void that's only public void and your import are wrong learn Java.

Is this your first extension?

1 Like

I think this is his first extension

That's why he is not aware of differences between Java and Android.
Some Java libraries were never meant to be made for Android.
And if this his first extension then it means he has potential but he is taking it in wrong direction. (Even though I am sure it's Ctrl + C and Ctrl + V)

1 Like

Yes, If he want to learn How to create extension then he dm me I teach him java

There is two java one is java and another is Android java so beginner got trouble in them.

Problem is here:

What do you want to pass to the extension in this method? List or string?
AppInventor does not support a String array. Either String or YailList. Then you need to convert the input data to what you need.

There is so many error

Hmm....I thought so. But I have to make an urgent extension for converting video to audio.

I can't wait for learning java

Yes. Maybe that's why it has got so many errorsπŸ˜”

I know the basics of extension development such as required annotations....but have no experience of java.

And currently I am in urgent need of an extension to convert video to audio