Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Google Play Services Interacting with Google+ APIs Setup the PlusOneButton

Pablo Rocha
Pablo Rocha
10,142 Points

I do not get "intellisense-like" auto complete when defining the attributes for any com.google.android defined tag?

I don't get "intellisense-like" auto complete when defining the attributes for any com.google.android defined tag, is there some extra step I have to perform to get that?

2 Answers

Harry James
Harry James
14,780 Points

Hey Pablo!

I seem to have reproduced your problem at a bit of testing.

Can you try closing down all open code windows and then running an Invalidate and Restart. After that, open up the layout_listing.xml file again.


Let me know how it goes! :)

Pablo Rocha
Pablo Rocha
10,142 Points

Still not getting it. What did you do to reproduce it?

Harry James
Harry James
14,780 Points

Well I'm not exactly sure how I did get there in the end.

I tried deleting the cache file under Recommendations\build\intermediates\dex-cache which seemed to flag up the issue but even after replacing the file again I still was unable to get the correct content assist results (I would get something about a namespace template when typing an...)

It looks like this is a bug with Android Studio and is difficult to reproduce - if it's not causing a big deal then I wouldn't worry about it too much and just hope that it gets resolved in the future. I'll see if I can find a way to reproduce my fix again tomorrow but can't promise anything!

Pablo Rocha
Pablo Rocha
10,142 Points

Thanks so much for looking into this Harry James. I will look into it some more as well and update you if I find a solution.

Harry James
Harry James
14,780 Points

Hey Pablo!

The content assistant should come up with the tag. If it doesn't come up at all, you can activate it again with Ctrl+Space.

If even then no tags are displayed, it's likely because you don't have the dependency for Google Play Services. Make sure you have this line in your build.gradle file for the app module under dependencies:

compile 'com.google.android.gms:play-services-plus:7.8.0'

After that, run a Gradle sync by clicking its button on the Toolbar:

Wait for the sync to complete and then try again.


If you're still having problems after this, give me a shout and I'll see what else can be done :)

Pablo Rocha
Pablo Rocha
10,142 Points

Thanks for answering Harry James.

I do have the dependency synced and tried hitting Ctrl+Space. I have already built and run the project and it runs just fine. However if I go back to the layout file I still do not get the content assist. Very strange. I assume it has something to do with some settings I have somewhere, since the tag is coming from a gradle dependency it is not loading it into the content assist compiler.

Pablo Rocha
Pablo Rocha
10,142 Points

There is a rendering problem in the Design view, not sure if that is related.

java.lang.NullPointerException
    at com.google.android.gms.plus.PlusOneDummyView$zzb.isValid(Unknown Source)
    at com.google.android.gms.plus.PlusOneDummyView.zzyF(Unknown Source)
    at com.google.android.gms.plus.PlusOneDummyView.<init>(Unknown Source)
    at com.google.android.gms.plus.internal.zzg.zza(Unknown Source)
    at com.google.android.gms.plus.PlusOneButton.zzah(Unknown Source)
    at com.google.android.gms.plus.PlusOneButton.<init>(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:437)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:154)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:93)
Harry James
Harry James
14,780 Points

Hey again Pablo!

The rendering problem is normal as it's not built-in to Android Studio, and it therefore does not know how to render it.

The fact that it does not come up in the Content Assist however, is not.

Are you able to run your project with the +1 button completely fine? Is it just that the Content Assist for whatever reason does not come up with it as an option and you have to type the full tag out?

Pablo Rocha
Pablo Rocha
10,142 Points

That is correct, I can use all in app features and everything works like it is supposed to. It is just the content assist does not work for any com.google prefixed tab.

It is not a big deal, it just requires more typing (or cut and pasting). I thought it was odd though since in the video they are getting the content assist.

Harry James
Harry James
14,780 Points

Interesting. It should come up after a Gradle Sync so I'm not sure what's hiding it. There isn't an option in the settings to limit this (Either Content Assist is enabled or it's not).

Have you tried Invalidating Android Studio's caches and restarting?:

To do this, click on the File tab then Invalidate Caches / Restart and press Invalidate and Restart:

Let me know if that makes any difference or not.

Pablo Rocha
Pablo Rocha
10,142 Points

That didn't do the trick :(

I also get no suggestions when I click Ctrl+space.

Harry James
Harry James
14,780 Points

Hey again Pablo!

Do you have Power Save Mode enabled under the File menu?

Pablo Rocha
Pablo Rocha
10,142 Points

Hey Harry - power save mode is off.