问题 无法更新android studio 3.1:冲突配置:同步项目中的'armeabi-v7a,x86'


这是我的构建gradle(app)文件:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'checkstyle'

def versions = ['appcompat_v7' : '25.1.0',
                'butterknife'  : '8.4.0',
                'leak_canary'  : '1.5',
                'card_view'    : '25.1.0',
                'design'       : '25.1.0',
                'photoview'    : '1.2.4',
                'play_services': '10.0.1']



task checkstyle(type: Checkstyle) {
    configFile file("${project.rootDir}/checkstyle/checkstyle.xml")
    configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
    // Where is my suppressions file for checkstyle is...
    source 'src'
    include '**/*.java'
    exclude '**/gen/**'
    classpath = files()
}


android {
    compileSdkVersion 25
    buildToolsVersion '27.0.3'
    flavorDimensions "versionCode"

    useLibrary 'org.apache.http.legacy'
    dexOptions {
        // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
        preDexLibraries = preDexEnabled && !travisBuild
    }

    defaultConfig {

        ndk {
            abiFilters 'x86', 'armeabi-v7a'
        }

        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
    }
    signingConfigs {
        release
    }
    buildTypes {
        debug {
            debuggable true
        }
        release {
            //runProguard true
            proguardFile file('android.pro')
            proguardFile getDefaultProguardFile('proguard-android.txt')
            signingConfig signingConfigs.release
        }
    }

    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi-v7a'
            universalApk true
        }
    }

    // map for the version code


    productFlavors {

        playstore {

        }
        develop {
        }
    }


    lintOptions {
        //I'm too lazy to translate everything
        abortOnError false
    }
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
}

def Properties props = new Properties()
def propFile = new 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 {
        println 'signing.properties found but some entries are missing'
        android.buildTypes.release.signingConfig = null
    }
} else {
    println 'signing.properties not found'
    android.buildTypes.release.signingConfig = null
}

buildscript {
    repositories {
        jcenter()
        mavenCentral()

    }
}


dependencies {
    compile project(":tess-two:tess-two")
    compile project(":volley")
    compile project(":real-time-ocr")

    compile 'com.github.barteksc:pdfium-android:1.5.0'
    compile fileTree(dir: 'src/main/libs', include: '*.jar')

    debugCompile "com.squareup.leakcanary:leakcanary-android:${versions.leak_canary}"
    releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${versions.leak_canary}"
    compile 'com.viewpagerindicator:library:2.4.1@aar'
    compile "com.commit451:PhotoView:${versions.photoview}"
    compile 'com.google.code.findbugs:jsr305:2.0.2'
    compile "com.google.guava:guava:18.0"
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile "com.android.support:design:${versions.design}"
    compile "com.android.support:appcompat-v7:${versions.appcompat_v7}"
    compile 'org.apache.commons:commons-compress:1.5'
    compile "com.android.support:cardview-v7:${versions.card_view}"
    compile 'com.google.code.gson:gson:2.8.2'
    compile "com.jakewharton:butterknife:${versions.butterknife}"
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.google.android.gms:play-services-vision:9.4.0+'
    compile group: 'com.facebook.android', name: 'facebook-android-sdk', version: '4.25.0'



    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
    androidTestCompile 'com.google.dexmaker:dexmaker:1.0'
    androidTestCompile 'org.mockito:mockito-core:1.10.17'
    androidTestCompile 'junit:junit:4.12'


    testCompile 'junit:junit:4.12'
    testCompile "org.mockito:mockito-all:1.10.19"
    testCompile("org.robolectric:robolectric:3.0-rc2") {
        exclude group: 'commons-logging', module: 'commons-logging'
    }
    compile('com.crashlytics.sdk.android:crashlytics:2+') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics-ndk:1+@aar') {
        transitive = true;
    }


    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.shawnlin:number-picker:2.4.4'
    compile 'com.squareup.picasso:picasso:2.5.2'



}
crashlytics {
    enableNdk true
    androidNdkOut '/Users/renard/devel/textfairy/tess-two/tess-two/obj'
    androidNdkLibsOut '/Users/renard/devel/textfairy/tess-two/tess-two/libs'
}
apply plugin: 'com.google.gms.google-services'

android studio无法同步项目并让我犯这个错误:

冲突配置:当设置拆分abi过滤器时,ndk abiFilters中的'armeabi-v7a,x86'不能出现:x86,armeabi-v7a

配置'compile'已经过时,已被'implementation'取代。   它将在2018年底删除

配置'debugCompile'已过时,已被'debugImplementation'取代。   它将在2018年底删除

配置'androidTestApi'已经过时,已被'androidTestImplementation'取代。   它将在2018年底删除

配置'releaseCompile'已过时,已被'releaseImplementation'取代。   它将在2018年底删除

配置'testCompile'已过时,已被'testImplementation'取代。   它将在2018年底删除

配置'testApi'已过时,已被'testImplementation'取代。   它将在2018年底删除

配置'androidTestCompile'已过时,已被'androidTestImplementation'取代。   它将在2018年底删除

选项'android.enableAapt2'已弃用,不应再使用。   使用'android.enableAapt2 = true'删除此警告。   它将在2018年底删除。

配置'compile'已经过时,已被'implementation'取代。   它将在2018年底删除

选项'android.enableAapt2'已弃用,不应再使用。   使用'android.enableAapt2 = true'删除此警告。   它将在2018年底删除。

配置'testCompile'已过时,已被'testImplementation'取代。   它将在2018年底删除

配置'testApi'已过时,已被'testImplementation'取代。   它将在2018年底删除

选项'android.enableAapt2'已弃用,不应再使用。   使用'android.enableAapt2 = true'删除此警告。   它将在2018年底删除。

配置'compile'已经过时,已被'implementation'取代。   它将在2018年底删除

如果我删除这一行

defaultConfig {

    ndk {
        abiFilters 'x86', 'armeabi-v7a'
    }

项目成功同步 但是当构建给我这个错误

无法执行aapt

我已经尝试清理并重建项目但仍然无法正常工作! 我还发布了build.gradle(Project)文件

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1+'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.android.tools.build:gradle:3.1.0'
    }
}



allprojects {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url "http://dl.bintray.com/populov/maven" }
        jcenter()
        maven {
            url "http://oss.sonatype.org/content/repositories/snapshots"
        }
        maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' }
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }

}

ext {
    travisBuild = System.getenv("TRAVIS") == "true"
    // allows for -Dpre-dex=false to be set
    preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
}

我的gradle-wrapper.properties文件

    #Tue Mar 27 14:42:14 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

和我的gradle.properties文件

    ndkDir=/Users/giuliopettenuzzo/Library/Android/sdk/ndk-bundle
org.gradle.jvmargs=-XX\:MaxPermSize\=512m
android.enableAapt2=false

请帮帮我,我在这个问题上花了一天!!


10255
2018-03-27 16:25


起源



答案:


ndkabiFilters 配置意味着只有选定的本机库处理器体系结构才会包含在最终的APK中。

另一方面, splitsabienable true 告诉编译器为选定的体系结构生成单独的APK。

它接缝这两个配置不能设置在一起。所以你有两个选择:

  1. 禁用拆分APK(你已经弄清楚了)。比你有一个APK。

  2. 去掉 ndkabiFilters 设置。比你有多个(可能小得多)的APK。而且,随着 universalApk true,将生成具有所有架构的通用APK(可能比选项1中的大得多)。

比,替换 compile 使用新关键字 implementation。我想,从错误信息中可以清楚地看到这一点。


6
2018-04-12 17:18



>此外,使用universalApk true,将生成具有所有体系结构的通用APK(可能比选项1中的大得多)。这太愚蠢了。如果我想要abi拆分,我会得到无效的通用apk,例如,如果我的依赖关系提供更多abis我们做。 - vganin


答案:


ndkabiFilters 配置意味着只有选定的本机库处理器体系结构才会包含在最终的APK中。

另一方面, splitsabienable true 告诉编译器为选定的体系结构生成单独的APK。

它接缝这两个配置不能设置在一起。所以你有两个选择:

  1. 禁用拆分APK(你已经弄清楚了)。比你有一个APK。

  2. 去掉 ndkabiFilters 设置。比你有多个(可能小得多)的APK。而且,随着 universalApk true,将生成具有所有架构的通用APK(可能比选项1中的大得多)。

比,替换 compile 使用新关键字 implementation。我想,从错误信息中可以清楚地看到这一点。


6
2018-04-12 17:18



>此外,使用universalApk true,将生成具有所有体系结构的通用APK(可能比选项1中的大得多)。这太愚蠢了。如果我想要abi拆分,我会得到无效的通用apk,例如,如果我的依赖关系提供更多abis我们做。 - vganin


最后我把它整理出来

abi { enable false reset() include 'x86', 'armeabi-v7a' universalApk true }

multiDexEnabled true 但我不知道这是否解决了问题或只是忽略了错误


4
2018-03-27 18:13



我应该把它放在哪里?在默认配置? - Harsh Bhavsar
@HarshBhavsar你应该把它放在android / app / build.gradle中 - Pratik Singhal
@PratikSinghal在哪里?我输入了该文件,并且我在“org.gradle.api.Project”类型的根项目':app'上有参数[build_randomchars_run_closure3 @ randomnumbers]的错误“Coiuld找不到方法abi()”。 - DiCri
@DiCri有两个build.gradle文件。你确定,你是想把它放在正确的文件中吗?你需要把它放在android / app / build.gradle而不是android / build.gradle中。 - Pratik Singhal
@PratikSinghal是的,我做了,但它不起作用。 - DiCri


dependencies {
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.android.gms:play-services-maps:9.6.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation ('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:9.6.1' //referencia  a la version de firebase
implementation 'com.google.firebase:firebase-database:9.6.1' // referencia a la base de datos
implementation 'com.google.firebase:firebase-auth:9.6.1'
implementation 'com.google.android.gms:play-services-auth:9.6.1'

implementation 'com.google.android.gms:play-services-maps:9.6.1'

// aqui se agrega la referencia a la autentificacion

}

**通过实现替换编译   androidTileImplementation的androidCompileTest **


0
2018-04-11 14:08



我不知道为什么这个答案得到了贬低,但这对我有用,并且根据Android Studio在我之前的gradle构建之后通知的内容,在某种程度上是合理的。 - adadion


我打开了一个旧项目,当我想要构建它时,我遇到了很多错误,这非常令人沮丧。我用实现替换了compile并添加了所有必需的代码。最后,该项目成功建成。

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation ('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.facebook.android:facebook-android-sdk:4.+'
    implementation 'com.facebook.android:account-kit-sdk:4.+'
    implementation 'com.android.volley:volley:1.1.0-rc2'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    testImplementation 'junit:junit:4.12'
}

0
2017-07-31 02:19