ActivityCompat error (Cannot resolve symbol)

buydadip

In my react-native application, I need to get location permission from the user, so I added this in one of the Activity classes...

public void onCreate() {
    ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}

However, I get a cannot resolve symbol error for both ActivityCompat and Manifest.

After doing some research I found out you need to add the following to the gradle.build file compile 'com.android.support:support-v4:23.0.0'

So I did that...

dependencies {
    compile project(':react-native-maps')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.android.support:support-v4:23.0.0'
}

But I still get the same errors. I tried clean still nothing. I also tried restarting Android Studio File > Invalidate Caches/Restart, still get the errors.

How do I fix these errors?

Vyacheslav

in gradle file set the latest API and build levels:

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

and use

compile 'com.android.support:appcompat-v7:+'

here you can use the other approach: https://stackoverflow.com/a/32062974/1979882

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive