1

I recently started with Android (developing in Java for two years) and did my first application. I did simple calculator project with working java code which is running correctly on emulator in Android Studio. Then I did this: run 'app' (everything working in emulator and also on attached phone via USB) > searched for generated apk (apk without sign) > transferred to my Samsung s4 mini (via USB) > installed > application works fine like on AS emulator or attached phone via USB. Then I tried to create signed APK instead and here comes problem. I build signed APK (created keystore and everything) > transfer to phone > install > run application and on my logcat is popping this text when i started app:

01-30 20:38:40.738 886-1822/? E/DatabaseUtils: Writing exception to parcel
   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
       at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15168)
       at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2492)
       at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:688)
       at android.content.ContentProvider$Transport.call(ContentProvider.java:325)
       at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:275)
       at android.os.Binder.execTransact(Binder.java:404)
       at dalvik.system.NativeStart.run(Native Method)

Here is what looks strange from log above "android.permission.INTERACT_ACROSS_USERS_FULL", but application didnt crashed yet.

Then I pressed (in this example) number five on calculator which should add "5" on display, but when i press button, application crashes with this log:

01-30 20:38:40.748 27869-27869/? E/AndroidRuntime: FATAL EXCEPTION: main
   Process: com.cka.kalkulajda, PID: 27869
   java.lang.IllegalStateException: Could not find a method five(View) in the activity class com.cka.kalkulajda.MainActivity for onClick handler on view class android.widget.Button with id 'fiveButt'
       at android.view.View$1.onClick(View.java:3956)
       at android.view.View.performClick(View.java:4640)
       at android.view.View$PerformClick.run(View.java:19425)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:146)
       at android.app.ActivityThread.main(ActivityThread.java:5593)
       at java.lang.reflect.Method.invokeNative(Native Method)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
       at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.NoSuchMethodException: five [class android.view.View]
       at java.lang.Class.getConstructorOrMethod(Class.java:472)
       at java.lang.Class.getMethod(Class.java:857)
       at android.view.View$1.onClick(View.java:3949)
       at android.view.View.performClick(View.java:4640) 
       at android.view.View$PerformClick.run(View.java:19425) 
       at android.os.Handler.handleCallback(Handler.java:733) 
       at android.os.Handler.dispatchMessage(Handler.java:95) 
       at android.os.Looper.loop(Looper.java:146) 
       at android.app.ActivityThread.main(ActivityThread.java:5593) 
       at java.lang.reflect.Method.invokeNative(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:515) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
       at dalvik.system.NativeStart.main(Native Method) 

This is strange part after pressing number 5: Could not find a method five(View) in the activity class com.cka.kalkulajda.MainActivity for onClick handler on view class android.widget.Button with id 'fiveButt'.

I'm sure everything regarding java code is correct (it works on emulator and also unsigned APK and ALSO when I'm not run project on emulator, but via USB on my phone), for example on emulator I press number 5 and it adds number 5, but when trying press any button ON SIGNED APK, app just crash.

I Googled everywhere but there is no straight answer to this or any real solution that works.

com.cka.kalkulajda is project..... five(View) method is attached to fiveButt ID of button ...every help is highly appriciated

TL;DR when I running project on emulator - works.... when running project via USB on phone - works... installing generated unsigned APK to phone and run - works..... installing built signed APK to phone and run - works with "bitching" (see log), but after pressed any button app crashes (see log)

edit: I'm adding build.gradle app

    apply plugin: 'com.android.application'

android {
    signingConfigs {
        config {
            keyAlias 'password'
            keyPassword 'passwordd'
            storeFile file('D:/KeyStore/key.jks')
            storePassword 'passwordd'
        }
    }
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.cka.kalkulajda"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    testCompile 'junit:junit:4.12'
}
Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
R. T.
  • 11
  • 3
  • strange, can you post build.gradle app? – Iqbal Rizky Jan 30 '17 at 20:11
  • See this: http://stackoverflow.com/questions/20578474/permission-denial-this-requires-android-permission-interact-across-users-full – Alex Jan 30 '17 at 20:16
  • @ntaloventi i added build.gradle app – R. T. Jan 30 '17 at 20:24
  • @AlexR i was looking there, and there is no real solution to this, just doesnt work – R. T. Jan 30 '17 at 20:25
  • like SamSPICA said `this feature can only be used by the device OEMs.` damn, i will use this for my next project, I'm curious about this. (sorry cannot help) – Iqbal Rizky Jan 30 '17 at 20:34
  • are you using reflection? reflection does not mix well with proguard – SteelBytes Jan 30 '17 at 23:58
  • @SteelBytes no, im using only Android Studio without any plugins...can problem occur becouse i didnt upload to googleplay and then downloaded from there ? sounds strange but if there is problem only with signed apk, maybe it require for some registration or something. Becouse i only transfered it from PC via USB and install and then problem occurs. When transfer via USB unsigned APK there is no problem – R. T. Jan 31 '17 at 00:29
  • you do not need to upload to google play. I also didn't say anything about plugins? – SteelBytes Jan 31 '17 at 00:36
  • @SteelBytes Aha reflection, no i didnt use any reflections in code, code is simple, and NOW i just did Hello world test project with button when on pressed, it sets text to textView... again, in emulator its working, but on signed apk installed on my phone it crashes on pressing that button, with same problem as calculator project – R. T. Jan 31 '17 at 01:06

0 Answers0