I have this gradle build file.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
classpath 'com.eriwen:gradle-css-plugin:1.2.1'
classpath 'com.eriwen:gradle-js-plugin:1.5.1'
}
}
apply plugin: 'android'
apply plugin: 'js'
apply plugin: 'css'
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/cordova-2.7.0.jar')
compile files('libs/libGoogleAnalyticsV2.jar')
}
task MinifyJSForRelease {
tasks.add(name:"copyTask2", type:Copy){
from 'assets/'
into 'build/minifiedassets/assets'
}
it.dependsOn copyTask2
def tester = fileTree(dir:"build/minifiedassets/assets", include:"**/*.js");
println tester
tester.eachWithIndex {File file, idx ->
tasks.add(name: "makeMinifyJS${idx}", type: com.eriwen.gradle.js.tasks.MinifyJsTask) {
source = file
dest = "${file.path}"
closure {
compilerOptions.languageIn = "ECMASCRIPT5"
}
}
}
it.dependsOn tasks.matching { Task task -> task.name.startsWith("makeMinifyJS")}
}
build.dependsOn MinifyJSForRelease
android {
compileSdkVersion 17
buildToolsVersion "17"
signingConfigs {
release {
storeFile file('keystores/mobilecoe_android.keystore')
storePassword "mobilecoe"
keyAlias "MobileCoE"
keyPassword "mobilecoe"
}
}
defaultConfig {
minSdkVersion 10
targetSdkVersion 16
}
buildTypes {
debug {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
release {
signingConfig signingConfigs.release
zipAlign true
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['build/minifiedassets/assets']
}
instrumentTest.setRoot('tests')
}
}
}
}
I Want to run the task MinifyJSForRelease like the first thing would be to copy the assets folder to where I want and then when that is finished I want to minify the JS files.
Now when I run the task it copies the folder but not reaching the end the next function says it has nothing to minify but if I run the task the second time(when the folder is already copied) it fiends it and does everything.
What am I do in wrong?
I need to:
copy folder
Get the folder and minify its js files
Could some one help me out?
I'm a total virgen to Gradle, So I can only provide you with educated guess:
unify the way you declare the dependencies
taskB.dependsOn tasksA
force the order of the task (in add of the dependency)
taskB.mustRunAfter(taskA)
add logs, to see if the task is executed VS the tasks does not do what you expect.
Adding dependencies to a task / Ordering tasks
http://www.gradle.org/docs/current/userguide/more_about_tasks.html
please, provide us with the solution once you got it !
Related
I'm getting this error in console while building my android project. Please help me understand this.
Messages:
Error:FAILURE: Build failed with an exception.
What went wrong:
Task 'prepareReleaseUnitTestDependencies' not found in project ':app'.
Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Gradle:
buildscript
{
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
//subprojects are added here
project(':external:calendar') {
apply plugin: 'android-library'
android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
lintOptions {
abortOnError false
}
}
}
project(':external:colorpicker') {
apply plugin: 'android-library'
android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
}
project(':external:datetimepicker') {
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:25.3.1'
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
lintOptions {
abortOnError false
}
}
}
project(':external:timezonepicker') {
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:25.3.1'
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
}
}
lintOptions {
abortOnError false
}
}
}
project(':external:chips') {
apply plugin: 'android-library'
android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
lintOptions {
abortOnError false
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile project(':external:calendar')
compile project(':external:colorpicker')
compile project(':external:datetimepicker')
compile project(':external:timezonepicker')
compile project(':external:chips')
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.1'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
}
useLibrary 'org.apache.http.legacy'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src', 'external/ex/common/java'] // NOTE: this includes external/ex/common/java!
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
/*
* To sign release build, create file gradle.properties in ~/.gradle/ with this content:
*
* signingStoreLocation=/home/key.store
* signingStorePassword=xxx
* signingKeyAlias=alias
* signingKeyPassword=xxx
*/
if (project.hasProperty('signingStoreLocation') &&
project.hasProperty('signingStorePassword') &&
project.hasProperty('signingKeyAlias') &&
project.hasProperty('signingKeyPassword')) {
println "Found sign properties in gradle.properties! Signing build…"
signingConfigs {
release {
storeFile file(signingStoreLocation)
storePassword signingStorePassword
keyAlias signingKeyAlias
keyPassword signingKeyPassword
}
}
buildTypes.release.signingConfig = signingConfigs.release
} else {
buildTypes.release.signingConfig = null
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
task customClean(type: Delete) {
delete rootProject.buildDir
}
clean.dependsOn customClean
perhaps you need to delete " -x prepareReleaseUnitTestDependencies" from :
Setting / build,execution, deployment/ compiler/ command-line Options
.
i added facebook sdk and AndroidMidi and i think i did it ok including dependencies and add model dependency on project structure
that is my build file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
}
}
apply plugin: 'android'
dependencies {
compile project(':facebook')
compile project(':AndroidMidi')
}
repositories {
jcenter()
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
i can't get it running,
i get this error:
Error:Execution failed for task ':packageDebug'.
Failed to seal APK,
help?
EDIT
thats settings.gradle
include ':facebook', ':AndroidMidi'
stacktrace log returns:
:packageDebug Failed and same error
not enough rep to upload picture
Removing the file MidiPlayer/src/META-INF/MANIFEST.MF fixed it for me.
See: https://github.com/tkirshboim/btmidi/commit/7486ccbf17a6c2c36ef642bfb03fb9e13352c369
I am trying to make my project use gradle. The problem is that everytime I try to build, I get the following error:
Error:Internal error: (java.lang.AssertionError) Unexpected node Android Packaging; nodes=[Module 'Serengeti' production, Resources for 'Serengeti' production, Resources for 'Serengeti' tests, Artifact 'Serengeti', gradle-resources-production:Serengeti, gradle-resources-test:Serengeti, Android Gradle Build Target]
java.lang.AssertionError: Unexpected node Android Packaging; nodes=[Module 'Serengeti' production, Resources for 'Serengeti' production, Resources for 'Serengeti' tests, Artifact 'Serengeti', gradle-resources-production:Serengeti, gradle-resources-test:Serengeti, Android Gradle Build Target]
at com.intellij.util.graph.GraphGenerator.buildOuts(GraphGenerator.java:55)
at com.intellij.util.graph.GraphGenerator.<init>(GraphGenerator.java:36)
at com.intellij.util.graph.GraphGenerator.create(GraphGenerator.java:40)
at org.jetbrains.jps.builders.impl.BuildTargetIndexImpl.initializeChunks(BuildTargetIndexImpl.java:86)
at org.jetbrains.jps.builders.impl.BuildTargetIndexImpl.getSortedTargetChunks(BuildTargetIndexImpl.java:50)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:610)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:352)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:191)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:131)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:229)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:158)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
I have no idea what this means. I found this but it's not really helpful...
This is my build.gradle file. This is my first time using gradle so if there is anything wrong with this please point it out.
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/repo' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.+'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/repo' }
}
dependencies {
// http://gradleplease.appspot.com/
compile 'com.android.support:support-v4:20.+'
compile 'com.google.android.gms:play-services:+'
compile 'joda-time:joda-time:+'
compile 'com.googlecode.android-query:android-query:+'
compile 'me.dm7.barcodescanner:zbar:+'
compile 'com.github.asne.facebook:facebook:3.17.2'
compile('com.twitter.sdk.android:twitter:1.0.1#aar') {
transitive = true;
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
lintOptions {
abortOnError false
}
signingConfigs {
SignConfig {
keyAlias 'removed'
keyPassword 'removed'
storeFile file('removed')
storePassword 'removed'
}
}
buildTypes {
debug {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
release {
zipAlignEnabled
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
}
productFlavors {
RunConfig {
signingConfig signingConfigs.SignConfig
}
}
}
How can I fix this error?
Found the solution to this problem. If you go to Project Structure -> Modules -> <Your project> -> Android, you will notice that nothing loads. It will look like this:
In order to fix this, select Android and click Remove (the red dash above). Then click Add (the green plus above) and select Android. Click OK and the error should be gone now.
I am using Robotium for my test case. When i am using eclipse for run a test case it is working and showing 2 fail result but when i am using gradle for test case it is showing BUILD SUCCESSFUL.But in my code 2 fail results.
I am using this command - gradle clean connectedCheck build
My build.gradle file--
buildscript { repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('MyTestCase')
instrumentTest {
java.srcDirs = ['MyTestCase/src']
manifest.srcFile file('MyTestCase/AndroidManifest.xml')
resources.srcDirs = ['MyTestCase/src']
res.srcDirs = ['MyTestCase/res']
assets.srcDirs = ['MyTestCase/assets']
}
}
dependencies {
compile files('libs/android-support-v4.jar')
}
lintOptions {
abortOnError false
}
}
In my current build scripts I have special /res/ and /assets folders that I copy over the working versions of the files at build time. In /assets/ is bundled data (sql and a text file) while in /res/values/ I have a connection.xml values file.
There are already duplicates of these files in the working directory, however at build time I want to use the ones from the /config/ folder of my project and copy them over the ones in the /res and /assets for the current build.
In my verbose logging I get a
"com.android.ide.common.res2.DuplicateDataException" when it tries to copy the file.
Any idea's how to handle this? I can make the filename unique, but the key/value pairs inside it will not be? Would that solve the issue?
My Build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.0'
}
}
apply plugin: 'android'
android {
compileSdkVersion "Google Inc.:Google APIs:18"
buildToolsVersion "17"
signingConfigs {
release {
storeFile file("../../TioClient/keystore/android.keystore")
storePassword "REDACTED"
keyAlias "pge-android"
keyPassword "lightmaker"
}
}
buildTypes {
dev {
signingConfig signingConfigs.release
}
tps {
signingConfig signingConfigs.release
}
production {
signingConfig signingConfigs.release
}
}
defaultConfig {
minSdkVersion 8
targetSdkVersion 15
}
dependencies {
compile project(':TioClient');
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = []
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
tps {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = []
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res','config/tps/res']
assets.srcDirs = ['assets', 'config/tps/assets']
}
instrumentTest.setRoot('tests')
}
}
You can define assets at the buildtype level or product flavor level by including appropriate folders in your src.
Build type resources override flavor resources which override main resources.