Error:Execution failed for task ':app:preDebugAndroidTestBuild' , when tried to run java program in android studio

后端 未结 14 1211
渐次进展
渐次进展 2021-02-13 03:03

Getting the below error at the time of running java program in android studio.

Error:Execution failed for task \':app:preDebugAndroidTestBuild\'.

<
14条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-13 03:40

    Well, I too faced the same problem here is how I fixed it

    • Goto app level Gradle file

    There you will find what are all the config's you have set up. In my case here

    android{
        **compileSdkVersion 26**
        defaultConfig {
            applicationId "com.xxxxxxxxxxx.yyyyyyyy.zzz"
            minSdkVersion 19
            **targetSdkVersion 26**
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        **implementation 'com.android.support:appcompat-v7:26.1.0'**
        implementation 'com.android.support.constraint:constraint-layout:1.1.2'
        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'
    }
    

    So here just change the compileSdkVersion & targetSdkVersion from 26 to 27 and

    from dependencies change support appcomat

    from   implementation 'com.android.support:appcompat-v7:26.1.0' 
    to     implementation 'com.android.support:appcompat-v7:27.1.1'
    
    
    android {
        **compileSdkVersion 27**
        defaultConfig {
            applicationId "com.xxxxxxxxxxx.yyyyyyyy.zzz"
            minSdkVersion 19
            **targetSdkVersion 27**
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        **implementation 'com.android.support:appcompat-v7:27.1.1'**
        implementation 'com.android.support.constraint:constraint-layout:1.1.2'
        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'
    }
    

    Got Fixed !!!

提交回复
热议问题