Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActivityCompat error (Cannot resolve symbol)

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?

like image 477
buydadip Avatar asked Dec 04 '16 18:12

buydadip


1 Answers

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

like image 85
Vyacheslav Avatar answered Nov 11 '22 10:11

Vyacheslav