java.lang.NoClassDefFoundError: Failed resolution of: Lcs/min2phase/Search; what does it means

i compiled my extension but java.lang.NoClassDefFoundError: Failed resolution of: Lcs/min2phase/Search; is the error i got in app inventor(companion,apk) @ewpatton can you please say where i gone wrong

That means some classes are not compiled with the extension in order to use it.

ok how to compile i used another java file as import that file is from github

Try using a jar file instead. I don't have experience directly using java files.

is there a way to convert java to jar

becaz the jar is not provided in git/mvnrespository

Yes. Just compile it with command prompt.

u mean which command

u mean javac cf and jar command

Make sure that the your extension's and the java file's package should be same.

1 Like

no in my extension code i used
import cs.min2phase.*;
and in package file
package cs.min2phase;i know it is right but i have doubt on java.lang.NoClassDefFoundError: Failed resolution of: Lcs/min2phase/Search; what does it means
as said by @Kumaraswamy

yes i found how to convert all my 4 codes to 4 class file as said


also in cmd
i put this command

javac *.java

it created 4 class file so is it enough that now i got class file or should i need jar file


using the

jar cf JarExample.jar *.class

i can also convert to jar but when i converted added to build xml and put @uses library but in the compiling it says the command is not defined(i mean there is no such command it says)

i have another thought those 4 java package file are by me instead of importing can i use them in my code i mean can i copy that code and paste it in my extension code what change i need

Can you show the annotation?

what do u mean by

you mean code of build xml

annoations like @SimpleFunction, @Nullable @ColorInt like this

1 Like

@Techno_Vedang is correct. This also happens with me . you have to move your imported classes in same folder (where is your extension class)

2 Likes

The extension build system only copies class files in the same package (plus any subpackages) of the extension. Because you're using Java files in a separate package, they won't be picked up by the extension system. The easiest thing to do would be to compile the dependency Java files to get the class files and put them into a JAR file (using the zip or jar utilities) and then place that in lib and make use of the library functionality built into the extension system since it knows how to pick up JAR libraries via the @UsesLibraries annotation.

3 Likes

@ewpatton really the same i did
now it compiled and in companion it worked :star_struck:

but

when i compile the apk

app inventor error log

kodular error log

Kodular is unable to compile this project.
The compiler error output was
________Preparing application icon
________Creating animation xml
________Creating fragment xml
________Creating listview xml in res/layout/..
________Creating listview xml in res/layout-v21/..
________Creating xml in res/drawable/..
________Creating splash png in res/drawable/..
________Creating colors xml
________Creating styles xml
________Creating drawables xml v21
________Checking for firebase
________Creating provider_path xml
________Creating network_security_config xml
________Generating adaptive icon file
________Generating round adaptive icon file
________Generating adaptive icon background file
________Generating manifest file
________Attaching native libraries
________Attaching Android Archive (AAR) libraries
________Attaching component assets
________Invoking AAPT
AAPT time: 1.23 seconds
________Compiling source files
(compiling io/kodular/electrobot999/nexcube/Screen1.yail to io.kodular.electrobot999.nexcube.Screen1)
(compiling /tmp/runtime8397583071109955809.scm to com.google.youngandroid.runtime)
Kawa compile time: 4.064 seconds
________Invoking DX
DX time: 4.319 seconds
________Invoking ApkBuilder
com.android.sdklib.build.ApkCreationException: Failed to add /tmp/1613547908514_0.8815810980618682-0/youngandroidproject/../build/tmp/classes3.dex
YAIL compiler - ApkBuilder failed.
.

:sob: