Amrmsmb
Amrmsmb

Reputation: 1

Android Studio cant resolve gradle dependencies

I've created the below App in android studio. At runtime I receive the below posted errors. I've checked the build.gradle file but I do not know whats wrong with it.

The problem is that android studio gives an error at R.layout and says: can't resolve symbol R

code:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_main);
    }
}

gradle.build:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.com.bt_11"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.+'
}

ERROR.

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.android.support:appcompat-v7:23.+.
 Required by:
     BT_11:app:unspecified
  > Could not resolve com.android.support:appcompat-v7:23.+.
     > Failed to list versions for com.android.support:appcompat-v7.
        > Unable to load Maven meta-data from https://jcenter.bintray.com/com/android/support/appcompat-v7/maven-metadata.xml.
           > Could not GET 'https://jcenter.bintray.com/com/android/support/appcompat-v7/maven-metadata.xml'.
              > Connection to https://jcenter.bintray.com refused

update: I set compileSdkVersion, targetSdkVersion to 23 and minSdkVersion = 19

and now i am getting the followin errors when tryin to run the App:

Upvotes: 0

Views: 2480

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363469

First of all update your SDK MANAGER.
It should resolve the issue that gradle is not able to resolve com.android.support:appcompat-v7:23.+.

enter image description here

Then in your build.gradle you have to change your compileSdkVersion.
The appcompat v23 requires compileSdkVersion 23

Upvotes: 0

Related Questions