1. 建立一個一般的測試類,用于導出JAR。package com.example.dextest; import android.app.Activity; import android.view.Gravity; import android.widget.FrameLayout; import android.widget.TextView; public class Test1 { public void test(Activity ac) { TextView tv = new TextView(ac); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.topMargin = 0; params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; tv.setText("Test1 textview!!!!"); ac.addContentView(tv, params); } }
2.使用SDK自帶的工具dx.bat将JAR轉換成DEX。![]()
android APK加強篇-1. 動态加載的Dex檔案的生成 這樣用于動态加載的dex檔案就生成成功可以使用DexClassLoader進行加載了。dx.bat --dex --output=F:/test.dex F:/test.jar