dexclassloader

Android DexClassLoader error, 'optimized data directory .. not owned by current user'

ぃ、小莉子 提交于 2019-12-30 11:20:50
问题 I am trying to produce a simple android application that can load a DEX file from the SD card at run-time. The application has two activites. The first activity is a simple screen that has a button. When the button is pressed, the second activity is launched which causes the loadDex() method to be invoked. The loadDex() method attempts to locate a jar file on the SD card and load it into the current application. Here is my code for the first activity: package poc.example.del.customclass;

How to execute APKs on a customized data directory?

走远了吗. 提交于 2019-12-17 23:33:14
问题 I was wondering how Parallel Space app can duplicate and execute other apps without copying their APKs or running them under modified package names like other apps on Playstore do (e.g.: "com.whatever.name-of-duplicated-app" ). After investigating their AndroidManifest.xml , the folders created on /data/data/ , and the logs on the device, the only conclusion I could get is that somehow Parallel Space is capable of executing the code from other APKs but it maps the data directories of those

Class resolved by unexpected DEX;

空扰寡人 提交于 2019-12-07 14:28:22
问题 I am developing a application which automatically load class from external dex from external apk file (external apk file is stored in internal storage of application). The external apk file have class using com.google.gson. The source code of the application // Internal storage where the DexClassLoader writes the optimized dex file to. final File optimizedDexOutputPath = mContext.getDir("optimize_offload", Context.MODE_PRIVATE); // Initialize the class loader with the s dex file.

Stranger things in Android class resolution

本小妞迷上赌 提交于 2019-12-06 04:18:56
问题 I observe quite a few behaviors on Android (I am working on a multidex issue, so I use an emulator in 4.4.4) that leave me speechless about Android class loading: On Android classes are not supposed to be resolved when being loaded by the class loader. But if I create a class: public class M { public Foo m(String i) { switch (i) { case "0": return new Foo(); case "1": return new Foo2(); } return null; } } and debug my app, adding watches: getClass().getClassLoader().findLoadedClass("Foo")

Class resolved by unexpected DEX;

╄→гoц情女王★ 提交于 2019-12-05 21:35:31
I am developing a application which automatically load class from external dex from external apk file (external apk file is stored in internal storage of application). The external apk file have class using com.google.gson. The source code of the application // Internal storage where the DexClassLoader writes the optimized dex file to. final File optimizedDexOutputPath = mContext.getDir("optimize_offload", Context.MODE_PRIVATE); // Initialize the class loader with the s dex file. DexClassLoader dexClassLoader = new DexClassLoader(apkPath, optimizedDexOutputPath.getAbsolutePath(), null,

浅谈Android虚拟机的动态加载技术

前提是你 提交于 2019-12-02 19:34:46
Android虚拟机的动态加载技术分为两种: 一种是加载基于NDK的so库;另一种是加载用java语言开发的zip包 。我今天主要讨论后者。 先简单说明一下so库加载。 NDK的执行效率很高,加密性很好,但同时开发入门难度大,一般用于加解密、数学运算等场合 。so的加载很简单,如果APK发布时已经携带了so文件,只需要在加载时调用 System.loadLibrary(libName) 方法即可。由于软件的安装目录中存放so的目录是没有写权限的,开发者不能更改该目录的内容,所以如果要动态加载存放在其他地方的so文件,用 System.load(pathName) 方法即可。 现在我们重点来看一下如何用java开发android的动态包。之所以前面称之为zip包,是因为 jar和apk其实都是zip格式的 。android虚拟机支持这两种文件后缀的包。 android虚拟机支持加载zip包中的dex格式的代码文件 。所以我们要用到一个很重要的类 DexClassLoader ,这个类是动态加在技术的关键。提到动态加载,还需要用到的一个就是 java的反射技术 ,下面就举一个调用伪代码: DexClassLoader dcl = new DexClassLoader( zip文件所在绝对路径 , zip文件所在目录 , 默认加载so所在目录 ,

How to execute APKs on a customized data directory?

谁说胖子不能爱 提交于 2019-11-28 20:48:10
I was wondering how Parallel Space app can duplicate and execute other apps without copying their APKs or running them under modified package names like other apps on Playstore do (e.g.: "com.whatever.name-of-duplicated-app" ). After investigating their AndroidManifest.xml , the folders created on /data/data/ , and the logs on the device, the only conclusion I could get is that somehow Parallel Space is capable of executing the code from other APKs but it maps the data directories of those apps into its own Data Directory. Evidences: Directories are created like this: /data/data/com.lbe

Is it still the case that Android never unloads classes?

半世苍凉 提交于 2019-11-28 03:42:28
问题 We have a large app that's always running into the dread method count limit. I've been asked to come up with a way to let it do much more, including supporting plugins. Looking for ways to unload code, I ran across JNI Tips which says Classes are only unloaded if all classes associated with a ClassLoader can be garbage collected, which is rare but will not be impossible in Android. This did seem to imply that a plugin can be unloaded if you, say, use a new DexClassLoader for each .jar file,