title: Can't import android.support.v7 (appcompat) - Unresolved Library
body: <p>I tried to import this support library into my project but can't get it to work. </p>
  
  <p>First of all I can't find it. When I hit the + button on the Dependencies tab and search for it. I have found android.support.v4 but I need v7 as well.
  I read somewhere that the library might be deprecated.</p>
  
  <p>So in my code it can't import android.support.v7.widget.ShareActionProvider
  The v7 is in Red because, it can't be resolved.
  I followed the direction on how to add a library. But still can't solve the issue. I did normal steps as clean, sync gradle files, invalidate links, etc...</p>
  
  <p>Here is some of my code from mainactivity</p>
  
  <pre><code>    import android.content.Intent
      import android.os.Bundle
      import android.support.v4.view.MenuItemCompat
      import android.view.Menu
      import android.view.MenuItem
      //import androidx.appcompat.widget.ShareActionProvider
      import androidx.appcompat.widget.Toolbar
  
      //import androidx.core.view.MenuItemCompat
      //import android.support.v4.view.MenuItemCompat
      //import androidx.core.view.MenuItemCompat.getActionProvider
  
      import android.support.v7.app.AppCompatActivity
      import android.support.v7.widget.ShareActionProvider
      //import android.widget.ShareActionProvider
  
  
  
      class MainActivity : AppCompatActivity() {
          private var shareActionProvider : ShareActionProvider? = null
  
      import android.content.Intent
      import android.os.Bundle
      import android.support.v4.view.MenuItemCompat
      import android.view.Menu
      import android.view.MenuItem
      //import androidx.appcompat.widget.ShareActionProvider
      import androidx.appcompat.widget.Toolbar
  
      //import androidx.core.view.MenuItemCompat
      //import android.support.v4.view.MenuItemCompat
      //import androidx.core.view.MenuItemCompat.getActionProvider
  
      import android.support.v7.app.AppCompatActivity
      import android.support.v7.widget.ShareActionProvider
      //import android.widget.ShareActionProvider
  
  
      class MainActivity : AppCompatActivity() {
          private var shareActionProvider : ShareActionProvider? = null
  
          override fun onCreate(savedInstanceState: Bundle?) {
              super.onCreate(savedInstanceState)
              setContentView(R.layout.activity_main)
              val toolbar = findViewById(R.id.toolbar) as Toolbar
              setSupportActionBar(toolbar)
          }
  
          override fun onCreateOptionsMenu(menu : Menu): Boolean {
              getMenuInflater().inflate(R.menu.menu_main, menu)
              val menuItem = menu.findItem(R.id.action_share) as MenuItem
              shareActionProvider = MenuItemCompat.getActionProvider(menuItem) as ShareActionProvider
              setShareActionIntent("Want to join me for pizza?")
              return super.onCreateOptionsMenu(menu)
          }
  
          private fun setShareActionIntent(text : String) {
              val intent = Intent(Intent.ACTION_SEND)
              intent.type = "text/plain"
              intent.putExtra(Intent.EXTRA_TEXT, text)
              shareActionProvider!!.setShareIntent(intent)
          }
  
          override fun onOptionsItemSelected(item : MenuItem) : Boolean {
              when(item.itemId) {
                  R.id.action_create_order -&gt; {
                      val intent = Intent(this, OrderActivity::class.java)
                      startActivity(intent)
                      return true
                  }
                  else -&gt; return super.onOptionsItemSelected(item)
              }
  }
  }
  </code></pre>
  
  <p>This my gradle.build file</p>
  
  <pre><code> // Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      ext.kotlin_version = '1.2.71'
      repositories {
          google()
          jcenter()
          maven { url '../pluginrepo' }
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.2.0-beta05'
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          google()
          jcenter()
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p>This is my app (build.gradle) file</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  apply plugin: 'kotlin-android'
  
  apply plugin: 'kotlin-android-extensions'
  
  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "com.gandalf.bitsandpizza"
          minSdkVersion 19
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
      //    implementation 'com.android.support:support-core-utils:27.0.0'
      implementation 'com.google.android:support-v4:r7'
      implementation 'com.android.support:appcompat-v7:28.0.+'
      //    implementation 'com.android.support:appcompat-v7:27.1.1'
      implementation 'com.android.support:support-core-utils:28.0.+'
  }
  </code></pre>
  
  <p>This is based on Refactoring suggested in answer.</p>
  
  <p>The issue is now resolved. This is the updated gradle.build file from app</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  apply plugin: 'kotlin-android'
  
  apply plugin: 'kotlin-android-extensions'
  
  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "com.some.name"
          minSdkVersion 19
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      implementation 'com.android.support:appcompat-v7:28.0.0'
      implementation 'com.android.support.constraint:constraint-layout:1.1.3'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  }
  </code></pre>