Search code examples
codenameoneproguard

Codename One - ProGuard - Duplicate jar entry


I have an existing Codename One application and wish to add some data from a GTFS real-time data feed. All is well, until I add the following statements:

    try {
        FeedMessage.parseDelimitedFrom(byteArrayInputStream);
    } catch (IOException ex) {
        Log.p("transitSelected,ex," + ex);
    }

After adding those statements, the local build fails with:

ProGuard, version 7.2.0-beta2
Error: Can't write [D:\data\Netbeans\HHT\common\target\compliance-check.jar] (Can't read [C:\Users\Still\.m2\repository\com\google\protobuf\protobuf-javalite\3.24.2\protobuf-javalite-3.24.2.jar(;;;;;;;;!META-INF\**)] (Duplicate jar entry [com/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream.class]))
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate jar entry [META-INF/MANIFEST.MF])Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate jar entry [META-INF/MANIFEST.MF])

I have tried a number of things e.g. setting the Codename One build hint android.enableProguard=false and nothing has worked. EXCEPT, the tip on this page https://groups.google.com/g/codenameone-discussions/c/hcIYL8-WXxo to remove the compliance-check line from the project's pom.xml.

Is there another possible solution?

The dependencies in the project's pom.xml are:

<dependencies>
    <dependency>
        <groupId>com.codenameone</groupId>
        <artifactId>codenameone-core</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <artifactId>myapplication-CN1CircleProgress</artifactId>
        <groupId>com.stylsy.app</groupId>
        <version>1.0-SNAPSHOT</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>com.codenameone</groupId>
        <artifactId>googlemaps-common</artifactId>
        <version>1.1.2</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>3.24.2</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-javalite</artifactId>
        <version>3.24.2</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java-util</artifactId>
        <version>3.24.2</version>
    </dependency>
</dependencies>

Solution

  • You can't add protobuf to the common dependencies and expect this to work properly. You can write this code in the Android project directory but not in the common directory as it won't translate to iOS. For the iOS version you would need to write your own native code.

    You would need to wrap the logic with a native interfaces and invoke it on the specific platforms.