java.lang.NoClassDefFoundError: Failed resolution of: Lio/github/furstenheim/copydown

Today I tried to make an extension with external libraries. I imported them into appinventor-sources, I wrote the code from the docs and it all compiled, but in appinventor I get the error:

java.lang.NoClassDefFoundError: Failed resolution of: Lio/github/furstenheim/copydown

I also tried it with web-based IDEs like Niotron, it also didn't work but it compiled successfully, I imported the dependencies also.

I got the JAR files from MVNrepository...

Here is my code:

package com.puterblade.mdtools;

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 org.jsoup.*;
import io.github.furstenheim.CopyDown;

//Libraries
@UsesLibraries(libraries = "copy_down-1.1.jar" + "jsoup-1.15.2.jar")

@DesignerComponent(
        version = 1,
        description = "Tools for operating with Markdown Text. Currently supports converting HTML to markdown, and markdown to HTML.",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,
        iconName = "")

@SimpleObject(external = true)

//Permissions
@UsesPermissions(permissionNames = "")

public class MarkdownTools extends AndroidNonvisibleComponent {

    //Activity and Context
    private Context context;
    private Activity activity;

    public MarkdownTools(ComponentContainer container){
        super(container.$form());
        this.activity = container.$context();
        this.context = container.$context();
    }

    @SimpleFunction(description = "Replaces text")
    public String Html2Markdown(String html){
        CopyDown converter = new CopyDown();
        String markdown = converter.convert(html);
        return markdown;
    }

    @SimpleEvent(description = "Test Event Generated by Niotron")
    public void TestEvent(){
        EventDispatcher.dispatchEvent(this, "TestEvent");
    }
}

It would be great if I can get this compiled, thank you...

Did you add the additional lines to build.xml?

Yes

<copy toFile="${public.deps.dir}/jsoup-1.15.2.jar" file="${lib.dir}/copy_down-1.1.jar" />
<copy toFile="${public.deps.dir}/copy_down-1.1.jar" file="${lib.dir}/jsoup-1.15.2.jar" />

I copied the JAR files to the libs folder in appinventor-sources\appinventor

This is wrong, use commas.

@UsesLibraries(libraries = "copy_down-1.1.jar, " + "jsoup-1.15.2.jar")

Now while compiling this is what showed up:

BUILD FAILED
C:\Users\Ayush\appinventor-sources\appinventor\build.xml:73: The following error occurred while executing this line:
C:\Users\Ayush\appinventor-sources\appinventor\components\build.xml:474: The following error occurred while executing this line:
C:\Users\Ayush\appinventor-sources\appinventor\components\build.xml:487: Java returned: 1

Total time: 1 minute 58 seconds

It would be good if you show us all the logs, also show us lines 474, 487.

Compilation Log:
New Text Document.txt (24.0 KB)

build.xml:
Line 474: <foreach target="dexExtension" param="extension">
Line 487: failonerror="true">

Full build.xml file:
build.xml.txt (28.2 KB)

Relevant part of logs

dexExtension:
     [java] Picked up _JAVA_OPTIONS: -Xmx1024m
     [java] 
     [java] PARSE ERROR:
     [java] InvokeDynamic not supported
     [java] ...while preparsing cst 0008 at offset 00000027
     [java] ...while parsing io/github/furstenheim/CopyDown$Rules.class
     [java] 1 error; aborting

BUILD FAILED
C:\Users\Ayush\appinventor-sources\appinventor\build.xml:73: The following error occurred while executing this line:
C:\Users\Ayush\appinventor-sources\appinventor\components\build.xml:474: The following error occurred while executing this line:
C:\Users\Ayush\appinventor-sources\appinventor\components\build.xml:487: Java returned: 1

Total time: 1 minute 58 seconds

Recently there was an update to extension mechanism supporting Java 11.

If you havent updated the repo in a while, it's probably because your library uses Java 8+ features.
Or if you have cloned the repo recently, error is because it uses Java 11+ features.

The error is also in Niotron IDE (maybe I should ask that part in Niotron community)

The library was made 2 years ago.
How do I use the old appinventor-sources?

So now what do I do?
What to configure for Java 11 libraries?
If I am unable to compile it again after some steps, I need it to be compiled by someone else who has everything configured properly (for free only).

Show us this updated line
Taifun

I updated it with a comma as @Kumaraswamy mentioned a few posts ago ...

@UsesLibraries(libraries = "copy_down-1.1.jar," + "jsoup-1.15.2.jar")

Correct would be

@UsesLibraries(libraries = "copy_down-1.1.jar, jsoup-1.15.2.jar")

without + in between

Taifun

I updated the line, and it didn't help me compile, same error.
Now I want to know what should I do to fix the compiler error? Maybe because this library is made with Java 11 could be the reason it doesn't compile?
What do I need to do? I am a beginner and have faced this issue for the first time...
Thank you

You'll have to desugar library first.
Use Rush for desugaring and then import wherever you want to use it.
It may work.

I was dumb for the fact I didn't use Rush before, I compiler and created my extension with Rush and it worked, thank you all though...

I have published the final extension to the community:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.