Office Hours — Today, April 4

Yesterday, April 3

Mark M.
has entered the room
Mark M.
turned on guest access
Apr 4
7:45 PM
Ruairi M.
has entered the room
Ruairi M.
cHi Mark
Mark M.
hello, Ruairi!
how can I help you today?
Ruairi M.
View paste
I have implemented the new(ish) runtime permissions for marshmallow -> all is working as expected on devices running > Lollipop. When I run/build app on device running <= Lollipop, the app will not install, citing a security exception. This is obviously expected, since pre marshammallow permissions must be explicitly granted at install time (when downloaded from the Play store. My questions is - for development purposes - can you suggest a workaround - so that - if 'sensitive' permissions are added to the manifest - that I can bypass - and so, the app can be installed on emulator or device via Android studio - so that I can verify that all is working as expected on older devices.

Not: 
- I have tried the <uses-permission-sdk-23 android:name="string" android:maxSdkVersion="integer"/> cite: https://developer.android.com/guide/topics/manifest/uses-permission-sdk-23-element.html

- I am also using the ContextCompat.checkSelfPermission() and Fragment.requestPermissions() calls - but still getting security issue... any help would be much appreciated. Thanks
Mark M.
you need the permissions in the manifest in all Android versions
Ruairi M.
Yeah
Mark M.
on Android 6.0 and higher, you *also* need the runtime permission support
so, I do not understand your question
if you use ContextCompat.checkSelfPermission(), it will "do the right thing" for all Android versions
so your Java code is the same for old and new
since your manifest is already the same for old and new... I am not certain what you need that is different
7:50 PM
Ruairi M.
Basically
The app will not install on an emulator when built from Android studio on api images < marshmallow
Security exception in logcat
Mark M.
usually, a SecurityException occurs at runtime, not when the app is installed
Ruairi M.
But it works as expected on api images >= marshmallow
Mark M.
what exactly is the exception that you are seeing?
Ruairi M.
2 secs...I will run it
api 19
View paste
 VFY: unable to find exception handler at addr 0x1b
    VFY:  rejected Lcom/thenational/utils/store/secure/AndroidSecurityHandler;.getCipherSymmetric (Ljava/lang/String;)Ljavax/crypto/Cipher;
    VFY:  rejecting opcode 0x0d at 0x001b
    VFY:  rejected Lcom/thenational/utils/store/secure/AndroidSecurityHandler;.getCipherSymmetric (Ljava/lang/String;)Ljavax/crypto/Cipher;
View paste
04-04 23:53:01.718 2552-2552/? E/dalvikvm: Could not find class 'android.security.keystore.KeyGenParameterSpec$Builder', referenced from method com.thenational.utils.store.secure.AndroidSecurityHandler.generateKeysSymmetric
Mark M.
is com.thenational your app?
Ruairi M.
Ye
Mark M.
this, however, is not a crash
7:55 PM
Ruairi M.
There is no crash
Mark M.
then, I am uncertain what the problem is
Ruairi M.
just wont install
Because permissions have not been granted
Mark M.
there is nothing in those messages that have anything to do with permissions
how are you determining that the app is not installing, and how are you determining that it has something to do with permissions?
Ruairi M.
Mark M.
that question, and my answer, are for an installed app
that app crashed at runtime
and it resulted in the stack trace shown in the question
Ruairi M.
The log I posted is similar to the issue in the stackoverflow issue - so I assumed was the same
Mark M.
the VFY messages are saying that your code is referencing android.security.keystore.KeyGenParameterSpec.Builder, and that class does not exist on API Level 19
so long as you do not execute any statements that refer to that class, though, you are still OK
so, I'm back to my earlier questions: how are you determining that the app is not installing, and how are you determining that it has something to do with permissions?
8:00 PM
Ruairi M.
Well... i have just noticed that the app icon is appearing in the app drawer - so, yeah it is installing - but the app does not start - device just sits on home screen
no visual indication that it has installed - no start etc
Mark M.
OK, when you tap your app's launcher icon, does a stack trace now show up in LogCat?
indicating a crash in your app?
Ruairi M.
No
View paste
04-05 00:03:00.143 1601-1715/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=co.uk.youandb.android.b.dev.debug/com.thenational.activity.EntryActivity} from pid 1745
Mark M.
OK, it looks like it thinks that it started your activity
Ruairi M.
i have tried a fresh avd image, tried api level 19, 21 --> same result
works perfectly for marshmallow
Mark M.
if you run your app in the debugger, does you acrivity's onCreate() method get called?
(er, that should be "activity's")
8:05 PM
Ruairi M.
The EntryActivity?
I will try
Doesnt hit the breakpoint - nothing in log either
Strange
Mark M.
I'm not sure what to tell you
Ruairi M.
Only code added was permission request
Ok... it's a tricky one
So...basic checklist
Permissions <use-permission xxx /> AND <use-permission v23 xx/>
Mark M.
for the same permission?
Ruairi M.
Yeah?
View paste
<uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
Mark M.
that is not necessary and may be causing problems
use one or the other
those are separate permissions
I meant, are you using <uses-permission> and <uses-permission-sdk23> for the same permission?
Ruairi M.
No
Mark M.
OK
Ruairi M.
At present - these are the only permissions being declared
View paste
  <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
Mark M.
OK, nothing unusual there
Ruairi M.
It's fine - I will keep googling - thanks for your time Mark
8:10 PM
Mark M.
sorry that I did not have a quick fix for you!
Ruairi M.
Many thanks
One other thing - have you any released any materials/resources on dagger-android specifically
Mark M.
no, sorry
Ruairi M.
Ok
Thanks mate
Bye Mark - keep up the good work!
*great
Mark M.
thanks!
8:30 PM
Mark M.
that's a wrap for today's chat
the transcript will be posted to https://commonsware.com/office-hours/ shortly
the next chat is tomorrow at 4pm US Eastern
have a pleasant day!
Ruairi M.
has left the room
Mark M.
turned off guest access

Yesterday, April 3

 

Office Hours

People in this transcript

  • Mark Murphy
  • Ruairi McGuigan