I'm trying to use the new Google Invitation api and I am getting an exception when trying to send an invite. I have added this to my gradle file:
compile 'com.google.android.gms:play-services-appinvite:7+'
And my code compiles fine. Not sure what's wrong. Here is the exception:
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
Looks like I missed two parts from the instructions:
Add the dependency to your project's top-level build.gradle:
classpath 'com.google.gms:google-services:1.3.0-beta1'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'