i'm using espresso testing try image form external storage , marshmallow need runtime permission otherwise there exception crash , test fail.
androidtestcompile 'com.android.support.test:runner:0.4' androidtestcompile 'com.android.support.test:rules:0.4' androidtestcompile 'com.android.support.test.espresso:espresso-core:2.2.1' androidtestcompile 'com.android.support.test.espresso:espresso-intents:2.2.1' androidtestcompile('com.android.support.test.espresso:espresso-contrib:2.2.1') { // library uses newest app compat v22 espresso contrib still v21. // have exclude older versions of contrib library or // there conflicts exclude group: 'com.android.support', module: 'appcompat' exclude group: 'com.android.support', module: 'support-v4' exclude module: 'recyclerview-v7' } androidtestcompile 'junit:junit:4.12' androidtestcompile 'com.squareup.retrofit:retrofit-mock:1.9.0' androidtestcompile 'com.squareup.assertj:assertj-android:1.1.0' androidtestcompile 'com.squareup.spoon:spoon-client:1.2.0'
how can manage right?
should write test runtime permissions or there's way disable testing?
should give permissions before tests run says here? https://www.youtube.com/watch?list=plwz5rj2ekkc-ljo_rggxl2psr8vvctwjm&v=c8ludpvszdk
you can create android gradle task grant permission:
android.applicationvariants.all { variant -> def applicationid = variant.applicationid def adb = android.getadbexe().tostring() def variantname = variant.name.capitalize() def grantpermissiontask = tasks.create("grant${variantname}permissions") << { "${adb} devices".execute().text.eachline { if (it.endswith("device")){ def device = it.split()[0] println "granting permissions on devices ${device}" "${adb} -s ${device} shell pm grant ${applicationid} android.permission.camera".execute() "${adb} -s ${device} shell pm grant ${applicationid} android.permission.access_fine_location".execute() } } } }
and command run task: gradle grantdebugpermissions
Comments
Post a Comment