1

private android.support.v7.widget.Toolbar toolbar; gives an error "Cannot resolve symbol v7" , i tried implementation in gradle but didn't work , please help

i will provide images and code bellow

TOOLBAR XML CODE

SOCIAL MEADIA CLASS XML

SOCIAL MEDIA JAVA CLASS

GRADLE DEPENDENCIES

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.24.1"
implementation 'com.github.Shashank02051997:FancyToast-Android:0.1.6'

implementation 'com.android.support:design:+'
implementation 'com.android.support:appcompat-v7:29.0.3'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'

XML CODE

?xml version="1.0" encoding="utf-8"?

android.support.v7.widget.Toolbar

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/myToolbar"
android:background="@color/colorPrimaryDark"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

android.support.v7.widget.Toolbar

JAVA CLASS

public class SocialMediaActivity extends AppCompatActivity {

private android.support.v7.widget.Toolbar toolbar;
private ViewPager viewPager;
private TableLayout tableLayout;
private TabAdapter tabAdapter;

public SocialMediaActivity() {
}

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

}

archi noris
  • 39
  • 2
  • 6

2 Answers2

5

The v7 support library does not appear in your dependencies in your gradle file. The v7 support library has been deprecated. You should use androidx.appcompat.widget.Toolbar. See: https://developer.android.com/jetpack/androidx. You have the dependency androidx.appcompat:appcompat:1.1.0 in your gradle file, so you'll have access to the androidx toolbar.

codebod
  • 686
  • 6
  • 17
1

While using androidX you need to use androidx.appcompat.widget.Toolbar for toolbar. And add implementation 'androidx.appcompat:appcompat:1.1.0' to app level gradle file.

Upendra Shah
  • 2,218
  • 17
  • 27