Android Studio ignore --core-library flag

前端 未结 6 977
盖世英雄少女心
盖世英雄少女心 2020-12-06 17:40

I have a project, which i want to configure on my computer.

On anothe computer it works, but with old version of Android Studio 0.4.0 whenever I use 0.5.2

Th

6条回答
  •  死守一世寂寞
    2020-12-06 17:50

    In Android Studio 1.1.0, navigate to :

    File --> Other Settings --> Default Settings --> Compilers --> Android Compilers

    You will find the check-box to Add "--core-library" flag, but this does not seem to be working.

    Instead editing the file app/build.gradle

    Disabling pre-dexing inside android {} using

    dexOptions {
        preDexLibraries = false
    }
    

    and modifying Dex task using

    project.tasks.withType(com.android.build.gradle.tasks.Dex) {
        additionalParameters=['--core-library']
    }
    

    solves the problem.

    Edit: Full contents of app/build.gradle

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"
    
        defaultConfig {
            applicationId "appId"
            minSdkVersion 19
            targetSdkVersion 21
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
        dexOptions {
            preDexLibraries = false
            javaMaxHeapSize "4g"
        }
    
        project.tasks.withType(com.android.build.gradle.tasks.Dex) {
            additionalParameters=['--core-library']
        }
    
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/MANIFEST.MF'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/LICENSE.txt'
            // more exclude files here if conflicts
        }
    }
    

提交回复
热议问题