在Android.mk中添加库路径 - google-play-services_lib

时间:2013-06-08 15:27:27

标签: android android-ndk android-build

我在其中一个项目中使用google-play-services_lib库。在日食中,一切都建立得很漂亮。现在我想编写一个Android.mk文件来自动构建我的项目。

按照here说明,我已将LOCAL_LDLIBS添加到Android.mk,方法是将google-play-services_lib库项目添加到项目的libs文件夹中,但它无效。

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)

因为,在编译过程中遇到的异常之后,Android.mk无法正确检测到库,这些异常引用了google-play-services_lib库中缺少的类。

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

需要做什么,以便我可以摆脱这个错误。

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:1)

试试这个:

LOCAL_STATIC_JAVA_LIBRARIES:= libgoogleplay

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:= libgoogleplay:您的Google Play图书馆

答案 1 :(得分:0)

我通过VisualGDB使用NDK。

我似乎已经开始工作的方式是添加project.properties文件。

我做了Google的Android文档似乎为Google Play服务建议的内容,并将其从SDK的位置复制到另一个位置(但不是我的项目目录)。当它位于{android-sdk}\extras\google\google_play_services\libproject

我手动编辑了project.properties文件,并在我创建的目录中添加了相对路径(绝对路径无效)。

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

(。1是我对外部库的第一次引用)

然后我按照 SettingUpLibraryProject 说明进行操作:http://developer.android.com/tools/projects/projects-cmdline.html#SettingUpLibraryProject

最终创建了构建过程所需的一堆文件。之后一切都很好。