Android gradle -experimental 0.2.0 add res and helpl

I am struggling to use external library in Android Studio 1.3, Gradle 2.5 and gradle-expert plugin 0.2.0 required due to NDK.

I found some stuff here on how to modify old Gradle files that I did, but can't find any other documentation.

During my extensive search, I was able to find out the changes for the manifest, but not for res

and aid

. Has anyone been able to figure out what needs to be changed or any helpful 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
        }
    }
}

      

Errors:

Gradle Synchronization failed: Could not find property 'srcDirs' on AndroidLanguageSourceSet 'main: helpl'.

Gradle Sync error: Unable to load class 'com.android.build.gradle.model.AndroidLanguageSourceSet_Decorated'.

+3


source to share


1 answer


Some debugging to println

show that java

, res

, aidl

are of the type AndroidLanguageSourceSet

. They all have the same properties source

, and the srcDirs

list is inside that. You have to add your own paths to the srcDirs property, for example:


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 a value and +=

to add it to the list (in the old syntax, a space is sufficient).

+1


source







All Articles