[android-developers] DexClassLoader

2012-03-24 Thread moutaz al-azab
Hi Everyone,

I am trying to play with DexClassLoader
http://developer.android.com/reference/dalvik/system/DexClassLoader.htmland
http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/system/DexClassLoader.java.htmI
am wondering how can I use these classes. I am not expert in Android
but
I want to use these classes, does anyone has an idea?

Your Response Is Much Appreciated.

Many Thanks/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] DexClassLoader

2012-03-24 Thread moutaz al-azab
Hello Everyone,

I am trying to play with DexClassLoader
http://developer.android.com/reference/dalvik/system/DexClassLoader.htmland
http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/system/DexClassLoader.java.htmI
am wondering how can I use DexClassLoader.I am not expert in Android
and
I dont know how to use it, does anyone has an idea?

Your Response Is Much Appreciated.

Many Thanks/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] DexClassLoader

2012-03-25 Thread Marcin Orlowski
On 25 March 2012 07:12, moutaz al-azab  wrote:


> I am trying to play with DexClassLoader
> http://developer.android.com/reference/dalvik/system/DexClassLoader.htmland
> http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/system/DexClassLoader.java.htmI
>  am wondering how can I use DexClassLoader.I am not expert in Android and
> I dont know how to use it, does anyone has an idea?
>

You do not know how to use so i wonder if you know why you think you want
to use it? Do you really got any need for that? I doubt slightly...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] DexClassLoader

2012-03-25 Thread Marcin Orlowski
And do not do crossposts in future!

Regards,
Marcin Orlowski

*Tray Agenda * - keep you daily schedule handy...
*Date In Tray*  - current date at glance...
WebnetMobile on *Facebook *,
*Google+*and
*Twitter *

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] DexClassLoader

2012-03-26 Thread TreKing
On Sat, Mar 24, 2012 at 5:04 AM, moutaz al-azab  wrote:

> I am wondering how can I use these classes. I am not expert in Android but
> I want to use these classes, does anyone has an idea?


You should start by googling the class names.

Beyond that you need to explain why you want to use some classes that you
apparently have no knowledge of and be a bit more specific about what
you're trying to do and what you need help with.

http://www.catb.org/~esr/faqs/smart-questions.html

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] DexClassLoader

2012-03-26 Thread Kristopher Micinski
FYI...

If you're not sure what you're doing, you really really shouldn't be
using a class loader..., lest your app become infested with tons of
security holes.

kris

On Sat, Mar 24, 2012 at 6:04 AM, moutaz al-azab  wrote:
> Hi Everyone,
>
> I am trying to play with DexClassLoader
> http://developer.android.com/reference/dalvik/system/DexClassLoader.html and
> http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/dalvik/system/DexClassLoader.java.htm
> I am wondering how can I use these classes. I am not expert in Android but I
> want to use these classes, does anyone has an idea?
>
> Your Response Is Much Appreciated.
>
> Many Thanks/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] DexClassLoader- ActiivityNotFound

2010-05-27 Thread Craig
Hi,

I am trying to build an app that will load other 3rd party apk files
and can control access to them. For this reason I don't want to
install the files as then people will be able to bypass the checks my
app does etc. I was told DexClassLoader would be the best way to do
this.

Here is my code:
DexClassLoader dLoader = new DexClassLoader("/data/data/
com.craig.testapp/
test.apk","/data/data/
com.craig.testapp/",null,ClassLoader.getSystemClassLoader().getParent());
 Class calledClass = dLoader.loadClass("com.thirdparty.classname");
Intent it=new Intent(this, calledClass);
 it.setClassName("com.thirdparty", "com.thirdparty.classname");
startActivity(it);

Now I had already installed test.apk so when I ran the above code it
worked fine and launched the application. However I want to be able to
run this without test.apk being installed already (as that would
defeat the entire point of the application) . So I uninstalled it and
when I ran the my app again I get this error:

android.content.ActivityNotFoundException: Unable to find explicit
activity class {com.test/com.test.classname}; have you declared this
activity in your AndroidManifest.xml.?

So I'm not sure where to go next. I can't declare the Activity in the
Manifest becuase it is an external apk file I am trying to load. Is
this even possible? Am I going about this the wrong way? Any pointers
would be appreciated. I've done a lot of searches for more information
on DexClassLoader but I haven't been able to find anything.

Thanks,
Craig

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] DexClassLoader read res/raw/

2011-05-25 Thread Hank
How do I use a DexClassLoader to read an apk file I placed in my
applications res/raw/ folder?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] DexClassLoader Feature in the Cupcake

2009-03-24 Thread Asif k

Hi all,

   Can anyone please provide some information regarding the reflection
API DexclassLoader, which will be includeed in cupcake release?? In
the latest development of the cupcake, whether this feature is added
or still to be done??

   I f already included then any reference which will explain about
how to download that cupcake source from the repo, compile that source
and add in the current sdk. I am using windows plateform and running
the applications on the emulator.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] DexClassLoader and DexFile Leaking File Handles

2011-08-18 Thread Matt
I have an application that uses a DexClassLoader to load some
dynamically updateable plugin code.  I created a stress test
essentially looks like this:

while (true) {
Copy plugin jar from assets to temp directory
Create a DexClassLoader using plugin jar as the classpath
Load plugin using this class loader
Delete plugin jar from temp directory
}

Eventually, creating the DexClassLoader fails due to lack of disk
space.  When I look in /proc//fd, I see that my process is still
holding file handles to all of the now-deleted copies of the plugin
jar in the temp directory.  I see from looking at the code that
DexClassLoader has an array of JarFile's and an array of DexFile's,
which never seem to get closed.  I created my own copy of
DexClassLoader that has a close() method that cleans up these arrays,
but this has two problems:
1. It is not obvious when I should call the close method, since it's
difficult to know when all of the objects from an instance of the
plugin are gone.  I assume it's not safe to invalidate a classloader
when objects loaded from it are still around, since they might need to
load other classes from the classloader later.
2. Even when I do call the close method on my classloader, calling
DexFile.close() does not cause it to release it's handle to the jar
file.  This is consistent with the documentation for DexFile.

Is there a good way to clean up the resources used by a
DexClassLoader?  Or do I just have to hope that in the real world, my
application's process gets restarted often enough that I won't hit
this problem?

Thanks,
Matt

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] DexClassLoader issues on android 3.0 (api-11)

2011-10-11 Thread BogDan
Hello,

  I encounter a very strange problem using DexClassLoader on
android-11 (emulator), because I wasn't sure if is my fault I tested
android-custom-class-loading-sample[1] which was introduced in this
[2] blog post. The example is working perfectly on all android
versions (4,5,8,9,10,12,13) except android-11 which gives me the
following errors:
E/dalvikvm(  343): Can't open dex cache '/data/dalvik-cache/
data@d...@com.example.dex@app_dex@secondary_dex@classes.dex': No
such file or directory
I/dalvikvm(  343): Unable to open or create cache for /data/data/
com.example.dex/app_dex/secondary_dex.jar (/data/dalvik-cache/
data@d...@com.example.dex@app_dex@secondary_dex@classes.dex)
W/System.err(  343): java.lang.ClassNotFoundException:
com.example.dex.lib.LibraryProvider in loader
dalvik.system.DexClassLoader@406445c0
W/System.err(  343):at
dalvik.system.DexClassLoader.findClass(DexClassLoader.java:240)
W/System.err(  343):at
java.lang.ClassLoader.loadClass(ClassLoader.java:548)
W/System.err(  343):at
java.lang.ClassLoader.loadClass(ClassLoader.java:508)
W/System.err(  343):at com.example.dex.MainActivity
$1.onClick(MainActivity.java:79)
W/System.err(  343):at android.view.View.performClick(View.java:
3100)
W/System.err(  343):at android.view.View
$PerformClick.run(View.java:11644)
W/System.err(  343):at
android.os.Handler.handleCallback(Handler.java:587)
W/System.err(  343):at
android.os.Handler.dispatchMessage(Handler.java:92)
W/System.err(  343):at android.os.Looper.loop(Looper.java:126)
W/System.err(  343):at
android.app.ActivityThread.main(ActivityThread.java:3997)
W/System.err(  343):at
java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(  343):at java.lang.reflect.Method.invoke(Method.java:
491)
W/System.err(  343):at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:841)
W/System.err(  343):at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
W/System.err(  343):at dalvik.system.NativeStart.main(Native
Method)
D/SntpClient(   67): request time failed: java.net.SocketException:
Address family not supported by protocol

The problem is that my application depends by this feature, so I want
to ask if is there any (known) workaround for this issue ? I also
tried with PathClassLoader but the result was the same, any idea will
be very appreciated !

Thank you.

BogDan.

[1] http://code.google.com/p/android-custom-class-loading-sample/
[2] 
http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] DexClassLoader caould not invoke method from another application properly

2009-05-13 Thread Asif k

Hi all,

   I had used DexClassLoader to execute the code of other application
dynamically. I am calling method display() of another application from
my application. The display() method will just show the Toast pop up.

The following is the code of my running application

DexClassLoader dLoader = new DexClassLoader("/data/app/
android.testcase.apk","/data/app-
private",null,ClassLoader.getSystemClassLoader());
try {
Class cLoad = 
dLoader.loadClass("android.testcase.TestCase");
//Class[] param = new Class[] 
{Bundle.class};
Method mLoad = 
cLoad.getMethod("display",null);
Object obj = cLoad.newInstance();
mLoad.invoke(obj);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

The method display() in the other android.testcase.apk is as follows,

public void display() {

Toast.makeText(this, "Loaded properly",Toast.LENGTH_SHORT).show
();


}

But this gives Exception and stacktrace as follows



05-13 20:10:22.155: WARN/System.err(773):
java.lang.reflect.InvocationTargetException
05-13 20:10:22.166: WARN/System.err(773): at
android.testcase.TestCase.dispaly(TestCase.java:23)
05-13 20:10:22.176: WARN/System.err(773): at
java.lang.reflect.Method.invokeNative(Native Method)
05-13 20:10:22.186: WARN/System.err(773): at
java.lang.reflect.Method.invoke(Method.java:521)
05-13 20:10:22.194: WARN/System.err(773): at
android.loaduiapp.LoadUiApp$1.onClick(LoadUiApp.java:28)
05-13 20:10:22.194: WARN/System.err(773): at
android.view.View.performClick(View.java:2179)
05-13 20:10:22.204: WARN/System.err(773): at
android.view.View.onTouchEvent(View.java:3828)
05-13 20:10:22.204: WARN/System.err(773): at
android.widget.TextView.onTouchEvent(TextView.java:6291)
05-13 20:10:22.216: WARN/System.err(773): at
android.view.View.dispatchTouchEvent(View.java:3368)
05-13 20:10:22.225: WARN/System.err(773): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
05-13 20:10:22.235: WARN/System.err(773): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
05-13 20:10:22.246: WARN/System.err(773): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
05-13 20:10:22.256: WARN/System.err(773): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
05-13 20:10:22.256: WARN/System.err(773): at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchTouchEvent(PhoneWindow.java:1707)
05-13 20:10:22.266: WARN/System.err(773): at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent
(PhoneWindow.java:1197)
05-13 20:10:22.266: WARN/System.err(773): at
android.app.Activity.dispatchTouchEvent(Activity.java:1993)
05-13 20:10:22.275: WARN/System.err(773): at
com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
05-13 20:10:22.284: WARN/System.err(773): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
05-13 20:10:22.284: WARN/System.err(773): at
android.os.Handler.dispatchMessage(Handler.java:99)
05-13 20:10:22.297: WARN/System.err(773): at android.os.Looper.loop
(Looper.java:123)
05-13 20:10:22.305: WARN/System.err(773): at
android.app.ActivityThread.main(ActivityThread.java:3948)
05-13 20:10:22.305: WARN/System.err(773): at
java.lang.reflect.Method.invokeNative(Native Method)
05-13 20:10:22.305: WARN/System.err(773): at
java.lang.reflect.Method.invoke(Method.java:521)
05-13 20:10:22.314: WARN/System.err(773): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
05-13 20:10:22.314: WARN/System.err(773): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
05-13 20:10:22.324: WARN/System.err(773): at
dalvik.system.NativeStart.main(Native Method)
05-13 20:10:22.336: WARN/System.err(773): Caused by:
java.lang.NullPointerException
05-13 20:10:22.454: DEBUG/dalvikvm(773): GC freed 4388 objects /
414064 bytes in 115ms
05-13 20:10:22.466: WARN/System.err(773): at
android.content.ContextWrapper.getResources(ContextWrapper.java:79)
05-13 20:10:22.466: WARN/System.err(773): at
android.widget.Toast.(Toast.java:88)
05-13 20:10:22.477: WARN/System.err(773): at
android.widget.Toast.makeText(Toast.java:230)
05-13 20:10:22.485: WARN/System.err(773): ... 25 more


Please Help. Am I missing something??


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-de