22

I am working on an example app in Android Studio and I somehow accidentally added Google Play Services to one of my Activities. I'm not even sure how I did it, but it added several auto generated methods, variables and imports. I removed all of these and continued to work on the app. Now, a few days later, I found

compile 'com.google.android.gms:play-services-appindexing:8.1.0'

in my app/build.gradle script and an auto-generated chunk in my manifest file:

<!--
     ATTENTION: This was auto-generated to add Google Play services to your project for
     App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information.
-->
<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

under the <application> tag. When I remove them and build the project, the <meta-data> tag is regenerated in the manifest, which causes the build to fail since I removed the dependency in build.gradle.

How do I completely remove Google Play Services from the app and build system to stop this? What have I missed?

Zoe
  • 27,060
  • 21
  • 118
  • 148
rvb
  • 420
  • 1
  • 8
  • 15
  • Are you using Google's App Indexing API somewhere in your code ? – Rohan Jan 13 '16 at 05:33
  • @Rohan No. It's basically a "Hello World" app I'm using to learn Mosby. – rvb Jan 13 '16 at 05:36
  • then simply delete these above code from your project and build again – Rahul Jan 13 '16 at 05:38
  • @Rah I did but android studio keeps generating that tag in my manifest file – rvb Jan 13 '16 at 05:42
  • 5
    that means you are using wrong androidManifest.xml file, just go to src/main/androidManifest.xml file – Rahul Jan 13 '16 at 05:44
  • Ok, I restarted Android Studio a few times and now it's working again. It stopped generating that tag after the third restart. Thanks and sorry for waisting everybody's time. – rvb Jan 13 '16 at 05:47

8 Answers8

15

As @Chinmay stated, removing all references to Google Play Service/App indexing and deleting '<-path-android-project->/app/build' solved this for me, also.

Thanks

Big Rich
  • 5,864
  • 1
  • 40
  • 64
7

It just suggestion not a solution as I don't know your complete scenario. Delete all dependencies and all the build folders from your application and rebuild the project.At least It will prompt you where the play services dependency is present

Hope it will work

Chinmay
  • 423
  • 5
  • 19
  • 4
    Restarting Android Studio several times fixed the issue. I suspect that removing the `app/build` directory would have fixed it, too. Thanks! – rvb Jan 13 '16 at 05:50
  • 1
    Welcome..!! If you think it can be solved your question, you can accept my answer. Thanks for reply cheers..!! – Chinmay Jan 13 '16 at 06:31
4

I also accidentally pressed on the quickfix to add "app indexing API code", which was suggested even though it had absolutely nothing to do with my error.

What worked for me:

  • I went to VCS -> Local History -> Show History and in there I found "Insert App Indexing API Code" which I rightclicked and pressed "Revert". This removed some things, but not all, so this quickfix certainly wasn't quick to get rid off again.
  • Next I went through all my build.gradle files and inside dependencies{} I removed compile 'com.google.android.gms:play-services-appindexing:8.1.0'.
  • I removed these bits of Auto-generated code in the xml files the error led me to. They are marked with comments:

    <!--
         ATTENTION: This was auto-generated to add Google Play services to your project for
         App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information.
    -->
    
  • Lastly I removed two different build folders in my project directory. Cleaning and building the project again finally worked.

I have to add that I cleaned, rebuilt and deleted build folders several times until it finally disappeared. Thanks to previous posters about deleting those build folder!

Zoe
  • 27,060
  • 21
  • 118
  • 148
  • thanks! `Revert` on `Insert App Indexing API Code` worked. I had to do it twice. Just make sure `Undo Insert App Indexing API Code` shows up on top of the history. Once it is there, you should be able to build it – ᴛʜᴇᴘᴀᴛᴇʟ Oct 05 '16 at 17:05
2

Actually when you remove the buggy lines in your manifest file, Android Studio doesn't really remove them.

With another text editor, open (your project)\app\src\main\AndroidManifest.xml and remove <meta-data ... /> Then save the file, make sure that our build.gradle doesn't contain the play-services-appindexing dependency anymore, and rebuild your project from Android Studio.

Cyril
  • 3,048
  • 4
  • 26
  • 29
2

My results were similar to @AllBecomesGood

  1. I went into File->Settings=>Plugins and unticked:

    • Android Games
    • App Links Assistant
    • Firebase App Indexing
    • Firebase Services
    • Firebase Testing
    • Google Cloud Tools Core
    • Google Cloud Tools For Android Studio
    • Google Login
    • Google Services
  2. I then removed both the build directory within the App folder and at the root of my application.

  3. I removed the build reference to com.google.android.gms:play-services-appindexing:8.4.0 in the build.gradle for my app under dependencies. I removed the references that were auto inserting in the android manifest.

  4. Finally I had to restart Android studio before I rebuilt, otherwise it would insert into the manifest.

n0manarmy
  • 109
  • 2
  • 7
1

If you using buildToolsVersion "23.0.2"

Use new version:

compile 'com.google.android.gms:play-services-appindexing:8.4.0'

Hope this work for you

Sorry I just got it now this not answer for your question

Zoe
  • 27,060
  • 21
  • 118
  • 148
mehrdad khosravi
  • 2,228
  • 9
  • 29
  • 34
1

It's simple

  • Click right on app -> Open Modules settings
  • Click Dependency tab
  • Select play-services line
  • and click delete (small minus on top right)

That's it

Zoe
  • 27,060
  • 21
  • 118
  • 148
azuldev
  • 11
  • 1
1

Don't worry, it's easy. I had same problem and I resolved it, while deleting this line of source code from dependency.

I had installed latest Google Play Service in my Android Studio, but I was using the below line in dependency.

compile 'com.google.firebase:firebase-core:11.8.0'

Just remove this line if you are using it.

Pir Fahim Shah
  • 10,505
  • 1
  • 82
  • 81