25

When I write code about firebase analytics like FirebaseAnalytics.getInstance() I get a warning message:

Missing permissions required by FirebaseAnalytics.getInstance: android.permission.ACCESS_NETWORK_STATE and android.permission.WAKE_LOCK

Here is the screenshot:

enter image description here

I didn't found anything about this by googling.

I also tried cleaning and rebuilding my project. Restarting Android studio. Nothing worked.

What's the issue?

Edit: Permissions are there. I can see those in the merged manifest. But still gives the error.

enter image description here

kirtan403
  • 7,293
  • 6
  • 54
  • 97
  • You can ignore the warning. `ACCESS_NETWORK_STATE` and `WAKE_LOCK` is Normal Permissions and not required to ask on Run-Time. [Docs](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous) – Ankur Jain Nov 08 '16 at 13:18
  • @AnkurJain But they should be in the manifest files. Else this won't work as intended – kirtan403 Nov 08 '16 at 13:21
  • Yes ,you need to add these permissions in Manifest. – Ankur Jain Nov 08 '16 at 13:22
  • @AnkurJain It should be merged by manifest merger. They should be in the analytics sdk. I don't know its Android Studio issue or manifest merger or sdk – kirtan403 Nov 08 '16 at 13:23
  • No, you need to add these permissions in your app manifest. They are not included in analytics manifest. – Ankur Jain Nov 08 '16 at 13:26
  • @AnkurJain I don't think so. All sdks includes the permissions and are merged by the manifest merger. – kirtan403 Nov 08 '16 at 13:27
  • What version of Android Studio are you using? – Bob Snyder Nov 08 '16 at 15:38
  • @qbix 2.2.1 latest – kirtan403 Nov 08 '16 at 15:54
  • I don't see the warning with version 2.2.2, although I doubt it's just a version issue. – Bob Snyder Nov 08 '16 at 16:00
  • @qbix I chcecked today it was the latest. Sorry. I am not currently in front of laptop. So it should be 2.2.2 (latest) – kirtan403 Nov 08 '16 at 16:01
  • @qbix I confirm its 2.2.2. – kirtan403 Nov 09 '16 at 06:03
  • Maybe an experiment will produce some clues. Use the Android Studio New Project wizard to create a simple project: File > New > New Project. The created project will have the default settings and build configuration. Add the call to `FirebaseAnalytics.getInstance(this)` in the `onCreate()` method of the main activity. If you don't see the lint warning, compare your app settings and configuration with the test app. – Bob Snyder Nov 09 '16 at 14:21
  • @qbix I have created a test project and tried doing the same as you mentioned. I got the same error again. No luck. – kirtan403 Nov 11 '16 at 10:33
  • Sorry--I don't know what else to suggest. – Bob Snyder Nov 11 '16 at 15:30
  • 1
    @qbix Thanks for helping :) However, suddenly It disappeared after I modified by gradle.properties file. It was like I wasn't even doing anything and suddenly the red underline gone! Finally! – kirtan403 Nov 12 '16 at 05:13

1 Answers1

15

Add

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

to your Manifest file

Android Studio doesn't look in imported lib's manifests. It's just an IDE error. You can disable the inspection

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
Ognian Gloushkov
  • 2,669
  • 1
  • 20
  • 35