1

I use google-play-services_lib library for one of my projects. Everything builds beautifully in eclipse. Now I want to write an Android.mk file to build my project automatically.

Following the instruction here , I have added LOCAL_LDLIBS to Android.mk, by putting google-play-services_lib library project to the libs folder of my project, but it's not working.

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := GoogleReviews

LOCAL_LDLIBS := -L/libs/google-play-services_lib

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)

include $(BUILD_MULTI_PREBUILT)

Since, the library is not detected correctly from Android.mk, following exceptions I get during compilation, which refer to these missing classes in the google-play-services_lib library.

packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:36: package com.google.android.gms.auth does not exist
import com.google.android.gms.auth.GoogleAuthUtil;
                              ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:37: package com.google.android.gms.common does not exist
import com.google.android.gms.common.AccountPicker;
                                ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:38: package com.google.android.gms.common does not exist
import com.google.android.gms.common.ConnectionResult;
                                ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:39: package com.google.android.gms.common does not exist
import com.google.android.gms.common.GooglePlayServicesUtil;
                                ^
Copying: out/target/common/obj/JAVA_LIBRARIES/jp.co.sharp.android.model.orange_sh70f_intermediates/noproguard.classes.dex
target Jar: jp.co.sharp.android.model.orange_sh70f (out/target/common/obj/JAVA_LIBRARIES/jp.co.sharp.android.model.orange_sh70f_intermediates/javalib.jar)
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:110: cannot find symbol
symbol  : variable AccountPicker
location: class com.example.appreviews.ReviewScreen
        Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                    ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:132: cannot find symbol
symbol  : variable GooglePlayServicesUtil
location: class com.example.appreviews.ReviewScreen
        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
                 ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:134: cannot find symbol
symbol  : variable ConnectionResult
location: class com.example.appreviews.ReviewScreen
        case ConnectionResult.SUCCESS:
             ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:138: cannot find symbol
symbol  : variable ConnectionResult
location: class com.example.appreviews.ReviewScreen
        case ConnectionResult.SERVICE_MISSING:
             ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:141: cannot find symbol
symbol  : variable ConnectionResult
location: class com.example.appreviews.ReviewScreen
        case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
             ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:145: cannot find symbol
symbol  : variable ConnectionResult
location: class com.example.appreviews.ReviewScreen
        case ConnectionResult.SERVICE_DISABLED:
             ^
packages/apps/GoogleReviews/src/com/example/appreviews/ReviewScreen.java:261: cannot find symbol
symbol  : variable GoogleAuthUtil
location: class com.example.appreviews.ReviewScreen
            GoogleAuthUtil.invalidateToken(this, token);
            ^
11 errors

What need to be done, such that I can get rid of this error.

Any help is much appreciated.

Community
  • 1
  • 1
user264953
  • 1,837
  • 8
  • 37
  • 63

2 Answers2

1

Try this:

LOCAL_STATIC_JAVA_LIBRARIES := libgoogleplay

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libgoogleplay:your google play library

anz
  • 1,317
  • 2
  • 13
  • 25
0

I am using the NDK through VisualGDB.

The way I seem to have gotten it to work is adding to the project.properties file.

I did what Google's Android documentation seemed to suggest for Google Play Services and copied it from the SDK's location into a different location (but not my project directory). At the time it was located in {android-sdk}\extras\google\google_play_services\libproject

I manually edited the project.properties file and added a relative path (an absolute path wasn't working) to the directory I created.

android.library.reference.1=<relative/path/to/my/google-play-services_lib>

(.1 being my first reference to an external library)

I then followed the SettingUpLibraryProject instructions here: http://developer.android.com/tools/projects/projects-cmdline.html#SettingUpLibraryProject

This ended up creating a bunch of files the build processes needed. After that everything built fine.

drs
  • 5,679
  • 4
  • 42
  • 67
RobGold
  • 39
  • 4