应用程序:transformClassesWithMultidexlistForDebugAndroidTest运行工具测试时出错

时间:2016-01-15 14:24:57

标签: java android gradle android-instrumentation

我正试图将我的手指放在android功能测试中。制作第一个简单的应用程序测试用例如下:

public class ApplicationTest extends ApplicationTestCase<App> {

    private App myApp;

    public ApplicationTest() {
        super(App.class);
    }

    protected void setUp() throws Exception {
        super.setUp();
        createApplication();
        myApp = getApplication();

    }

    public void testCorrectVersion() throws Exception {
        PackageInfo info = myApp.getPackageManager().getPackageInfo(myApp.getPackageName(), 0);
        assertNotNull(info);
        MoreAsserts.assertMatchesRegex("\\d\\.\\d", info.versionName);
    }
}
  • 我只需单击左键运行它,然后单击绿色箭头“运行” 应用程序“
  • 我选择了“调试”变体
  • 测试神器“Android Instrumental Test”
  • 我有“Geny Motion”,并希望用它进行测试。
  • Gradle sync well

  • =&GT;但我运行测试用例,最后得到以下错误:

  

:app:transformClassesWithMultidexlistForDebugAndroidTest FAILED   错误:任务':app:transformClassesWithMultidexlistForDebugAndroidTest'的执行失败。    com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'/Library/Java/JavaVirtualMachines/jdk1.7.0_75。 jdk / Contents / Home / bin / java''以非零退出值1

结束

这是我的app gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {

    signingConfigs {
        release {
            if (System.getenv()["CI"]) { // CI=true is exported by Greenhouse
                storeFile file(System.getenv()["GH_KEYSTORE_PATH"])
                storePassword System.getenv()["GH_KEYSTORE_PASSWORD"]
                keyAlias System.getenv()["GH_KEY_ALIAS"]
                keyPassword System.getenv()["GH_KEY_PASSWORD"]
            } else {
                release
            }
        }
    }

    compileSdkVersion ANDROID_BUILD_SDK_VERSION
    buildToolsVersion ANDROID_BUILD_TOOLS_VERSION

    defaultConfig {
        applicationId "fr.millezimsolutions.app.millezimu"
        targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION
        minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION
        versionCode ANDROID_BUILD_VERSION_CODE
        versionName ANDROID_BUILD_APP_VERSION_NAME
        multiDexEnabled true
    }
    buildTypes {
        release {
            debuggable false
            renderscriptOptimLevel 3
            signingConfig android.signingConfigs.release
            zipAlignEnabled true

            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'proguard-rules-new.pro'

        }
        debug {

            debuggable true
            renderscriptOptimLevel 3
            applicationIdSuffix ".debug"
            versionNameSuffix "debug"
        }
    }

    configurations{
        all*.exclude group: 'cglib'
        all*.exclude group: 'commons-collections'
    }


    dexOptions {
        incremental false
        preDexLibraries = false
        jumboMode = true
        javaMaxHeapSize "4g"
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/INDEX.LIST'
        exclude 'LICENSE.txt'
        exclude 'NOTICE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    useLibrary 'org.apache.http.legacy'

    configurations.all {
        resolutionStrategy.force 'com.google.code.gson:gson:2.5'
        resolutionStrategy.force 'com.google.guava:guava:19.0'
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])

        // SUPPORT
        compile 'com.android.support:appcompat-v7:23.1.1'

        // WORKERS
        compile 'de.greenrobot:eventbus:2.4.1'
        compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

        // SOCIAL NETWORK
        compile 'org.twitter4j:twitter4j-core:4.0.4'
        compile 'com.facebook.android:facebook-android-sdk:4.8.2'

        // TEST
        //testCompile 'org.robolectric:robolectric:3.0'
        //testCompile "org.robolectric:robolectric:3.0"
        testCompile 'junit:junit:4.+'
        androidTestCompile 'junit:junit:4.+'
        androidTestCompile 'io.appium:java-client:3.3.0'
        androidTestCompile 'org.apache.commons:commons-lang3:3.4'
        androidTestCompile 'com.google.code.gson:gson:2.5'
        // Set this dependency if you want to use the Hamcrest matcher library
        testCompile 'org.hamcrest:hamcrest-library:1.3'

        // MULTIDEX
        compile 'com.android.support:multidex:1.0.1'

        // VIEW
        compile 'com.android.support:design:23.1.1'
        compile 'de.hdodenhof:circleimageview:2.0.0'
        compile 'me.relex:circleindicator:1.1.7@aar'
        compile 'com.lsjwzh:recyclerviewpager:1.0.8'
        compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.11'
        compile('com.afollestad.material-dialogs:core:0.8.5.3@aar') {
            transitive = true
        }
        compile project(':MaterialWidget')
        compile project(':MultiHeaderRecyclerView')
        compile 'com.android.support:cardview-v7:23.1.1'
        compile 'me.zhanghai.android.materialprogressbar:library:1.1.4'

        // TEXT
        compile 'uk.co.chrisjenx:calligraphy:2.1.0'
        compile 'com.github.bluejamesbond:textjustify-android:2.1.1'

        // FIREBASE
        compile 'com.firebaseui:firebase-ui:0.3.0'
        compile 'com.firebase:geofire:1.1.1'
        compile('com.firebase:firebase-client-android:2.5.0') {
            exclude module: 'httpclient'
        }

        // UTILS
        compile 'com.google.code.gson:gson:2.5'
        // compile 'me.dm7.barcodescanner:zbar:1.6.3'
        compile('com.google.http-client:google-http-client-jackson:1.21.0') {
            exclude module: 'xpp3'
            exclude group: 'stax'
        }
        compile 'org.apache.commons:commons-lang3:3.4'

        // OAUTH
        compile 'com.google.oauth-client:google-oauth-client-java6:1.21.0'

        // TIME
        compile 'joda-time:joda-time:2.9.1'
        compile 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'

        // AMAZON WS
        compile 'com.amazonaws:aws-android-sdk-core:2.2.9'
        compile 'com.amazonaws:aws-android-sdk-cognito:2.2.9'
        compile 'com.amazonaws:aws-android-sdk-s3:2.2.9'

        // GOOGLE
        compile 'com.google.android.gms:play-services:8.3.0'

        // RATING STORE
        compile project(':AppRate')

        // DEBUG
        compile 'com.github.brianPlummer:tinydancer:0.0.9'
        compile 'com.splunk.mint:mint:4.4.0'
        compile 'com.google.android.gms:play-services-analytics:8.3.0'
        // debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
        // releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
        compile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'


    }

    if (!System.getenv()["CI"]) {
        // Routine pour acceder aux clés de signature
        def Properties props = new Properties()
        def propFile = file('../../signing.properties')
        if (propFile.canRead()) {
            props.load(new FileInputStream(propFile))

            if (props != null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
                    props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {

                android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
                android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
                android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
                android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
            } else {
                android.buildTypes.release.signingConfig = null
            }
        } else {
            android.buildTypes.release.signingConfig = null
        }
    }

    println(getVersion().toString())
}

这是项目gradle文件:

buildscript {
    repositories {
        jcenter()
        mavenCentral()

    }
    dependencies {

        classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
        classpath 'com.google.gms:google-services:1.5.0-beta2'
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        maven {
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
        maven {
            url "https://mint.splunk.com/gradle/"
        }

    }
}

ext {
    ANDROID_BUILD_MIN_SDK_VERSION = 16
    ANDROID_BUILD_TARGET_SDK_VERSION = 23
    ANDROID_BUILD_TOOLS_VERSION = "23.0.1"
    ANDROID_BUILD_SDK_VERSION = 23
    ANDROID_BUILD_VERSION_CODE = getAppVersionCode()
    ANDROID_BUILD_APP_VERSION_NAME = getAppUVersionName()

    ANDROID_DEFAULT_BUILD_VERSION_CODE = "24"
    ANDROID_DEFAULT_BUILD_APP_VERSION_NAME = 0.4
}

apply plugin: 'com.github.ben-manes.versions'

我看了一会儿,但很难看出它可能是什么。

0 个答案:

没有答案