简体   繁体   中英

Which dependency is required for Awareness API?

I want to check out the new Awareness API which is quite new. I'm using Play Services 9.0.2. The documentation has this example :

GoogleApiClient client = new GoogleApiClient.Builder(context)
        .addApi(Awareness.API)
        .build();
client.connect();

However, there is no hint which dependency needs to been added. Any idea?

I found it out: I need to upgrade to PlayServices 9.2.0 and the dependency is hidden in play-services-contextmanager . Just add those dependencies and here we go:

compile 'com.google.android.gms:play-services-awareness:10.2.4'

Please use the latest play services library, at the time I updated this answer it was 10.2.4

If you want to know the latest Dependency you can use my web tool called DependencyLookup .

Keep in mind that this library was added in the Play Services Repository v31. Make sure that you have at least that version installed in the SDK manager.

You need to add the library of Google Play services to your project.

Set up Google Play services

To access the Awareness API, your app's development project must include Google Play services. Download and install the Google Play services component via the SDK Manager and add the library to your project. For details, see the Android guide to setting up Google Play services.

Source

Set up Google Play services

To access the Awareness API, your app's development project must include Google Play services. Download and install the Google Play services component via the SDK Manager and add the library to your project. For details, see the Android guide to setting up Google Play services .

which is apparently on the same page you got your code sample from here

Most of the times the number of method references in your app exceeds the 65K limit, your app may fail to compile. So in order to mitigate this problem when compiling your app ,specify only the specific Google Play services APIs your app uses, instead of all of them.

compile 'com.google.android.gms:play-services-basement:9.2.0'
compile 'com.google.android.gms:play-services-contextmanager:9.2.0'

You will find the complete solution here: http://xordroid.com/create-intelligent-apps-with-google-awareness-api/

Starting PlayServices v9.6.0, contextmanager has been changed to awareness

So, the previous answers won't be working.

The correct dependencies, as of v10.2.4 are

compile 'com.google.android.gms:play-services-basement:10.2.0'
compile 'com.google.android.gms:play-services-awareness:10.2.0'

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