Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java app:transformClassesWithMultidexlistForDebugAndroidTest运行仪器测试时出错_Java_Android_Gradle_Android Instrumentation - Fatal编程技术网

Java app:transformClassesWithMultidexlistForDebugAndroidTest运行仪器测试时出错

Java app:transformClassesWithMultidexlistForDebugAndroidTest运行仪器测试时出错,java,android,gradle,android-instrumentation,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 {

我正试图参与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);
    }
}
这是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())
}
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'

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

该依赖项列表可能会被删减,从而不需要多索引,不是吗?每个依赖项都会被使用,当然不完全是这样。这是一个多指标问题吗?因为我在release和debug config中构建apk都没有任何问题。你找到任何解决方案了吗?@Lisitso我改变了策略,成功地使用了Proguard和Espresso。你也有同样的问题吗?@Antony:是的,我也有同样的问题,我已经激活了Proguard,需要打开multidex。如果您有任何建议,我们将不胜感激:-)