Gradle not fetching metadata correctly from AndroidManifest.xml when using integration testing
Quick summary: I am trying to do integration testing with gradlew connectedAndroidTest on Android Studio 1.2.2, but I am getting 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 testing / testing.
I am running my benchmarks using:
gradlew connectedAndroidTest
This uses AndroidManifest.xml located at ... / src / androidTest / and builds and runs tests on Android. 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 application myself (not the integration testing bit) it works correctly, i.e. it displays google game version and google map key. However, I get the above error when I do integration testing using the above AndroidManifest.xml.
It has something to do with gradle, using the aforementioned AndroidManifest.xml to create another, but it doesn't get the value "@ integer / google_play_services_version", but just uses it as literal.
Any help would be much appreciated. Thanks to
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'
}
source to share