将gradle更新为实验版本 - 错误

时间:2016-01-27 17:02:19

标签: android gradle android-ndk

我正在按照指南http://tools.android.com/tech-docs/new-build-system/gradle-experimental更新我的gradle配置以使用ndk。

  • 插件版本:0.6.0-alpha5
  • Gradle版本:2.10

更改后,我收到错误:

Gradle sync failed: Cause: com.android.build.gradle.managed.AndroidConfig$Impl

这是我的build.gradle。我忘记了什么或弄错了吗?

apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"

        defaultConfig {
            applicationId "com.appid"
            minSdkVersion.apiLevel 19
            targetSdkVersion.apiLevel 23
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

        buildTypes {
            release {
                minifyEnabled false
                proguardFiles.add(file('proguard-android.txt'))
                proguardFiles.add(file('proguard-rules.pro'))
            }
        }

        ndk {
            moduleName "ImageProc"
        }

        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
        }

    }
}

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:design:23.1.1'

        // JSON serialization
        compile 'com.google.code.gson:gson:2.4'

        // Network
        compile 'com.squareup.retrofit:retrofit:2.0.0-beta3'
        compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
        compile 'com.squareup.okhttp3:okhttp:3.0.0-RC1'

        // Junit
        testCompile 'org.robolectric:robolectric:3.0'
    }

2 个答案:

答案 0 :(得分:0)

我相信buildTypes应该在“android”块之外。另外,可能将“defaultConfig”替换为“defaultConfig.with”我在this回答中遵循build.gradle结构。然后Gradle终于能够建立。

答案 1 :(得分:0)

也许这会有所帮助。

我的工作档案:

Android Studio:3.0.1 有: classpath'com.android.tools.build:gradle-experimental:0.11.1'

看起来像这样:

apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.2"

        defaultConfig {
            applicationId "com.niedved.xxx"
            minSdkVersion.apiLevel 19
            targetSdkVersion.apiLevel 22
            ndk {
                moduleName "mupdf"
            }
            multiDexEnabled true
            jackOptions {
                enabled true
            }
        }

        buildTypes {
            release {
                jackOptions {
                    enabled true
                }
                minifyEnabled false
                proguardFiles.add(file("proguard-rules.pro"))
            }
        }
        productFlavors {
        }

        compileOptions.with {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
}

dependencies {
    compile project(':main')
    compile 'com.android.support:multidex:1.0.2'
    compile 'com.google.http-client:google-http-client-android:+'
    compile 'com.google.api-client:google-api-client-android:+'
    compile 'com.google.api-client:google-api-client-gson:+'
    compile 'com.google.code.gson:gson:2.6'
    compile files('libs/devsmartlib.jar')
    compile files('libs/ormlite-core-4.48.jar')
    compile files('libs/ormlite-android-4.48.jar')
    compile files('libs/retrofit-1.7.1.jar')
    compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.google.android.gms:play-services-maps:11.6.2'
    compile 'com.google.android.gms:play-services:11.6.2'
}