1

Im trying to go through this tutorial Android Implementing Preferences Settings Screen

He imports android.support.v7... and android.suppor.annotation libary...

I did the most suggested answer and implemented these packages to my build.gradle and resynced it.

Android studio can't resolve v7 and annotations.

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;

gradle.build:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "info.androidhive.preferences"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.android.support:appcompat-v7:+'
}

I expected, that after resyncing the libarys would be available and not the error message

cant resolve symbol v7 for instance.

Thanks for help.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
NobodyIsPerfect
  • 182
  • 1
  • 12

1 Answers1

3

You are using androidx: implementation 'androidx.appcompat:appcompat:1.0.2'.

In your code you have to import the correct class:

import androidx.appcompat.widget.Toolbar;

Also remove in your build.gradle

//implementation 'com.android.support:appcompat-v7:+'

For the annotations use:

androidx.annotation:annotation:1.1.0
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841