Android Studio development Groovy and androidgroovy
Context:
This article mainly talks about how Android Studio develops Groovy and sets up the environment. I checked N more foreign languages ....
1. AS (Android Studio) itself supports Groovy, And the syntax used by Gradle is Groovy. You can also directly create a. groovy extension file in.
2. build. gradle of the Project and Module can change the directory display form to Android to identify:
Problem:
The executed groovy file will prompt that no configuration (configure) groovy
Solution: 1. Add:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}
That is, add
classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6'
2. Add in build. gradle of Module layer
apply plugin: 'groovyx.grooid.groovy-android'
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.+' compile 'org.codehaus.groovy:groovy:2.4.0:grooid'}
That is, add a plug-in and a compile in dependencies.
3. Use the latest Android Studio1.2Beta3
Because I used an old one before, and thus cannot run.
4. Wall flip:
This is not necessary, but may be affected when groovy dependencies and AS upgrades are installed. There is no way for tianchao to be inferior in technology and management. Just use a VPN. The first VPN found by Baidu is basically fake, and the domain names are all snatched by the shanzhai.
Source code:
Source code is on my github address: https://github.com/AlbertSnow/MyGroovyProject.git
The file is app \ src \ androidTest \ java \ com \ example \ starlight \ myapplication \ policytest. groovy