如何修复Bundle Gradle错误未知属性

时间:2019-02-09 15:15:22

标签: java android apk

apply plugin: 'com.android.application'

            android {
            compileSdkVersion 28
            buildToolsVersion '28.0.3'
            defaultConfig {
                applicationId "com."
                minSdkVersion 1
                targetSdkVersion 28
                versionCode 4
                multiDexEnabled true
                versionName "3.2.9"
                testInstrumentationRunner 
            "android.support.test.runner.AndroidJUnitRunner"

                ndk {
                    abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
                }
            }
            aaptOptions {
                cruncherEnabled = false
            }

            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 
            'proguard-rules.pro'
                 }
              }
          }
            def final var = dependencies {
            implementation fileTree(dir: 'libs', include: ['*.jar', '*.so'])


     androidTestCompile('com.android.support.test.espresso:espresso- 
          core:2.2.2', {
                exclude group: 'com.android.support', module: 'support-annotations'

               exclude / 'com.android.support:appcompat-v7:25.3.1' /
                       exclude / 'com.android.support:design:25.3.1' /
                       exclude / 'com.android.support.constraint:constraint- 
         layout:1.0.2'
                testcompile / 'junit:junit:4.12'

               compile 




'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http. 
        client:4.1.2'
           compile 'com.drewnoakes:metadata-extractor:2.8.1'
              compile 'jp.wasabeef:picasso-transformations:2.1.2'
            If you want to use the GPU Filters
           compile 'com.github.bumptech.glide:glide:3.6.0'

           compile 'com.android.support:multidex:1.0.0'
           compile 'com.github.zomato:androidphotofilters:1.0.1'
           compile  'com.android.support:recyclerview-v7:25.3.1'
           compile  'com.android.support:support-annotations:28.0.0'
            })

       }

错误:

  

错误:无法获取未知的属性“排除”   DefaultExternalModuleDependency {group ='com.android.support.test.espresso',   名称=“浓缩咖啡核”,版本=“ 2.2.2”,配置=“默认”}   类型   org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency

1 个答案:

答案 0 :(得分:0)

这是因为您的build.gradle结构不正确。您需要确保您的build.gradle遵循module build structure文档中的正确结构。像这样:

apply plugin: 'com.android.application'

android {


  compileSdkVersion 28
  buildToolsVersion "28.0.3"


  defaultConfig {

    applicationId 'com.example.myapp'
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
  }

  buildTypes {


    release {
        minifyEnabled true // Enables code shrinking for the release build type.
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }

dependencies {
    implementation project(":lib")
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
}

错误的结构是以下行:

def final var = dependencies {

然后,您需要将对依赖项的排除修改为以下内容:

 implementation('com.drewnoakes:metadata-extractor:2.8.1') {
    exclude group: 'com.android.support', module: 'support-annotations'
    exclude group: 'com.android.support', module: 'appcompat-v7'
    exclude group: 'com.android.support', module: 'design'
  }