How do you add classpath on IntelliJ IDEA

hello
i am a newbee and i want your help, i want to configure my intellij FOR editing java extensions...
my question is how i can do for this kind of imports :

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.Notifier;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.annotations.UsesLibraries;
import com.google.appinventor.components.annotations.UsesPermissions;

where i can download this libs ? and how i import them

thank you

Please let us know which build tool you're using to build extension? So we might help you better.

no need to download any external lib
just put this imports in your .java file after packj
eg..
packaj com.myapp

import.....
import...........

Tip

you can also use 1 import to do this
import com.google.appinventor.components.*;

i am using intelliJ IDEA IDE .
can this intelliJ build extensions .aix ? any idea ? netbeans ?
wht is the best ide to do this ?

thx

I'm not talking about the IDE, it's about the build tool. Are you using the App Inventor Open Source program to build aix or the Extension Template Repository? Let me know it so I can help you more.

ah sorry ... yes i am using the App Inventor Open Source. (ant extensions).
but i i am editing the java file with intellij and i want that intellij do the autocompletion for all methods for this imports .

1 Like

Ok, I'll share a way for that. And I'll recommend you to use the Extension Template Repository to build extensions with ease.

Or use RUSH, then most imports are automatically picked up as you add a class in your code when using IntelliJ.

yes can i tell me how ?
intelliJ and rush

Watch this video to learn how to install Rush.

Or just follow the guide in the link I posted (if using Linux etc.)

yes but Extension Template Repository not working with me (ant) i have this error :

Blockquote
javac:
[javac] Compiling 471 source files to D:\App inventor Ext creat\my-extension\build\classes
[javac] D:\App inventor Ext creat\my-extension\src\com\google\appinventor\components\runtime\util\OlsTrendLine.java:13: error: package org.apache.commons.math3.linear does not exist
[javac] import org.apache.commons.math3.linear.MatrixUtils;
[javac] ^
[javac] D:\App inventor Ext creat\my-extension\src\com\google\appinventor\components\runtime\util\OlsTrendLine.java:14: error: package org.apache.commons.math3.linear does not exist
[javac] import org.apache.commons.math3.linear.RealMatrix;
[javac] ^
[javac] D:\App inventor Ext creat\my-extension\src\com\google\appinventor\components\runtime\util\OlsTrendLine.java:15: error: package org.apache.commons.math3.stat.regression does not exist
[javac] import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression;
[javac] ^
[javac] warning: Supported source version 'RELEASE_7' from annotation processor 'com.google.appinventor.components.scripts.ComponentDescriptorGenerator' less than -source '1.8'
[javac] error: cannot access CurlExtension
[javac] bad source file: D:\App inventor Ext creat\my-extension\src\com\google\appinventor\components\runtime\CurlExtension.java
[javac] file does not contain class com.google.appinventor.components.runtime.CurlExtension
[javac] Please remove or make sure it appears in the correct subdirectory of the sourcepath.
[javac] warning: Supported source version 'RELEASE_7' from annotation processor 'com.google.appinventor.components.scripts.ComponentListGenerator' less than -source '1.8'
[javac]
[javac]
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.EnumConstantNotPresentException: com.google.appinventor.components.annotations.PropertyCategory.GENERAL
[javac] at sun.reflect.annotation.EnumConstantNotPresentExceptionProxy.generateException(EnumConstantNotPresentExceptionProxy.java:46)
[javac] at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:84)
[javac] at com.sun.proxy.$Proxy6.category(Unknown Source)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.executableElementToProperty(ComponentProcessor.java:1926)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.processProperties(ComponentProcessor.java:2540)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.processComponent(ComponentProcessor.java:1869)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.process(ComponentProcessor.java:1551)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
[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:1035)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
[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:1352)
[javac] at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1092)
[javac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
[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:1401)
[javac] at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
[javac] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[javac] at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
[javac] at org.apache.tools.ant.Main.runBuild(Main.java:818)
[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)

BUILD FAILED
D:\App inventor Ext creat\my-extension\build.xml:49: Compile failed; see the compiler error output for details.

Total time: 1 second

Blockquote

Just place extension related java files only inside the src folder.

yes that's what i do always

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="${PROJECT_DIR}/src/" />
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/acra-4.4.0.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/android.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/AndroidRuntime.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/androidsvg.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/annotation.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/AnnotationProcessors.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/appcompat.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/asynclayoutinflater.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/Barcode.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/cardview.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/collection.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/commons-math3.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/commons-pool.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/CommonVersion.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/constraintlayout-solver.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/constraintlayout.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/coordinatorlayout.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/core-common.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/core-runtime.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/core.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/cursoradapter.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/customview.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/documentfile.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/drawerlayout.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/firebase.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/fragment.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/fusiontables.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-api-client-android2-beta.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-api-client-beta.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-api-client-jackson2.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-api-client.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-http-client-android2-beta.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-http-client-android3-beta.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-http-client-beta.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-http-client-jackson2.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-http-client.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-oauth-client-beta.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-oauth-client-java6.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-oauth-client-jetty.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/google-oauth-client.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/googlesheets.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/grpc-context.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/gson-2.1.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/gson-2.9.0.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/guava-14.0.1.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/guava.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/http-legacy.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/httpmime.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/interpolator.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/jackson-core.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/jedis.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/jetty-util.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/jetty.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/json.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/jts.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/kawa.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/legacy-support-core-ui.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/legacy-support-core-utils.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/lifecycle-common.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/lifecycle-livedata-core.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/lifecycle-livedata.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/lifecycle-runtime.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/lifecycle-viewmodel.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/loader.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/localbroadcastmanager.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/mpandroidchart.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/opencensus-contrib-http-util.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/opencensus.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/osmdroid.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/physicaloid.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/print.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/protobuf-java-3.0.0.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/QRGenerator.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/recyclerview.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/slidingpanelayout.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/swiperefreshlayout.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/twitter4j.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/twitter4jmedia.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/vectordrawable-animated.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/vectordrawable.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/versionedparcelable.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/viewpager.jar"/>
    <classpathentry kind="lib" path="${PROJECT_DIR}/lib/appinventor/webrtc.jar"/>
</classpath>

Copy the xml and create a .classpath file into your project root directory and paste the copied xml inside the file. If you want to add new dependencies so just make a new line at the end and set the path of the new jar.

For example:

<classpathentry kind="lib" path="${PROJECT_DIR}/lib/deps/jar-name.jar"/>

So the IntelliJ IDEA will suggest auto completion.

Hope it helps?

1 Like

thank you @ JEWEL

can you explain to me more detailed..
i said i use IntelliJ not eclipse

This xml should work on IntelliJ IDEA. Please try.
I'm also using it for developing extensions with the Extension Template Repository.

please please help me...... i can't do this ... ho i do it ..

ye this is pretty confusing