1

I want to convert my jar to dex: dx --dex --output=file.dex file.jar. In file.jar exists folder cnf/ which contains configuration files needed for my classes. But there is no folder cnf/ in resulting dex-file.

How to keep all files and folders in dex-file while converting?

Michael Galuza
  • 386
  • 6
  • 16

2 Answers2

2

This isn't possible, there's no way to store arbitrary files in a dex file. The closest you can get would be to create an "android" jar file, with the dex file as a classes.dex entry, along with anything else you want to put in it, such as the cnf folder.

JesusFreke
  • 19,784
  • 5
  • 65
  • 68
1

You can put cnf/ in APK file. APK is a ZIP archive. After unpacking on device cnf/ folder would be in classpath so it should work the same as inside JAR.

  1. After a build remove MANIFEST.MF and certificates from META-INF folder inside APK;

    zip -d file.apk "META-INF/*"
    
  2. Add your resources (cnf/) to APK;

    aapt add -v file.apk cnf/*
    
  3. Re-sign APK. Here's an example using the default debug key:

    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore file.apk androiddebugkey
    
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259