{"id":19732499,"url":"https://github.com/mmin18/dex65536","last_synced_at":"2025-10-04T14:02:08.504Z","repository":{"id":14814895,"uuid":"17537369","full_name":"mmin18/Dex65536","owner":"mmin18","description":"Solve the issue with dalvik compiler limitation on 65536 methods (Unable to execute dex: method ID not in [0, 0xffff]: 65536)","archived":false,"fork":false,"pushed_at":"2024-01-04T09:44:28.000Z","size":3001,"stargazers_count":352,"open_issues_count":15,"forks_count":121,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-03-29T19:08:15.324Z","etag":null,"topics":["android","apk","dalvik","dex"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmin18.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-08T07:24:26.000Z","updated_at":"2025-02-21T15:47:11.000Z","dependencies_parsed_at":"2025-02-18T02:00:38.004Z","dependency_job_id":"2915024f-1db7-4b85-b01d-0ef1d742fd8c","html_url":"https://github.com/mmin18/Dex65536","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmin18%2FDex65536","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmin18%2FDex65536/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmin18%2FDex65536/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmin18%2FDex65536/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmin18","download_url":"https://codeload.github.com/mmin18/Dex65536/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399877,"owners_count":20932876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","apk","dalvik","dex"],"created_at":"2024-11-12T00:26:40.440Z","updated_at":"2025-10-04T14:02:03.464Z","avatar_url":"https://github.com/mmin18.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Dex 65536\n========\n\n\n\u003e Unable to execute dex: method ID not in [0, 0xffff]: 65536) \n\nWhen you get this message, normally it is not because your project itself has too much methods, but you are importing some big .jar libraries.\n\nSo the easy solution is to pack your .jar libraries in libs/ folder into a secondary .dex file and load that file before your application starts.\n\n## How to run sample project\n\n/Dex65536 is the main project, depends on a android library project /Lib.\n\nYou can write code in eclipse, but you need to build/run in ant.\n\n\tandroid update project -p ./Dex65536\n\tandroid update project -p ./Lib\n\tcd Dex65536\n\tant clean debug install run\n\n(Make sure your android_sdk/tools is in the $PATH)\n\n## How to make it work on your own project\n\n### Step1: build tools\n\n\tDex65536/custom_rules.xml\n\tDex65536/pathtool.jar\n\nCopy these two files in your android project, and execute the following command to generate build.xml.\n\n\tandroid update project -p .\n\n(Make sure your android_sdk/tools is in the $PATH)\n\n### Step2: add some code\n\nYou need to add some code to load the secondary .dex file before your application starts.\n\n\tpublic class App extends Application {\n\t\n\t\t@Override\n\t\tpublic void onCreate() {\n\t\t\tsuper.onCreate();\n\t\t\tdexTool();\n\t\t}\n\t\n\t\t/**\n\t\t * Copy the following code and call dexTool() after super.onCreate() in\n\t\t * Application.onCreate()\n\t\t * \u003cp\u003e\n\t\t * This method hacks the default PathClassLoader and load the secondary dex\n\t\t * file as it's parent.\n\t\t */\n\t\t@SuppressLint(\"NewApi\")\n\t\tprivate void dexTool() {\n\t\n\t\t\tFile dexDir = new File(getFilesDir(), \"dlibs\");\n\t\t\tdexDir.mkdir();\n\t\t\tFile dexFile = new File(dexDir, \"libs.apk\");\n\t\t\tFile dexOpt = new File(dexDir, \"opt\");\n\t\t\tdexOpt.mkdir();\n\t\t\ttry {\n\t\t\t\tInputStream ins = getAssets().open(\"libs.apk\");\n\t\t\t\tif (dexFile.length() != ins.available()) {\n\t\t\t\t\tFileOutputStream fos = new FileOutputStream(dexFile);\n\t\t\t\t\tbyte[] buf = new byte[4096];\n\t\t\t\t\tint l;\n\t\t\t\t\twhile ((l = ins.read(buf)) != -1) {\n\t\t\t\t\t\tfos.write(buf, 0, l);\n\t\t\t\t\t}\n\t\t\t\t\tfos.close();\n\t\t\t\t}\n\t\t\t\tins.close();\n\t\t\t} catch (Exception e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\n\t\t\tClassLoader cl = getClassLoader();\n\t\t\tApplicationInfo ai = getApplicationInfo();\n\t\t\tString nativeLibraryDir = null;\n\t\t\tif (Build.VERSION.SDK_INT \u003e 8) {\n\t\t\t\tnativeLibraryDir = ai.nativeLibraryDir;\n\t\t\t} else {\n\t\t\t\tnativeLibraryDir = \"/data/data/\" + ai.packageName + \"/lib/\";\n\t\t\t}\n\t\t\tDexClassLoader dcl = new DexClassLoader(dexFile.getAbsolutePath(),\n\t\t\t\t\tdexOpt.getAbsolutePath(), nativeLibraryDir, cl.getParent());\n\t\n\t\t\ttry {\n\t\t\t\tField f = ClassLoader.class.getDeclaredField(\"parent\");\n\t\t\t\tf.setAccessible(true);\n\t\t\t\tf.set(cl, dcl);\n\t\t\t} catch (Exception e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t}\n\t\n\t}\n\nIf you don't have a custom Application class, register one in your AndroidManifest.xml like:\n\n    \u003capplication\n        android:name=\"com.github.mmin18.dex65536.App\"\n        android:icon=\"@drawable/ic_launcher\"\n        android:label=\"@string/app_name\" \u003e\n\nOthersise you just need to copy dexTool() method into your own custom Application and call it after super.onCreate().\n\n### Step3: ant build and run\n\nMake sure you have ant installed.\n\n\tcd /YourProject\n\tant clean debug install run\n\nYour project should be compile and runnable. Good luck.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmin18%2Fdex65536","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmin18%2Fdex65536","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmin18%2Fdex65536/lists"}