1

Note: I was working on the project and building it from time to time. It was working fine, until recently all of my projects started showing a "missing permission error" but I've mentioned permission in the AndroidManifest file already for the projects.

Project 1 :

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.firstproject">

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        ////other code

</manifest>

missing permission error in first project

Why I need permission / permission check:

error-at(1)

error-at(2)

error-at(3)

error-at(4)

missing permission error

build.gradle (:app) (first project):

dependencies {
implementation platform('com.google.firebase:firebase-bom:28.1.0')
implementation "androidx.cardview:cardview:1.0.0"
implementation "com.google.android.material:material:1.3.0"
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.firebaseui:firebase-ui-database:6.2.1'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-database:20.0.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.karumi:dexter:6.1.2'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.firebase:geofire-android:3.0.0'
}

Same error occurs in my second project.

Second Project: missing permission error in second project

AndroidManifest.xml file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.driver">
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
//other stuff

The Project builds log:

Starting Gradle Daemon...
Gradle Daemon started in 3 s 90 ms

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguid/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 34s

What happens if I run this project with the error: It doesn't asks for my permission but shows the permission in the Setting -> Apps permission showing in the setting

What I already tried:

  1. Rebuilding the project
  2. Cleaning the project
  3. Upgrading the Gradle
  4. Deleting the project and building the backup version(one commit revert as I use github)
Dennis Kozevnikoff
  • 2,078
  • 3
  • 19
  • 29
baxsm
  • 56
  • 8

2 Answers2

1

After many hours of research and trying new things out, I found out that my AndroidManifest.xml was not merging files and it was happening for all of my projects.

I can't find the answer to why it was happening but it was the reason why the permission inside the AndroidManifest.xml was not working.

The things I did to solve that issue

  1. Delete the Android Studio directory at E:/Android Studio (custom)
  2. Delete the .android directory at C:/Users/UserName/.android (default)
  3. Delete the .gradle directory at C:/Users/UserName/.gradle (default)
  4. Install new Android Studio

After that all the previous projects were working fine

Note: To view the Directory (e.g .android) make sure that "show hidden files/folders" is enabled

baxsm
  • 56
  • 8
0

It's an easy fix, Android studio will automatically generate some code with return statement. Which will check the permission if granted then, the next line of code will be executed else you ask permission at runtime if granted and rerun the same yourgetLocationmethod();

This link will be helpful

enter image description here

Rohaitas Tanoli
  • 624
  • 4
  • 16