【问题标题】:preBuild dependency in new experimental Gradle for NDK on Android Studio用于 Android Studio 上的 NDK 的新实验性 Gradle 中的 preBuild 依赖项
【发布时间】:2015-10-17 20:25:15
【问题描述】:

最近我决定试一试 Android Studio 中的新 NDK 插件

需要的更改解释here

我的 build.gradle 移植成功。今天我决定我需要一个复制任务才能将文件复制到我的“资产”文件夹中。

在线搜索说我必须使用“preBuild.dependsOn taskName”行,我确信这对于普通 Gradle 可以正常工作,但在新的实验性行中失败(引入了“模型”行为)

现在我的 build.gradle 失败了。

Error:(25, 0) Could not find property 'preBuild' on root project 'Android'.

我确信任务定义正确,因为错误来自 preBuild... 行

这是我的 build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.2.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

task copyWebViewAssets(type: Copy){
    from '../Common/WebView'
    into 'src/main/assets'
    include('**/*')
}

preBuild.dependsOn copyWebViewAssets

model {
    compileOptions.with {
        sourceCompatibility=JavaVersion.VERSION_1_7
        targetCompatibility=JavaVersion.VERSION_1_7
    }
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.1"

        defaultConfig.with {
            applicationId = "com.company.product"
            minSdkVersion.apiLevel = 9
            targetSdkVersion.apiLevel = 23
            versionCode = 1
            versionName = "1.0"
        }
    }
    android.ndk {
        moduleName = "native"
    }
    android.buildTypes {
        release {
            minifyEnabled = false
        }
        debug {
            ndk.with {
                debuggable = true
            }
        }
    }
    android.productFlavors {
        // To include all cpu architectures, leaves abiFilters empty
        create("all")
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.0.1'
}

我想再次说明这与新的实验性 Gradle for NDK 有关。我目前在 Android Studio 1.4 上,使用 Gradle 2.5。

感谢您的支持

【问题讨论】:

    标签: android gradle android-ndk


    【解决方案1】:

    使用 compileTask 代替 prebuild

    它对我有用。

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn(changeNamespace)
    }
    

    【讨论】:

    • 我收到一个错误:No such property: compileTask for class: org.gradle.model.ModelMap
    • 为我工作。我刚刚用这个建议替换了我的prebuild.dependsOn 行。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2015-12-05
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    • 2015-01-25
    相关资源
    最近更新 更多