When using integration testing, gradle cannot get metadata correctly from androidmanifest.xml
Quick summary: I'm trying to use gradlew connectedandroidtest on Android studio 1.2.2 for integration testing, but I received 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 text: I have two different androidmanifest.xml, one for publishing and one for integration / detection testing
I perform instrument tests using the following methods:
gradlew connectedAndroidTest
This uses androidmanifest.xml located in... / SRC / Android test /, and builds and runs the Android test. 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 alone (instead of the integration test bit), it works normally, that is, it can obtain the Google play version and Google Maps key. However, when I use the above androidmanifest.xml for integration test, I get the above error
It is related to gradle and uses the androidmanifest.xml given above to generate another one, but in doing so, it will not get the value of "@ integer / google_play_services_version", but just use it as composition
Any help will be appreciated. Thank you
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'
}
resolvent:
I think this is because it tries to find these resources in the test resources. As a quick solution, try to create the res folder under Android test / and copy the requested resources there
