简体   繁体   中英

How to add Google Play Services dependency to Android makefile?

I use Google Play Services as referenced project. Can anyone guide me how properly add it to my project Android.mk to get all build work done? Without referenced project use all is done fine.

Now the following errors happen (see build log below):

MapLocator/src/com/maplocator/MapFragment.java:13: package com.google.android.gms.common does not exist
        import com.google.android.gms.common.ConnectionResult;

MapLocator/src/com/maplocator/MapFragment.java:56: cannot find symbol
    symbol  : class GoogleMap
    location: class com.maplocator.MapFragment
        private GoogleMap mMap;

... and etc.

The answer is simple you have to generate correct JAR library with Eclipse export tools and define it as prebuilded java static libraries in Android.mk:

#Google Play Services
LOCAL_STATIC_JAVA_LIBRARIES += googleplayservices \
                                googleplayservices_lib
...
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += googleplayservices:libs/google-play-services.jar \
                                        googleplayservices_lib:libs/google-play-services_lib.jar

See details here: How to solve java.lang.NoClassDefFoundError for com.google.android.gms.R$styleable error?

Right click on project and select properties. In the properties window on left side select Android. On the right you can see a Add button under library section. Click it and select google play services project which you might have imported previously .

Also add the below in the Android Manifest xml file

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

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