Is there any way to dynamically load a class from a dex file inside a jar in Android APIs below 14?
Asked
Active
Viewed 645 times
0
-
1DexClassLoader has been added in API level 3 – pskink Nov 26 '13 at 21:57
-
around the web I have found a lot of examples, but they all in some point use this sintaxis : " DexClassLoader cl = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(), optimizedDexOutputPath.getAbsolutePath(), null, getClassLoader()); Class libProviderClazz = null; try { // Load the library. libProviderClazz = cl.loadClass("com.example.dex.lib.LibraryProvider"); " .... here, this last call to method "loadClass" requires api 14. – Hugo Alonso Nov 27 '13 at 19:19
-
"loadClass" requires api 14??? Any links to docs? – pskink Nov 27 '13 at 19:42
-
eclipse marks this line as error, with this message "Call requires API level 14 (current min is 8): dalvik.system.BaseDexClassLoader#loadClass". I was searching about BaseDexClassLoader and, in fact, it was added in API 14. Maybe I'm doing something wrong, please advice. – Hugo Alonso Nov 27 '13 at 19:51
-
Hi pskink, thanks for the time spent, the problem was mine, I was using android 4.3 library to make a project for 2.2...duh!? ajaja, thank you so much! – Hugo Alonso Nov 27 '13 at 20:06
1 Answers
0
maybe Lint in android IDE has error. I got same issue. I fixed it by add:
@SuppressLint("NewApi")
to my method.
Actually: this method can run in android API 8

Long Rainbow
- 328
- 3
- 10