当前位置: 首页>>代码示例>>Java>>正文


Java DexFile.loadDex方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:17,代码来源:DexFileCompat.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:MultiDex.java

示例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);
        }
    }
}
 
开发者ID:charslab,项目名称:Android-Hotpatch,代码行数:23,代码来源:Hotpatch.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:MultiDex.java

示例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);
    }
}
 
开发者ID:aphexyuri,项目名称:dexter,代码行数:23,代码来源:Dexter.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:TinkerDexOptimizer.java

示例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);
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:37,代码来源:MultiDex.java

示例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) {
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:32,代码来源:SystemClassLoaderAdder.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:41,代码来源:DexDiffPatchInternal.java

示例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);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:36,代码来源:MultiDex.java

示例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);
}
 
开发者ID:dodola,项目名称:RocooFix,代码行数:36,代码来源:RocooFix.java

示例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);
}
 
开发者ID:nuptboyzhb,项目名称:AndroidPluginFramework,代码行数:39,代码来源:AssetsMultiDexLoader.java

示例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);
}
 
开发者ID:LiuHongtao,项目名称:hthotfix-android,代码行数:31,代码来源:HTHotFixDex.java

示例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);
}
 
开发者ID:typ0520,项目名称:fastdex,代码行数:37,代码来源:MultiDex.java


注:本文中的dalvik.system.DexFile.loadDex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。