Q:

Issues with dependencies in Android Studio

I am very new to developing in Android and I am trying to develop test automation for Android apps. When I run my test, I keep hitting the unable to resolve dependency issues. My attached code is an attempt to just click on the login button of the app. Here is my code :
Main app:
package com.example.test;
import io.appium.java_client.android.AndroidDriver;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a 
href="http://d.android.com/tools/testing">Testingdocumentation</a>
 */
//@RunWith(AndroidJUnit4.class)

public class ExampleInstrumentedTest {
    private AndroidDriver driver;
    @Before
    public void setup() throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "emulator-5444");
        capabilities.setCapability("platFormName","Android");           
        capabilities.setCapability("appPackage",
        "com.mol.molwallet.uat");

        capabilities.setCapability
        ("appActivity","com.mol.molwallet.start.SplashActivity");
        capabilities.setCapability("noReset","true");

        driver = new AndroidDriver(new URL 
        ("http://127.0.0.1:4725/wd/hub"),capabilities);
   }
   @Test
   public void myFirstTest() {
       //Context of the app under test.
       driver.findElement(By.xpath("//*[@text='LOG IN']")).click();
       //assertEquals("com.example.test", appContext.getPackageName());
   }
}

App/Build.Gridle:
apply plugin: 'com.android.application'
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:+'
    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'
    androidTestImplementation 'com.android.support:support-annotations:24.0.0'
    implementation("com.android.support:support-v4:27.1.1")
    //implementation project(':react-native-fast-image')

}
if(hasProperty('buildScan')){
    buildScan {
        termsOfServiceUrl = 'https://gradle.com/terms-of-service';
        termsOfServiceAgree = 'yes'
    }
}

Project/Build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

        // 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
}

Upon running, I get the following errors
"build.gradle: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
<a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Could not find any version that matches com.android.support:appcompat-v7:29.+.">Show Details</a>
Affected Modules: <a href="openFile:C:/Users/chiomeng.lam/IntelliJIDEAProjects/Test/app/build.gradle">app</a>"

Base on the error, I kind of get the impression that some version is mismathc. But my problem is, what version of what is mismatched. 

A:

You are using compileSdk 29 , for sdk 29 there is no version of support libraries since it has been moved to AndroidX libraries.
Goto Menu bar in Android Studio, Select Refactor then Migrate to AndroidX, that should solve the issue.

If you need a temporary solution, you can change compileSdk to 27, however you won't be able to publish it on PlayStore until you change to Sdk 29 if your app hasn't already been published. As per requirements:

Starting August 1, 2019, Google Play requires that new apps target at least Android 9.0 (API level 28), and that app updates target Android 9.0 from November 1, 2019. Until these dates, new apps and app updates must target at least Android 8.0 (API level 26).
Note: With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack. The AndroidX library contains the existing support library and also includes the latest Jetpack components.
You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.*) will remain available on Google Maven. However, all new library development will occur in the AndroidX library. We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well.

If any issues pop up during refactoring, take a look at this refactoring page and replace the any packages you are already using with new ones as given in this list:
https://developer.android.com/jetpack/androidx/migrate#artifact_mappings

