本文整理汇总了Java中dalvik.system.DexFile.loadDex方法的典型用法代码示例。如果您正苦于以下问题:Java DexFile.loadDex方法的具体用法?Java DexFile.loadDex怎么用?Java DexFile.loadDex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dalvik.system.DexFile
的用法示例。
在下文中一共展示了DexFile.loadDex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadDex
import dalvik.system.DexFile; //导入方法依赖的package包/类
static public DexFile loadDex(Context context, String sourcePathName, String outputPathName,
int flags) throws Exception {
if(Build.VERSION.SDK_INT<=15) {
return DexFile.loadDex(sourcePathName,outputPathName,flags);
}else{
DexFile dexFile = DexFile.loadDex(context.getApplicationInfo().sourceDir,null,0);
try {
int cookie = (int)openDexFile.invoke(null,sourcePathName,outputPathName,flags);
mFileName.set(dexFile,sourcePathName);
mCookie.set(dexFile,cookie);
} catch (Exception e) {
throw e;
}
return dexFile;
}
}
示例2: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, IOException {
int extraSize = additionalClassPathEntries.size();
Field pathField = MultiDex.findField(loader, "path");
StringBuilder path = new StringBuilder((String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
ListIterator<File> iterator = additionalClassPathEntries.listIterator();
while (iterator.hasNext()) {
File additionalEntry = (File) iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ".dex", 0);
}
pathField.set(loader, path.toString());
MultiDex.expandFieldArray(loader, "mPaths", extraPaths);
MultiDex.expandFieldArray(loader, "mFiles", extraFiles);
MultiDex.expandFieldArray(loader, "mZips", extraZips);
MultiDex.expandFieldArray(loader, "mDexs", extraDexs);
}
示例3: loadClasses
import dalvik.system.DexFile; //导入方法依赖的package包/类
public void loadClasses() throws IOException,
ClassNotFoundException,
IllegalAccessException,
InstantiationException {
DexFile dexFile = DexFile.loadDex(this.jarpath, File.createTempFile("opt", "dex", this.context.getCacheDir()).getPath(),
0);
String className = "";
for(Enumeration<String> classNames = dexFile.entries(); classNames.hasMoreElements();
className = classNames.nextElement()) {
if(!className.isEmpty()) {
//Remove partial classes <class>$1..
if(className.contains("$"))
className = className.substring(0, className.indexOf("$"));
this.loadClass(className);
}
}
}
示例4: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, IOException {
int extraSize = additionalClassPathEntries.size();
Field pathField = MultiDex.findField(loader, "path");
StringBuilder path = new StringBuilder((String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
ListIterator<File> iterator = additionalClassPathEntries.listIterator();
while (iterator.hasNext()) {
File additionalEntry = (File) iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ShareConstants.DEX_SUFFIX, 0);
}
pathField.set(loader, path.toString());
MultiDex.expandFieldArray(loader, "mPaths", extraPaths);
MultiDex.expandFieldArray(loader, "mFiles", extraFiles);
MultiDex.expandFieldArray(loader, "mZips", extraZips);
MultiDex.expandFieldArray(loader, "mDexs", extraDexs);
}
示例5: describeDexContents
import dalvik.system.DexFile; //导入方法依赖的package包/类
public void describeDexContents() {
if(!initialized) {
Log.w(TAG, "Dexter not initialized");
return;
}
Log.d(TAG, "Describing dex file " + getDexInternalStoragePath().getPath() + ", " + getDexInternalStoragePath().getAbsolutePath());
try {
DexFile dx = DexFile.loadDex(
getDexInternalStoragePath().getAbsolutePath(),
File.createTempFile("opt", "dex", mContext.getCacheDir()).getPath(),
0);
for(Enumeration<String> classNames = dx.entries(); classNames.hasMoreElements();) {
String className = classNames.nextElement();
Log.d(TAG, "class in dex: " + className);
}
}
catch (IOException e) {
Log.w(TAG, "Error opening " + getDexInternalStoragePath().getAbsolutePath(), e);
}
}
示例6: dexJar
import dalvik.system.DexFile; //导入方法依赖的package包/类
private DexFile dexJar() throws IOException {
if (!classFile.exists()) {
classFile.createNewFile();
}
final Main.Arguments arguments = new Main.Arguments();
arguments.fileNames = new String[]{classFile.getPath()};
arguments.outName = dexFile.getPath();
arguments.jarOutput = true;
Main.run(arguments);
DexFile dex = DexFile.loadDex(dexFile.getPath(), odexOatFile.getPath(), 0);
dx.add(dex);
return dex;
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:14,代码来源:AndroidClassLoader.java
示例7: run
import dalvik.system.DexFile; //导入方法依赖的package包/类
public boolean run() {
try {
if (!SharePatchFileUtil.isLegalFile(dexFile)) {
if (callback != null) {
callback.onFailed(dexFile, optimizedDir,
new IOException("dex file " + dexFile.getAbsolutePath() + " is not exist!"));
return false;
}
}
if (callback != null) {
callback.onStart(dexFile, optimizedDir);
}
String optimizedPath = SharePatchFileUtil.optimizedPathFor(this.dexFile, this.optimizedDir);
if (useInterpretMode) {
interpretDex2Oat(dexFile.getAbsolutePath(), optimizedPath);
} else {
DexFile.loadDex(dexFile.getAbsolutePath(), optimizedPath, 0);
}
if (callback != null) {
callback.onSuccess(dexFile, optimizedDir, new File(optimizedPath));
}
} catch (final Throwable e) {
Log.e(TAG, "Failed to optimize dex: " + dexFile.getAbsolutePath(), e);
if (callback != null) {
callback.onFailed(dexFile, optimizedDir, e);
return false;
}
}
return true;
}
示例8: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader,
List<? extends File> additionalClassPathEntries)
throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, IOException {
/* The patched class loader is expected to be a descendant of
* dalvik.system.DexClassLoader. We modify its
* fields mPaths, mFiles, mZips and mDexs to append additional DEX
* file entries.
*/
int extraSize = additionalClassPathEntries.size();
Field pathField = findField(loader, "path");
StringBuilder path = new StringBuilder((String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
for (ListIterator<? extends File> iterator = additionalClassPathEntries.listIterator();
iterator.hasNext();) {
File additionalEntry = iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ".dex", 0);
}
pathField.set(loader, path.toString());
expandFieldArray(loader, "mPaths", extraPaths);
expandFieldArray(loader, "mFiles", extraFiles);
expandFieldArray(loader, "mZips", extraZips);
expandFieldArray(loader, "mDexs", extraDexs);
}
示例9: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries,
File optimizedDirectory) throws IllegalArgumentException,
IllegalAccessException, NoSuchFieldException, IOException {
int extraSize = additionalClassPathEntries.size();
Field pathField = ShareReflectUtil.findField((Object) loader, "path");
StringBuilder path = new StringBuilder((String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
ListIterator<File> iterator = additionalClassPathEntries.listIterator();
while (iterator.hasNext()) {
File additionalEntry = (File) iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, SharePatchFileUtil.optimizedPathFor
(additionalEntry, optimizedDirectory), 0);
}
pathField.set(loader, path.toString());
ShareReflectUtil.expandFieldArray(loader, "mPaths", extraPaths);
ShareReflectUtil.expandFieldArray(loader, "mFiles", extraFiles);
ShareReflectUtil.expandFieldArray(loader, "mZips", extraZips);
try {
ShareReflectUtil.expandFieldArray(loader, "mDexs", extraDexs);
} catch (Exception e) {
}
}
示例10: patchDexExtractViaDexDiff
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static boolean patchDexExtractViaDexDiff(Context context, String
patchVersionDirectory, String meta, File patchFile, boolean isUpgradePatch) {
String dir = patchVersionDirectory + "/" + ShareConstants.DEX_PATH + "/";
if (extractDexDiffInternals(context, dir, meta, patchFile, ShareTinkerInternals.isVmArt()
? 4 : 3, isUpgradePatch)) {
Tinker manager = Tinker.with(context);
File[] files = new File(dir).listFiles();
if (files != null) {
String optimizeDexDirectory = patchVersionDirectory + "/" + ShareConstants
.DEX_OPTIMIZE_PATH + "/";
File file = new File(optimizeDexDirectory);
if (!file.exists()) {
file.mkdirs();
}
int length = files.length;
int i = 0;
while (i < length) {
File file2 = files[i];
try {
String outputPathName = SharePatchFileUtil.optimizedPathFor(file2, file);
long start = System.currentTimeMillis();
DexFile.loadDex(file2.getAbsolutePath(), outputPathName, 0);
TinkerLog.i(TAG, "success dex optimize file, path: %s, use time: %d",
file2.getPath(), Long.valueOf(System.currentTimeMillis() - start));
i++;
} catch (Throwable e) {
TinkerLog.e(TAG, "dex optimize or load failed, path:" + file2.getPath(),
new Object[0]);
SharePatchFileUtil.safeDeleteFile(file2);
manager.getPatchReporter().onPatchDexOptFail(patchFile, file2,
optimizeDexDirectory, file2.getName(), e, isUpgradePatch);
return false;
}
}
}
return true;
}
TinkerLog.w(TAG, "patch recover, extractDiffInternals fail", new Object[0]);
return false;
}
示例11: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries)
throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, IOException {
/* The patched class loader is expected to be a descendant of
* dalvik.system.DexClassLoader. We modify its
* fields mPaths, mFiles, mZips and mDexs to append additional DEX
* file entries.
*/
int extraSize = additionalClassPathEntries.size();
Field pathField = findField(loader, "path");
StringBuilder path = new StringBuilder((String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
for (ListIterator<File> iterator = additionalClassPathEntries.listIterator();
iterator.hasNext();) {
File additionalEntry = iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ".dex", 0);
}
pathField.set(loader, path.toString());
expandFieldArray(loader, "mPaths", extraPaths);
expandFieldArray(loader, "mFiles", extraFiles);
expandFieldArray(loader, "mZips", extraZips);
expandFieldArray(loader, "mDexs", extraDexs);
}
示例12: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries)
throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, IOException {
/* The patched class loader is expected to be a descendant of
* dalvik.system.DexClassLoader. We modify its
* fields mPaths, mFiles, mZips and mDexs to append additional DEX
* file entries.
*/
int extraSize = additionalClassPathEntries.size();
Field pathField = RocooUtils.findField(loader, "path");
StringBuilder path = new StringBuilder((String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
for (ListIterator<File> iterator = additionalClassPathEntries.listIterator();
iterator.hasNext(); ) {
File additionalEntry = iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ".dex", 0);
}
pathField.set(loader, path.toString());
RocooUtils.expandFieldArray(loader, "mPaths", extraPaths);
RocooUtils.expandFieldArray(loader, "mFiles", extraFiles);
RocooUtils.expandFieldArray(loader, "mZips", extraZips);
RocooUtils.expandFieldArray(loader, "mDexs", extraDexs);
}
示例13: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader,
List<File> additionalClassPathEntries)
throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, IOException {
/*
* The patched class loader is expected to be a descendant of
* dalvik.system.DexClassLoader. We modify its fields mPaths,
* mFiles, mZips and mDexs to append additional DEX file entries.
*/
int extraSize = additionalClassPathEntries.size();
Field pathField = findField(loader, "path");
StringBuilder path = new StringBuilder(
(String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
for (ListIterator<File> iterator = additionalClassPathEntries
.listIterator(); iterator.hasNext();) {
File additionalEntry = iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, entryPath
+ ".dex", 0);
}
pathField.set(loader, path.toString());
expandFieldArray(loader, "mPaths", extraPaths);
expandFieldArray(loader, "mFiles", extraFiles);
expandFieldArray(loader, "mZips", extraZips);
expandFieldArray(loader, "mDexs", extraDexs);
}
示例14: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader, List<File> additionalClassPathEntries)
throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, IOException {
int extraSize = additionalClassPathEntries.size();
Field pathField = findField(loader, "path");
StringBuilder path = new StringBuilder((String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
for (ListIterator<File> iterator = additionalClassPathEntries.listIterator();
iterator.hasNext();) {
File additionalEntry = iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ".dex", 0);
}
pathField.set(loader, path.toString());
expandFieldArray(loader, "mPaths", extraPaths);
expandFieldArray(loader, "mFiles", extraFiles);
expandFieldArray(loader, "mZips", extraZips);
expandFieldArray(loader, "mDexs", extraDexs);
}
示例15: install
import dalvik.system.DexFile; //导入方法依赖的package包/类
private static void install(ClassLoader loader,
List<? extends File> additionalClassPathEntries)
throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, IOException {
/* The patched class loader is expected to be a descendant of
* dalvik.system.DexClassLoader. We modify its
* fields mPaths, mFiles, mZips and mDexs to append additional DEX
* file entries.
*/
int extraSize = additionalClassPathEntries.size();
Field pathField = findField(loader, "path");
StringBuilder path = new StringBuilder((String) pathField.get(loader));
String[] extraPaths = new String[extraSize];
File[] extraFiles = new File[extraSize];
ZipFile[] extraZips = new ZipFile[extraSize];
DexFile[] extraDexs = new DexFile[extraSize];
for (ListIterator<? extends File> iterator = additionalClassPathEntries.listIterator();
iterator.hasNext();) {
File additionalEntry = iterator.next();
String entryPath = additionalEntry.getAbsolutePath();
path.append(':').append(entryPath);
int index = iterator.previousIndex();
extraPaths[index] = entryPath;
extraFiles[index] = additionalEntry;
extraZips[index] = new ZipFile(additionalEntry);
extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ".dex", 0);
}
pathField.set(loader, path.toString());
expandFieldArray(loader, "mPaths", extraPaths);
expandFieldArray(loader, "mFiles", extraFiles);
expandFieldArray(loader, "mZips", extraZips);
expandFieldArray(loader, "mDexs", extraDexs);
}