简体   繁体   中英

Android gradle-experimental 0.2.0 add res and aidl

I'm struggling to use external library in Android Studio 1.3, Gradle 2.5 and gradle-experimental plugin 0.2.0, required because of NDK.

I found some material here on how to change old gradle files which I've done, but can't find any other documentation documentation.

During my extensive search I managed to find out the changes for manifest but not for res and aid . Has anyone managed to find out what need to be changed or any useful documentation?

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

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

model {
    android {
        compileSdkVersion = 19
        buildToolsVersion = "19.1.0"

        defaultConfig.with {
            applicationId = "org.opencv.android"
            minSdkVersion.apiLevel = 8
            targetSdkVersion.apiLevel = 19
            versionCode = 3000
            versionName = "3.0.0"
        }
    }

    android.sources {
        main {
            manifest.source.include 'AndroidManifest.xml' // OLD manifest.srcFile 'AndroidManifest.xml'
            java.source.srcDir 'src'
            resources.source.srcDirs 'src'
            res.srcDirs = ['res'] // ERROR
            aidl.srcDirs ['src'] // ERROR
        }
    }
}

The errors are:

Gradle sync failed: Could not find property 'srcDirs' on AndroidLanguageSourceSet 'main:aidl'.

Gradle sync failed: Unable to load class 'com.android.build.gradle.model.AndroidLanguageSourceSet_Decorated'.

Some debugging with println shows that java , res , aidl are of the type AndroidLanguageSourceSet . They all have the same source property now, and srcDirs list inside that. You should be able to append your custom paths to the srcDirs property like:


android.source {
  main {
    java.source.srcDirs += 'src'
    res.source.srcDirs += 'res'
    aidl.source.srcDirs += 'aidl'
  }
}

Don't forget to use = in the new syntax to set the value and += to append it to the list (in the old syntax just a whitespace was sufficient).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM