android - Gradle doesn't pick up meta-data correctly from AndroidManifest.xml when using integration testing -
quick summary: trying integration testing using gradlew connectedandroidtest on android studio 1.2.2 following error:
position 28:28-65 : no resource found matches given name (at 'value' value '@integer/google_play_services_version'). position 31:28-51 : no resource found matches given name (at 'value' value '@string/google_maps_key').
full story: have 2 different androidmanifest.xml, 1 release , 1 integration/instrumentation testing.
i execute instrumentation tests using:
gradlew connectedandroidtest
this uses androidmanifest.xml located @ .../src/androidtest/ , builds , runs android tests. looks this:
<uses-sdk android:targetsdkversion="22" android:minsdkversion="15"/> <uses-feature android:glesversion="0x00020000" android:required="true"/> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.access_fine_location" /> <application> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.maps.v2.api_key" android:value="@string/google_maps_key" /> <uses-library android:name="android.test.runner"/> </application> <instrumentation android:name="android.test.instrumentationtestrunner" android:label="tests com.company.app" android:functionaltest="false" android:handleprofiling="false" android:targetpackage="com.company.app"/> </manifest>
when run app (not integration testing bit) works properly, i.e. picks google play version , google maps key. however, above error when integration testing using above androidmanifest.xml.
it has got gradle using above given androidmanifest.xml generate one, in doing doesn't pick value of "@integer/google_play_services_version" rather uses literal.
any appreciated. thanks
edit
apply plugin: 'com.android.application' android { compilesdkversion 22 buildtoolsversion "22.0.1" defaultconfig { applicationid "com.minttea.halalit" minsdkversion 15 targetsdkversion 22 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } testoptions { unittests.returndefaultvalues = true } } dependencies { compile filetree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.loopj.android:android-async-http:1.4.6' compile 'com.google.android.gms:play-services:6.+' testcompile 'junit:junit:4.12' testcompile 'org.mockito:mockito-core:2.0.8-beta' testcompile 'org.json:json:20141113' androidtestcompile 'junit:junit:4.12' }
i guess it's because it's trying find these resources in test resources. quick solution, try creating res
folder under androidtest/
, duplicating requested resources there.
Comments
Post a Comment