我正在学习质量检查,但遇到了这些错误,我似乎找不到解决方法

    Default interface methods are only supported starting with Android N (--min-api 24): java.lang.Object org.openqa.selenium.remote.session.CapabilitiesFilter.apply(java.lang.Object)

    Default interface methods are only supported starting with Android N (--min-api 24): java.lang.String org.openqa.selenium.Capabilities.getBrowserName()

    Default interface methods are only supported starting with Android N (--min-api 24): java.lang.Object org.openqa.selenium.firefox.XpiDriverService$ThrowingSupplier.get()

        Default interface methods are only supported starting with Android N (--min-api 24): java.lang.Object org.openqa.selenium.json.JsonInput$VoidCallable.call()

    Invoke-customs are only supported starting with Android O (--min-api 26)
    InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
    Default interface methods are only supported starting with Android N (--min-api 24): void com.google.common.collect.RangeSet.addAll(java.lang.Iterable)
    Default interface methods are only supported starting with Android N (--min-api 24): java.util.Set com.google.common.collect.RowSortedTable.rowKeySet()
    Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values()
    Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.ListMultimap.get(java.lang.Object)
    Default interface methods are only supported starting with Android N (--min-api 24): boolean com.google.common.base.Predicate.test(java.lang.Object)
    null
    com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Pierre Abi Chacra\Desktop\androidwidget\AppiumTest\app\libs\client-combined-3.12.0.jar
    com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
    com.android.tools.r8.CompilationFailedException: Compilation failed to complete
    com.android.tools.r8.utils.AbortException


这是我的代码:

 package com.example.pierreabichacra.appiumtest;
    import java.net.MalformedURLException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.concurrent.TimeUnit;

    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;



    public class FirstTest {

        WebDriver driver;

        @Before
        public void setUp() throws MalformedURLException {
            // Created object of DesiredCapabilities class.
            DesiredCapabilities capabilities = new DesiredCapabilities();

            // Set android deviceName desired capability. Set your device name.
            capabilities.setCapability("deviceName", "XT1562");

            // Set BROWSER_NAME desired capability. It's Android in our case here.
            capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");

            // Set android VERSION desired capability. Set your mobile device's OS version.
            capabilities.setCapability(CapabilityType.VERSION, "8.1.0");

            // Set android platformName desired capability. It's Android in our case here.
            capabilities.setCapability("platformName", "Android");

            // Set android appPackage desired capability. It is
            // com.android.calculator2 for calculator application.
            // Set your application's appPackage if you are using any other app.
            capabilities.setCapability("appPackage", "com.android.calculator2");

            // Set android appActivity desired capability. It is
            // com.android.calculator2.Calculator for calculator application.
            // Set your application's appPackage if you are using any other app.
            capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

            // Created object of RemoteWebDriver will all set capabilities.
            // Set appium server address and port number in URL string.
            // It will launch calculator app in android device.
            driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
            driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);


        }

        @Test
        public void testFirstCalculator() {



            // Click on DELETE/CLR button to clear result text box before running test.
            driver.findElements(By.xpath("//android.widget.Button")).get(0).click();

            // Click on number 2 button.
            driver.findElement(By.name("7")).click();

            driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
        }

        @After
        public void End() {
            driver.quit();
        }
    }


my gradle:
apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.pierreabichacra.appiumtest"
        minSdkVersion 14
        targetSdkVersion 27
        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(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:design:27.1.1'
    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'
    implementation files('libs/byte-buddy-1.8.3.jar')
    implementation files('libs/client-combined-3.12.0.jar')
    implementation files('libs/client-combined-3.12.0-sources.jar')
    implementation files('libs/commons-codec-1.10.jar')
    implementation files('libs/commons-exec-1.3.jar')
    implementation files('libs/commons-logging-1.2.jar')
    implementation files('libs/gson-2.8.2.jar')
    implementation files('libs/guava-23.6-jre.jar')
    implementation files('libs/httpclient-4.5.3.jar')
    implementation files('libs/httpcore-4.4.6.jar')
    implementation files('libs/okhttp-3.9.1.jar')
    implementation files('libs/okio-1.13.0.jar')

}

最佳答案

将此添加到您的gradle将解决问题:

 compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}


但是如here所述:更改为1.8可解决此问题,但我必须在较旧的设备上进行检查。

关于java - Selenium项目使用Android Studio构建失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50378735/

10-09 04:24