简体   繁体   中英

error: resource integer/google_play_services_version (aka app:integer/google_play_services_version) not found

Getting error while compile or run the project. I want to calculate the distance which I traveled. My Android studio version is Android Studio 3.1.4

When I add following library in build.gradle(Model: app) this error will occurred.

implementation 'com.google.android.gms:play-services-location:12.0.1'

Error is getting in following file :

...\\app\\build\\intermediates\\manifests\\full\\debug\\AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="shravan.measuredistance.app"
android:targetSandboxVersion="2"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="26" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<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="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<application
    android:name="android.support.multidex.MultiDexApplication"
    android:allowBackup="true"
    android:debuggable="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:testOnly="true"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="aia-compat-api-min-version"
        android:value="1" />
    <meta-data
        android:name="android.support.VERSION"
        android:value="26.1.0" />
    <meta-data
        android:name="android.arch.lifecycle.VERSION"
        android:value="27.0.0-SNAPSHOT" />

    <activity
        android:name="shravan.measuredistance.distance.MainActivity"
        android:splitName="distance" >
        <intent-filter android:order="1" >
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />

            <data
                android:host="www.atjoin.in"
                android:pathPattern="/.*"
                android:scheme="https" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name="shravan.measuredistance.distance.LocationService"
        android:splitName="distance" />

    <activity
        android:name="com.google.android.gms.common.api.GoogleApiActivity"
        android:exported="false"
        android:splitName="distance"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
</application>

Please give me suggestion for this. Thanks.

I had the same issue. Add the Play Services library in your app gradle file. implementation 'com.google.android.gms:play-services:9.2.1' or a later version. Then rebuild.

Add this to your manifest before your package name

xmlns:tools="http://schemas.android.com/tools"

Also add the code below in your manifest after

<application
    ...............
    >
<meta-data
        tools:replace="android:value"
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

Final make sure your add Google services plugin and class path in your build.gradle

apply plugin: 'com.google.gms.google-services' (add to module)
classpath 'com.google.gms:google-services:4.0.1' (add to project)

This will ignore the clashing of google services with any other library in your project

None of the solutions helped me ,

Clearing the cache did . thanks to How to clear gradle cache?

I cleared the cache using this command:

rm -rf $HOME/.gradle/caches/

also I cleared the build dir running

./gradlew cleanBuildCache

and manually deleted the build dir

the I did run assable again and the apk got generated OK worked :)

./gradlew assemble

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM