Gradle无法在IntelliJ中同步问题

时间:2019-08-05 10:54:49

标签: android intellij-idea

我确信INtelliJ中有很多关于Gradle同步问题的帖子,但是通常都存在各种错误。

我正在尝试在移动应用程序上运行自动化测试,但是尽管根据StackOverflower同事的建议升级了所有可能的库,但仍然遇到以下问题。

主要代码:

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">Testing documentation</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.gradle

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:29+'
    implementation 'androidx.appcompat.appcompat:1.0.0'
    //implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation 'androidx.annotation:annotation:1.1.0'
    //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'
    }
}

当我尝试运行主代码时,错误消息如下 enter image description here

希望对这个困扰我的问题提出建议。

1 个答案:

答案 0 :(得分:1)

尝试

    //noinspection GradleCompatible