我正在尝试使用新的 Google Invitation api,但在尝试发送邀请时遇到了异常。我已将此添加到我的 gradle 文件中:
compile 'com.google.android.gms:play-services-appinvite:7+'
我的代码编译得很好。不知道出了什么问题。这是一个例外:
Process: mypackage, PID: 17623
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/appinvite/AppInviteInvitation$IntentBuilder;
at mypackage.MyActivity.sendInvitation(MyActivity.java:452)
at mypackage.MyActivity$35.share(MyActivity.java:2749)
at mypackage.dialogs.VideoListDialog$VideoListAdapter$ViewHolder.onClick(VideoListDialog.java:236)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.appinvite.AppInviteInvitation$IntentBuilder" on path: DexPathList[[zip file "/data/app/mypackage-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at mypackage.MyActivity.sendInvitation(MyActivity.java:452)
at mypackage.MyActivity$35.share(MyActivity.java:2749)
at mypackage.dialogs.VideoListDialog$VideoListAdapter$ViewHolder.onClick(VideoListDialog.java:236)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.appinvite.AppInviteInvitation$IntentBuilder
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available