[android-developers] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-22 Thread Mark Murphy

Ask wrote:
> Hi Dianne,
> 
>  Please respond.

If you want to demand people answer your questions, hire a consultant,
and make your demands to the consultant.

>> My aim is to send the .apk files dynamically from the desktop
>> using socket communication and execute one method in this .apk at
>> runtime . After executing this methos I will delete this .apk file.

Use a scripting language. Beanshell (Java-esque language) works as an
embeddable language. Rhino (Javascript) works as well, with minor
modifications. Other languages may also work if you prefer one of those.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books.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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-22 Thread Ask

Hi Dianne,

 Please respond.

On Apr 21, 6:27 pm, Ask  wrote:
> >executing code from the SD card is a security hole for your app, no
> >matter how short a time you have the code there.
>
>   now I am successful in writing file in the /data/app-private/ dir
> rather than /sdcard. So one problem is solved.
>
>    but still I cant invoke intents in the method which is called
> dynamically using PathClassLoader.
>
>    If android does not support dynamic loading of classes from another
> application  then my question to google engineers is that why You have
> provided the APIs like PathClassLoader , DexClassLoader and DexFile??
>
>    why the variables (which are defined outside the invoked method but
> inside the loaded class) throwing null pointer exception and why the
> problem occurs with intents( which are used in the invoked method)
> gives null pointer exception at startActivity(intent); line. Is there
> anyway to solve this problem.
>
>     My aim is to send the .apk files dynamically from the desktop
> using socket communication and execute one method in this .apk at
> runtime . After executing this methos I will delete this .apk file.
>
> Thanks,
> Asif
>
> On Apr 20, 1:13 pm, Dianne Hackborn  wrote:
>
>
>
> > On Sun, Apr 19, 2009 at 3:37 AM, Ask  wrote:
> > > >I am writing the file in the /sdcard using the application
> > > programmatically and the same file I am deleting when its work has been
> > > done. Same thing I had tried in the /data/app-private file but I could not
> > > write the file prgrammatically.. Is there any way to write in the private
> > > dir programmatically using changing permissions??
>
> > I am having a lot of trouble visualizing what you are trying to do, but if
> > you are getting in to situations where you are trying to write to an app
> > directory with a different UID, you really need to step back and rethink
> > what you are doing.
>
> > Also, executing code from the SD card is a security hole for your app, no
> > matter how short a time you have the code there.
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com
>
> > Note: please don't send private questions to me, as I don't have time to
> > provide private support, and so won't reply to such e-mails.  All such
> > questions should be posted on public forums, where I and others can see and
> > answer them.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-21 Thread Ask



>executing code from the SD card is a security hole for your app, no
>matter how short a time you have the code there.

  now I am successful in writing file in the /data/app-private/ dir
rather than /sdcard. So one problem is solved.

   but still I cant invoke intents in the method which is called
dynamically using PathClassLoader.

   If android does not support dynamic loading of classes from another
application  then my question to google engineers is that why You have
provided the APIs like PathClassLoader , DexClassLoader and DexFile??

   why the variables (which are defined outside the invoked method but
inside the loaded class) throwing null pointer exception and why the
problem occurs with intents( which are used in the invoked method)
gives null pointer exception at startActivity(intent); line. Is there
anyway to solve this problem.

My aim is to send the .apk files dynamically from the desktop
using socket communication and execute one method in this .apk at
runtime . After executing this methos I will delete this .apk file.

Thanks,
Asif


On Apr 20, 1:13 pm, Dianne Hackborn  wrote:
> On Sun, Apr 19, 2009 at 3:37 AM, Ask  wrote:
> > >I am writing the file in the /sdcard using the application
> > programmatically and the same file I am deleting when its work has been
> > done. Same thing I had tried in the /data/app-private file but I could not
> > write the file prgrammatically.. Is there any way to write in the private
> > dir programmatically using changing permissions??
>
> I am having a lot of trouble visualizing what you are trying to do, but if
> you are getting in to situations where you are trying to write to an app
> directory with a different UID, you really need to step back and rethink
> what you are doing.
>
> Also, executing code from the SD card is a security hole for your app, no
> matter how short a time you have the code there.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-20 Thread Dianne Hackborn
On Sun, Apr 19, 2009 at 3:37 AM, Ask  wrote:

> >I am writing the file in the /sdcard using the application
> programmatically and the same file I am deleting when its work has been
> done. Same thing I had tried in the /data/app-private file but I could not
> write the file prgrammatically.. Is there any way to write in the private
> dir programmatically using changing permissions??


I am having a lot of trouble visualizing what you are trying to do, but if
you are getting in to situations where you are trying to write to an app
directory with a different UID, you really need to step back and rethink
what you are doing.

Also, executing code from the SD card is a security hole for your app, no
matter how short a time you have the code there.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-19 Thread Ask

Can DexClassLoader solve this above problem?? I have not downloaded
early look sdk yet.. Will The application which is running on sdk 1.0
run on 1.5 without an problem??

On Apr 19, 3:37 pm, Ask  wrote:
> fadden,
>
>  >but rather why are you getting the
>
> >NullPointerException.
>
>     I am getting null pointer exception due to the variables which are
> defined outside the Method which is to be invoked but inside the
> activity. If I will define the same variable inside the method..
> application works nicely. If I am invoking intent in the method then
> it is throwing same exception at startAcitivity(intent). Can
> DexclassLoader fix all this problems??
>
> >Presumably you are running as root, and/or have changed the
> >permissions on /data/dalvik-cache.
>
>   I could not understand this.Can you please clearify.. Yes I had
> changed the permissions of the /data/dalvik-cache
>
> >I am writing the file in the /sdcard using the application programmatically 
> >and the same file I am deleting when its work has been done. Same thing I 
> >had tried in the /data/app-private file but I could not write the file 
> >prgrammatically.. Is there any way to write in the private dir 
> >programmatically using changing permissions??
>
> On Apr 18, 12:45 am, fadden  wrote:
>
>
>
> > On Apr 17, 6:24 am, Ask  wrote:
>
> > > The application will be residing in the /sdcard/ and I am loading it
> > > dynamically using PathClassLoader API.
> > > and using Method.invoke() function I am invoking the method residing
> > > in that class.
>
> > Presumably you are running as root, and/or have changed the
> > permissions on /data/dalvik-cache.
>
> > If you have the 1.5 "early look" SDK, you can start using
> > DexClassLoader, which allows you to choose where the output of
> > "dexopt" will go.  You should probably use the app's private storage
> > area on /data rather than /sdcard if that's feasible.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-19 Thread Ask

fadden,

 >but rather why are you getting the
>NullPointerException.


I am getting null pointer exception due to the variables which are
defined outside the Method which is to be invoked but inside the
activity. If I will define the same variable inside the method..
application works nicely. If I am invoking intent in the method then
it is throwing same exception at startAcitivity(intent). Can
DexclassLoader fix all this problems??


>Presumably you are running as root, and/or have changed the
>permissions on /data/dalvik-cache.

  I could not understand this.Can you please clearify.. Yes I had
changed the permissions of the /data/dalvik-cache

>I am writing the file in the /sdcard using the application programmatically 
>and the same file I am deleting when its work has been done. Same thing I had 
>tried in the /data/app-private file but I could not write the file 
>prgrammatically.. Is there any way to write in the private dir 
>programmatically using changing permissions??





On Apr 18, 12:45 am, fadden  wrote:
> On Apr 17, 6:24 am, Ask  wrote:
>
> > The application will be residing in the /sdcard/ and I am loading it
> > dynamically using PathClassLoader API.
> > and using Method.invoke() function I am invoking the method residing
> > in that class.
>
> Presumably you are running as root, and/or have changed the
> permissions on /data/dalvik-cache.
>
> If you have the 1.5 "early look" SDK, you can start using
> DexClassLoader, which allows you to choose where the output of
> "dexopt" will go.  You should probably use the app's private storage
> area on /data rather than /sdcard if that's feasible.
--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-17 Thread fadden

On Apr 17, 6:24 am, Ask  wrote:
> The application will be residing in the /sdcard/ and I am loading it
> dynamically using PathClassLoader API.
> and using Method.invoke() function I am invoking the method residing
> in that class.

Presumably you are running as root, and/or have changed the
permissions on /data/dalvik-cache.

If you have the 1.5 "early look" SDK, you can start using
DexClassLoader, which allows you to choose where the output of
"dexopt" will go.  You should probably use the app's private storage
area on /data rather than /sdcard if that's feasible.

--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-17 Thread fadden

On Apr 17, 5:56 am, Asif k  wrote:
>   But if I am using the variables which are defined outside that
> method ( in the same activity or same .apk) then my application throws
> "java.lang.reflect.InvocationTargetException" at runtime.
[...]
> caused due to NullPointerException.

When you call a method through e.g. Method.invoke(), any exception
thrown as a result of the call is wrapped in an
InvocationTargetException.  This is necessary because otherwise
checked exceptions could be getting thrown with nothing to catch
them.  So the question is not why are you getting an
InvocationTargetException, but rather why are you getting the
NullPointerException.

Which reference is null?

--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-17 Thread Mark Murphy

> means that exception is coming due to different user IDs??

No, probably it is coming due to using different class loaders. That's a
standard Java issue, not anything particular to Android.

>   Regarding Loading and ulloading of .apk in the /sdcard, I am making
> sure to put it in the card only when I am executing my application and
> after competion of my application I am deleting it from /sdcard
> programmatically.

I am unconvinced your approach is secure.

> Please give any idea to get rid of that exception...

Don't load external JARs. There are relatively few applications in this
world that rely upon downloading and executing untrusted code, and many of
those applications are plagued with problems like viruses and spyware.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-17 Thread Ask

means that exception is coming due to different user IDs??

why cant that method use any variable of the activity??


  Regarding Loading and ulloading of .apk in the /sdcard, I am making
sure to put it in the card only when I am executing my application and
after competion of my application I am deleting it from /sdcard
programmatically.

Please give any idea to get rid of that exception...

On Apr 17, 6:44 pm, "Mark Murphy"  wrote:
> > The application will be residing in the /sdcard/ and I am loading it
> > dynamically using PathClassLoader API.
> > and using Method.invoke() function I am invoking the method residing
> > in that class.
>
> Do not do that unless you have some means of ensuring that the code you
> are loading off that SD card is your code, and not some piece of malware.
>
> >   both are different application and I think both have different user
> > IDs. Is there any way to run both application as the same userID and
> > in the same process.???
>
> http://developer.android.com/guide/topics/manifest/application-elemen...
>
> http://developer.android.com/guide/topics/manifest/manifest-element.h...
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-17 Thread Mark Murphy

> The application will be residing in the /sdcard/ and I am loading it
> dynamically using PathClassLoader API.
> and using Method.invoke() function I am invoking the method residing
> in that class.

Do not do that unless you have some means of ensuring that the code you
are loading off that SD card is your code, and not some piece of malware.

>   both are different application and I think both have different user
> IDs. Is there any way to run both application as the same userID and
> in the same process.???

http://developer.android.com/guide/topics/manifest/application-element.html#proc

http://developer.android.com/guide/topics/manifest/manifest-element.html#uid

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-17 Thread Ask

Mark,

The application will be residing in the /sdcard/ and I am loading it
dynamically using PathClassLoader API.
and using Method.invoke() function I am invoking the method residing
in that class.

Yes it may violate the model but I need it in my application

>>If not, are both applications executing as the same user ID and in the
>>same process?

  both are different application and I think both have different user
IDs. Is there any way to run both application as the same userID and
in the same process.???

Regards,

Asif
On Apr 17, 6:04 pm, "Mark Murphy"  wrote:
> >    I am calling a method of another .apk file dynamically at runtime
> > in my application. I can execute it successfully if method does not
> > contain any variable which is defined outside of that method.
>
> Are you using remote services?
>
> If not, are both applications executing as the same user ID and in the
> same process?
>
> If not, how are you doing this, since it seems to violate the Android
> security model?
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
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] Re: java.lang.reflect.InvocationTargetException during calling a function of another application at runtime

2009-04-17 Thread Mark Murphy

>I am calling a method of another .apk file dynamically at runtime
> in my application. I can execute it successfully if method does not
> contain any variable which is defined outside of that method.

Are you using remote services?

If not, are both applications executing as the same user ID and in the
same process?

If not, how are you doing this, since it seems to violate the Android
security model?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---