Quick summary: I am trying to do integration testing using gradlew connectedAndroidTest on Android Studio 1.2.2 but I get the following error:
Position 28:28-65 : No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
Position 31:28-51 : No resource found that matches the given name (at 'value' with value '@string/google_maps_key').
Full story: I have two different AndroidManifest.xml, one for release and one for integration/instrumentation testing.
I execute my instrumentation tests using:
gradlew connectedAndroidTest
This uses AndroidManifest.xml located at .../src/androidTest/ and builds and runs the android tests. It looks like 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 for com.company.app"
android:functionalTest="false"
android:handleProfiling="false"
android:targetPackage="com.company.app"/>
</manifest>
When I run the app by itself (not the integration testing bit) it works properly, i.e. it picks up the google play version and the google maps key. However, I get the above error when I do integration testing using the above AndroidManifest.xml.
It has got something to do with gradle using the above given AndroidManifest.xml to generate another one, but in doing so it doesn't pick up the value of "@integer/google_play_services_version" but rather just uses it as a literal.
Any help would be much 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'
}