10

I am experimenting quite a strange behaviour in my Android app and have not been able to find a solution in Stackoverflow or whatever place.

I have an Android application working properly with no error when loaded from Eclipse to the mobile phone. But when signed I am seeing this errors in Logcat:

E/DatabaseUtils(2360): Writing exception to parcel
E/DatabaseUtils(2360): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
E/DatabaseUtils(2360):  at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13140)
E/DatabaseUtils(2360):  at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
E/DatabaseUtils(2360):  at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
E/DatabaseUtils(2360):  at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
E/DatabaseUtils(2360):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
E/DatabaseUtils(2360):  at android.os.Binder.execTransact(Binder.java:388)
E/DatabaseUtils(2360):  at dalvik.system.NativeStart.run(Native Method)

and after that:

E/Parcel(2360): Class not found when unmarshalling: com.meapp.utilites.Anuncio
E/Parcel(2360): java.lang.ClassNotFoundException: com.meapp.utilites.Anuncio
E/Parcel(2360):     at java.lang.Class.classForName(Native Method)
E/Parcel(2360):     at java.lang.Class.forName(Class.java:204)
E/Parcel(2360):     at java.lang.Class.forName(Class.java:169)
E/Parcel(2360):     at android.os.Parcel.readParcelableCreator(Parcel.java:2091)
E/Parcel(2360):     at android.os.Parcel.readParcelable(Parcel.java:2055)
E/Parcel(2360):     at android.os.Parcel.readValue(Parcel.java:1971)
E/Parcel(2360):     at android.os.Parcel.readMapInternal(Parcel.java:2255)
E/Parcel(2360):     at android.os.Bundle.unparcel(Bundle.java:223)
E/Parcel(2360):     at android.os.Bundle.getString(Bundle.java:1082)
E/Parcel(2360):     at android.content.Intent.getStringExtra(Intent.java:4961)
E/Parcel(2360):     at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3761)
E/Parcel(2360):     at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:4977)
E/Parcel(2360):     at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3173)
E/Parcel(2360):     at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3129)
E/Parcel(2360):     at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:157)
E/Parcel(2360):     at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2125)
E/Parcel(2360):     at android.os.Binder.execTransact(Binder.java:388)
E/Parcel(2360):     at dalvik.system.NativeStart.run(Native Method)
E/Parcel(2360): Caused by: java.lang.NoClassDefFoundError: com/meapp/utilites/Anuncio
E/Parcel(2360):     ... 18 more
E/Parcel(2360): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.meapp.utilites.Anuncio" on path: .
E/Parcel(2360):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
E/Parcel(2360):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/Parcel(2360):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/Parcel(2360):     ... 18 more

I am using proguard with my application and I added these lines to ensure that com.meapp.utilites.Anuncio is visible:

-keep class com.meapp.utilites.** { *; }
-keep class * implements android.os.Parcelable { *; }
-keep public class com.meapp.utilites.Anuncio

com.meapp.utilites.Anuncio implements Parcelable.

But the most extrange thing to me is that even after a ClassNotFoundException not "catched" the app works properly. Even more, the app is doing it work like the Parcelable was recovered without problems because it uses the data contained in that object.

So I have a couple of questions:

  1. Why is giving me a Permission denial in my signed application but there's not problem in the unsigned one?

  2. Why not is crashing my app after a ClassNotFound...?

  3. Why is working properly but announcing that error?

  4. How can I solve this and make proguard make my class visible?

Thanks for your help, I think this a question for Android Ninjas...

Chelu Martín
  • 578
  • 5
  • 17
  • I am facing the same. Did you get any thing? – Atul O Holic Dec 12 '14 at 13:38
  • @AtulOHolic Related http://stackoverflow.com/questions/19756727/what-do-i-do-about-this-requires-android-permission-interact-across-users-full/19756762#19756762 – rnrneverdies Dec 13 '14 at 02:42
  • @OneWay - I added that permission but it didn't help. Any other solution? – Atul O Holic Dec 13 '14 at 12:37
  • Do you read comments below of answer? – rnrneverdies Dec 13 '14 at 13:18
  • Yes I did and it only says that its beyond limits. – Atul O Holic Dec 14 '14 at 07:58
  • The error is most likely in your `Anuncio` class. Please post that code. – Jeffrey Mixon Dec 17 '14 at 03:40
  • Before android 4.1 there was only 1 user but since then accounts have been added. In 4.2 and 4.3 the security was expanded and I think they added sandboxing to prevent applications from doing things outside of their allotted space without explicit permission. From what I can tell you seem to be trying to access a database from another user somehow. – G_V Dec 18 '14 at 12:44
  • Can you share Anuncio, something is wrong with it. I thing it should have went through proguard with no problems but maybe it depends on something else. – Mostafa Gazar Dec 18 '14 at 18:41
  • "Why not is crashing my app after a ClassNotFound...?" -- my guess is that your app is not the one that is crashing. My guess is that you are using `Anuncio` as an extra that is being examined by some other process. – CommonsWare Dec 19 '14 at 00:50
  • Thank you all of you for your comments. I placed the answer below, maybe @CommonsWare is right but I am sorry I don't have the tools to check that now. – Chelu Martín Dec 19 '14 at 14:32

3 Answers3

5

I had this problem 6 months ago so I had to search in bitbucket to see what I changed to make it work.

What I did was change my script proguard-project.txt using this template as a base:

# Basic Template extracted from http://wiebe-elsinga.com/blog/obfuscating-for-android-with-proguard/
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

You can find more info in http://wiebe-elsinga.com/blog/obfuscating-for-android-with-proguard/

As you can see, related to the Parcelable, my original script missed some part of the configuration:

-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}

I hope this helps to all of you @AtulOHolic & @OneWay

Chelu Martín
  • 578
  • 5
  • 17
1

android.permission.INTERACT_ACROSS_USERS_FULL is a signature level permission. Your app will not be able to use it until and unless it has the same signature as the system.

class not found may be due to package problem , make sure that you have given same package name of launching activity as of package name.

hope this will help

Sukhbir
  • 1,410
  • 14
  • 33
0

you missed one more step while taking care of when using Parceble with progaurd. you can check out this.

and for you case add this line in progaurd text file

  -keep class * implements android.os.Parcelable { 
   public static final android.os.Parcelable$Creator *; 
}
Community
  • 1
  • 1
Imtiyaz Khalani
  • 2,037
  • 18
  • 32