1.首先需要把assets中的test.dex复制到应用的files空间下。
string copyDexToData(JNIEnv* env, jobject asset, string dexName, string dataPath) { AAssetManager* asMg = AAssetManager_fromJava(env, asset); AAsset* as = AAssetManager_open(asMg, dexName.c_str(), AASSET_MODE_UNKNOWN); if (as == NULL) { LOGE("%s not found in assets!",dexName.c_str()); return ""; } string strDexPath = dataPath + "/files/" + dexName; int len = AAsset_getLength(as); int file = open(strDexPath.c_str(), O_WRONLY | O_CREAT, 0755); if (file < 0) { AAsset_close(as); LOGE("Open %s File Error!",strDexPath.c_str()); return ""; } char* buf = new char[1024]; while (len > 0) { memset(buf, 0, 1024); int n = AAsset_read(as, buf, 1024); if (n < 0) break; write(file, buf, n); len -= n; } delete[] buf; AAsset_close(as); cl