¿Cómo eliminar este error? java.lang.reflect.InvocationTargetException [duplicado]

I added All the needed permissions

 PackageManager packageManager = context.getPackageManager();
    Class<?> [] c = new Class[2];
    c[0] = String.class;
    c[1] = IPackageDataObserver.class;
    try {

    Object cleardata = packageManager.getClass().getMethod("clearApplicationUserData", c);
       Object[] o = new Object[2];
       o[0] = String.valueOf("my.app.withdata");
       o[1] = new ClearApplicationDataObserver();

    ((Method)cleardata).invoke(packageManager, o);
  }
    catch(Exception e) {e.printStackTrace();
 }

02-02 16:08:26.629: W/System.err(709): java.lang.reflect.InvocationTargetException
02-02 16:08:26.678: W/System.err(709):  at java.lang.reflect.Method.invokeNative(Native Method)
02-02 16:08:26.738: W/System.err(709):  at java.lang.reflect.Method.invoke(Method.java:511)
02-02 16:08:26.738: W/System.err(709):  at f.c.v.ClearUserDataUsingInterfaceActivity.run1(ClearUserDataUsingInterfaceActivity.java:105)
02-02 16:08:26.778: W/System.err(709):  at f.c.v.ClearUserDataUsingInterfaceActivity$1.run(ClearUserDataUsingInterfaceActivity.java:52)
02-02 16:08:26.778: W/System.err(709):  at java.lang.Thread.run(Thread.java:856)
02-02 16:08:26.778: W/System.err(709): Caused by: java.lang.SecurityException: Neither user 10048 nor current process has android.permission.CLEAR_APP_USER_DATA.
02-02 16:08:26.778: W/System.err(709):  at android.os.Parcel.readException(Parcel.java:1327)
02-02 16:08:26.778: W/System.err(709):  at android.os.Parcel.readException(Parcel.java:1281)
02-02 16:08:26.808: W/System.err(709):  at android.content.pm.IPackageManager$Stub$Proxy.clearApplicationUserData(IPackageManager.java:2568)
02-02 16:08:26.808: W/System.err(709):  at android.app.ApplicationPackageManager.clearApplicationUserData(ApplicationPackageManager.java:1006)
02-02 16:08:26.808: W/System.err(709):  ... 5 more

preguntado el 02 de febrero de 12 a las 10:02

You've asked the same question before. -

yes i've asked but did not get the answer. -

@johnsmith - If you want people to pay attention to your old Question, 1) update it as required, and 2) post a Bonus. (You have enough rep points for that!) Don't just repost the Question ... 'cos the repost will be closed as a duplicate. -

2 Respuestas

nvocationTargetException is due to unability of system to invoke an activity, and it is becuase there is another error on activity, please check the real issue is: java.lang.SecurityException: Neither user 10048 nor current process has android.permission.CLEAR_APP_USER_DATA. and its because you need to set this permission in android manifest file.

Respondido 02 Feb 12, 14:02

I added the permission android.permission.CLEAR_APP_USER_DATA not working - Soleada

then clean and launch your app, again. - jeet

Try adding this permission to your application's Manifest.:

android.permission.CLEAR_APP_USER_DATA

Respondido 02 Feb 12, 14:02

I added the permission android.permission.CLEAR_APP_USER_DATA not working - Soleada

Well go back and check that you have added the permission la manera correcta!! Clearly the security manager todavía dice that the application does not have the required permission ... no matter what you think you have done. - Stephen C

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.