【问题标题】:Update gradle to experimental version - Error将 gradle 更新到实验版本 - 错误
【发布时间】:2016-01-27 17:02:19
【问题描述】:

我正在按照指南 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'
    }

【问题讨论】:

  • 未找到解决方案。放弃了。

标签: android gradle android-ndk


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    也许这会有所帮助。

    我的工作文件:

    Android Studio:3.0.1 和: 类路径'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'
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-16
      • 2020-11-15
      • 1970-01-01
      相关资源
      最近更新 更多