Duplicate class error when attetmpting to run application on device

Hi,
I am trying to run a program on an android device that is testing FTP client code (FTP client is from apache commons net). When i run the program i get a “Duplicate Classes Failed” error and a whole host of gradle errors related to Duplicate classes which i have never seen before (code and some of the error output are shown below).

I found some information related to fixing duplicate classes errors which is related to removing duplicate stuff from .jar files which i found a bit confusing.

Does anybody have any ideas on this.

Any help is much appreciated.

Cheers.

FTP code:

//import ketai.ui.*;
import java.io.IOException;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;

color backgroundcolor = color(0, 0, 0);

void setup()
{
  fullScreen();
  orientation(LANDSCAPE);
  textSize(20*displayDensity);
  textAlign(CENTER);
  
  uploadFile();
}

void draw()
{
  background(backgroundcolor);

  //drawUI();
  text("Nothing to see here", width/2, height/2);
}


void showServerReply(FTPClient ftpClient) {
  String[] replies = ftpClient.getReplyStrings();
  if (replies != null && replies.length > 0) {
    for (String aReply : replies) {
      println("SERVER: " + aReply);
    }
  }
}

void uploadFile() {
  println("attempting to connect to the server.....");
  String server = "ftp.niwa.co.nz";
  int port = 21;
  String user = "anonymous";
  String pass = "r.yates@niwa.co.nz";
  FTPClient ftpClient = new FTPClient();
  try {
    ftpClient.connect(server, port);
    showServerReply(ftpClient);
    int replyCode = ftpClient.getReplyCode();
    if (!FTPReply.isPositiveCompletion(replyCode)) {
      println("Operation failed. Server reply code: " + replyCode);
      return;
    }
    boolean success = ftpClient.login(user, pass);
    showServerReply(ftpClient);
    if (!success) {
      println("Could not login to the server");
      return;
    } 
    else {println("LOGGED ON TO SERVER");}
    
    println("Getting file");
    
   
  } catch (IOException ex) {
      println("Error1");
      ex.printStackTrace();
  }
  
  print("Slight pause before closing down");
  for (int x=0; x<=4; x++) {println("."); delay(1000);}
  
  try {
    if (ftpClient.isConnected()) {
      ftpClient.logout();
      ftpClient.disconnect();
    } 
  } catch (IOException ex) {
    println("Error2");
    ex.printStackTrace();
  }
  
  if (!ftpClient.isConnected()) {
    println("logged out and disconnected");
  }
  
  
}

error output :

Duplicate class org.ajwcc.pduUtils.gsm3040.SmsDeliveryPdu found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.gsm3040.SmsStatusReportPdu found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.gsm3040.SmsSubmitPdu found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.gsm3040.ie.ConcatInformationElement found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.gsm3040.ie.InformationElement found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.gsm3040.ie.InformationElementFactory found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.gsm3040.ie.PortInformationElement found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.MessageGeneratorTester found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.MultipartGeneratorTester found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.ParserGeneratorTester found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.ParserTester found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.TestFileReader found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.AbstractTester found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.AbstractTester$CallNotification found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.AbstractTester$InboundNotification found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.AbstractTester$OutboundNotification found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.ClickatellSendMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.ClickatellSendMessage$OutboundNotification found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.ClickatellSendPortMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.ClickatellSendPortMessage$OutboundNotification found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.ReadMessages found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendBinaryConcatMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendBinaryMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendPortedBinaryMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendPortedConcatBinaryMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendPortedConcatTextMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendPortedTextMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendTextConcatMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendTextMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendWapSIConcatMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.test.integration.SendWapSIMessage found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.wappush.WapPushUtils found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.wappush.WapSiPdu found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     Duplicate class org.ajwcc.pduUtils.wappush.WapSiUserDataGenerator found in modules jetified-pduutils (pduutils.jar) and jetified-smslib-3.5.1 (smslib-3.5.1.jar)
     
     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
16 actionable tasks: 16 executed

Hi,
And thanks for the replies.

I found the problem:
The error output indicated that there were duplicate classes in the modules pduutils.jar and
smslib-3.5.1.jar. I did a search for these two files and found them as part of the ‘ShortMessage’ Library. I uninstalled this library (not sure why i installed it in the first place) pushed the program to the phone and it successfully accessed an FTP server and then disconnected it. So far so good.

Cheers.

1 Like