我正在尝试构建一个使用Google Play Services作为库的Titanium Android模块。我很难把图书馆包括在内。以下是我迄今为止所尝试的:
从命令行管理项目-安卓开发者
我试着添加
android.library.reference.1=path/to/google/play/services/lib
到我的android文件夹中的build.properties,但没有用。蚂蚁没有认出它。
之后,我只是尝试将.jar文件复制到android/lib文件夹,并将res文件夹复制到platform/android/res中。这导致模块编译,但在尝试使用它时,我得到了以下错误:
[ERROR] GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
[DEBUG] AndroidRuntime: Shutting down VM
[ERROR] TiApplication: (main) [88,5294] Sending event: exception on thread: main msg:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/R$style;; Titanium 3.4.0,2014/09/25 16:42,b54c467
[ERROR] TiApplication: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/R$style;
[ERROR] TiApplication: at com.google.android.gms.wallet.fragment.WalletFragmentStyle.Z(Unknown Source)
[ERROR] TiApplication: at com.google.android.gms.wallet.fragment.WalletFragmentOptions.Z(Unknown Source)
[ERROR] TiApplication: at com.google.android.gms.wallet.fragment.SupportWalletFragment.onCreate(Unknown Source)
[ERROR] TiApplication: at android.support.v4.app.Fragment.performCreate(Fragment.java:1477)
[ERROR] TiApplication: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:904)
[ERROR] TiApplication: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
[ERROR] TiApplication: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
[ERROR] TiApplication: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
[ERROR] TiApplication: at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
[ERROR] TiApplication: at com.*snip*.onStart(InstantBuyActivity.java:104)
[ERROR] TiApplication: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
[ERROR] TiApplication: at android.app.Activity.performStart(Activity.java:5949)
[ERROR] TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
[ERROR] TiApplication: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
[ERROR] TiApplication: at android.app.ActivityThread.access$800(ActivityThread.java:144)
[ERROR] TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
[ERROR] TiApplication: at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] TiApplication: at android.os.Looper.loop(Looper.java:135)
[ERROR] TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5221)
[ERROR] TiApplication: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiApplication: at java.lang.reflect.Method.invoke(Method.java:372)
[ERROR] TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
[ERROR] TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
[ERROR] TiApplication: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.R$style" on path: DexPathList[[zip file "/data/app/*snip*"],nativeLibraryDirectories=[/data/app/*snip*/lib/arm, /vendor/lib, /system/lib]]
[ERROR] TiApplication: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
[ERROR] TiApplication: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
[ERROR] TiApplication: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
[ERROR] TiApplication: ... 23 more
[ERROR] TiApplication: Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.R$style
[ERROR] TiApplication: at java.lang.Class.classForName(Native Method)
[ERROR] TiApplication: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
[ERROR] TiApplication: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
[ERROR] TiApplication: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
[ERROR] TiApplication: ... 24 more
[ERROR] TiApplication: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
我在谷歌上发现的所有结果都表明我没有正确引用该项目,但我似乎找不到一种方法将其包含在项目中,让蚂蚁识别它,而不会给我带来一堆错误。有人在这方面取得了成功吗?
我使用Titanium Studio将google-play-services.jar添加到项目的构建路径中,并确保将实际文件复制到projector/android/lib,否则它会抱怨找不到它。