迁移到摇篮的实验时,2.5问题:这样的方法AndroidConfig [英] Issue when migrating to Gradle Experimental 2.5 : no such method AndroidConfig

查看:1329
本文介绍了迁移到摇篮的实验时,2.5问题:这样的方法AndroidConfig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚更新我的Andr​​oid Studio安装到1.3(最新的稳定为2015年8月31日的),我需要使用最新的NDK集成。我的previous的Andr​​oid Studio版本是1.2​​.1(稳定为好)。

谷歌移植到摇篮实验指南我管理很容易适应各种我的gradle脚本。

不过,摇篮同步失败,出现以下错误:

 错误:没有这样的属性:机器人类:com.android.build.gradle.managed.ProductFlavor

[更新1 - >见下文,错误更新]

当我尝试制作的项目,我得到一个小更详细的错误:

 错误:(17 1)发生配置项目的问题:应用程序。
>在执行模型规则抛出异常:model.android
   >没有这样的属性:机器人类:com.android.build.gradle.managed.ProductFlavor

应用程序指的是主要应用code(带活动等)。

使用功能 F4>跳转到源代码,它从我的应用项目打开我的的build.gradle 脚本。

这就是前面提到的脚本的内容:

 应用插件:'com.android.model.application'//实验模型{
    安卓{
        compileSdkVersion = 21
        buildToolsVersion = '22 .0.1'        defaultConfig.with {
            的applicationID =company.com.myapplication
            minSdkVersion.apiLevel = 10
            targetSdkVersion.apiLevel = 21
            版本code = 1
            的versionName =1.0            // NDK
            android.ndk {
                MODULENAME =MyAwesomeJNILib
                CFLAGS-std = C99
            }
        }
        android.buildTypes {
            发布 {
                minifyEnabled = FALSE
                proguardFiles + =文件(proguard-rules.pro')
            }
        }
        android.productFlavors {
            //详细abiFilter说明,请参见支持的ABI@
            // https://developer.android.com/ndk/guides/abis.html#sa
            创建(ARM){
                ndk.abiFilters + =armeabi
            }
            创建(ARM7){
                ndk.abiFilters + =armeabi-V7A
            }
            创建(ARM8){
                ndk.abiFilters + =arm64-V8A
            }
            创建(86){
                ndk.abiFilters + =86
            }
            创建(X86-64){
                ndk.abiFilters + =x86_64的
            }
            创建(MIPS){
                ndk.abiFilters + =MIPS
            }
            创建(MIPS-64){
                ndk.abiFilters + =MIPS64
            }
            //要包括所有的CPU架构,叶abiFilters空
            创建(全能)
        }        packagingOptions {
            排除的LICENSE.txt
        }
    }
}依赖{
    编译文件树(包括:['的* .jar'],DIR:库)
    编译com.android.support:appcompat-v7:22.2.0
    编译com.google code.gson:GSON:2.3.1
    编译com.squareup.okhttp:okhttp-Android的支持:2.4.0
    编制项目(':bluetoothmanager')
    编译乔达时间:乔达时间:2.8.1
    //单位测试
    // androidTestCompile'的JUnit:JUnit的:4.12
    编译'的JUnit:JUnit的:4.12'//实验
}

正如你所看到的,没有什么很花哨这里。
但是,你可能会注意到有一些单元测试设置:

  //单位测试
// androidTestCompile'的JUnit:JUnit的:4.12
编译'的JUnit:JUnit的:4.12'//实验

androidTestCompile ,而迁移到 GradleExperimental 让我修改下一个解决方案,我再也找不到(对不起),在那里我会简单的无法解析把编译 androidTestCompile 代替。
这是错误:

 错误:(71,0)摇篮DSL方法未找到:'androidTestCompile()

我试图比较谷歌的NDK样本之一( HELLO-JINI 为例)作为aforemention指南中提供和的可在这里

packagingOptions 我找不到这将是负责我的歪任何差异。我试图删除 packagingOptions 但这并没有使一个单一的变化都没有。

[更新1]

您会发现,更详细的错误消息指出它在线路#17这是我声明我的原始构建设置
我固定这是错误 CFLAGS 必须改成 CFLAGS 和我添加了 = 所要求的摇篮的新版本。
这确实帮助,误差不会出现了,但改变了:

 错误:没有这样的属性:机器人类:com.android.build.gradle.managed.AndroidConfig


解决方案

有关的第一部分。

BuildType,口味......都是Android的外块,但该模型块中。

 应用插件:'com.android.model.application'//实验模型{
    安卓{
         defaultConfig.with {         }
     }    android.ndk {    }    android.buildTypes {
            发布 {            }
        }
    android.productFlavors {    }
}

I have just updated my Android Studio setup to 1.3 (latest stable as of 31st of August 2015) and I need to use the latest NDK integration. My previous Android Studio version was 1.2.1 (stable as well).

Following Google Migration to Gradle Experimental Guide I managed to easily adapt my various gradle scripts.

However, Gradle Sync fails with the following error :

Error:No such property: android for class: com.android.build.gradle.managed.ProductFlavor

[Update 1 -> see below, error updated]

When I attempt to Make the project, I obtain a little more detailed error :

Error:(17, 1) A problem occurred configuring project ':app'.
> Exception thrown while executing model rule: model.android
   > No such property: android for class: com.android.build.gradle.managed.ProductFlavor

App refers to the main application code (with activities and other).

Using the feature F4 > Jumping to Source, it opens my build.gradle script from my app project.

This is the content of the aforementioned script :

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

model {
    android {
        compileSdkVersion = 21
        buildToolsVersion = '22.0.1'

        defaultConfig.with {
            applicationId = "company.com.myapplication"
            minSdkVersion.apiLevel = 10
            targetSdkVersion.apiLevel = 21
            versionCode = 1
            versionName = "1.0"

            // NDK
            android.ndk {
                moduleName = "MyAwesomeJNILib"
                cFlags "-std=c99"
            }
        }
        android.buildTypes {
            release {
                minifyEnabled = false
                proguardFiles += file('proguard-rules.pro')
            }
        }
        android.productFlavors {
            // for detailed abiFilter descriptions, refer to "Supported ABIs" @
            // https://developer.android.com/ndk/guides/abis.html#sa
            create("arm") {
                ndk.abiFilters += "armeabi"
            }
            create("arm7") {
                ndk.abiFilters += "armeabi-v7a"
            }
            create("arm8") {
                ndk.abiFilters += "arm64-v8a"
            }
            create("x86") {
                ndk.abiFilters += "x86"
            }
            create("x86-64") {
                ndk.abiFilters += "x86_64"
            }
            create("mips") {
                ndk.abiFilters += "mips"
            }
            create("mips-64") {
                ndk.abiFilters += "mips64"
            }
            // To include all cpu architectures, leaves abiFilters empty
            create("all")
        }

        packagingOptions {
            exclude 'LICENSE.txt'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.squareup.okhttp:okhttp-android-support:2.4.0'
    compile project(':bluetoothmanager')
    compile 'joda-time:joda-time:2.8.1'
    // Units Testing
    //androidTestCompile 'junit:junit:4.12'
    compile 'junit:junit:4.12' // experimental
}

As you can see, there is nothing very fancy here. But you might notice there is some unit testing setup :

// Units Testing
//androidTestCompile 'junit:junit:4.12'
compile 'junit:junit:4.12' // experimental

androidTestCompile could not be resolved while migrating to GradleExperimental so I modified following a solution I can no longer find (sorry) where I would simple put compile in stead of androidTestCompile. This was the error :

Error:(71, 0) Gradle DSL method not found: 'androidTestCompile()'

I tried to compare one of Google's NDK sample (hello-jini for example) as provided in the aforemention guide and available here.

Except the packagingOptions I could not find any differences that would be responsible for my awry. I tried to remove packagingOptions but that did not make a single change at all.

[UPDATE 1]

You will notice that the more detailed error message states that it's in line #17 which is where I declare my native build settings. I fixed the error which was cFlags must be changed to CFlags and I added the = as required by the new version of Gradle. This did help, the error does not appear anymore but changed for :

Error:No such property: android for class: com.android.build.gradle.managed.AndroidConfig

解决方案

For the first part.

BuildType, flavors... are outside the android block, but inside the model block.

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

model {
    android {
         defaultConfig.with {

         }
     }

    android.ndk {

    }

    android.buildTypes {
            release {

            }
        }
    android.productFlavors {

    }
}

这篇关于迁移到摇篮的实验时,2.5问题:这样的方法AndroidConfig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆