I am looking for a way to copy src/main/res/values/* to /src/main/assets/www/xml/
I would like this to happen on compile, so I've been trying to get gradle to do such a thing, but with no success.
I appreciate any help with this :)
I have added my current gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "name"
minSdkVersion 1
targetSdkVersion 21
versionCode 123
versionName "123"
}
}
dependencies {
A huge bunch
}
Based on the copy task given from Enrico I made this work:
task myCopy(type: Copy) {
from 'src/main/res/values'
into 'src/main/assets/www/xml'
}
project.afterEvaluate {
prepareDebugDependencies.dependsOn myCopy
}
Create a copy task and make it a dependency of the compile task
task myCopy(type: Copy) {
from 'src/main/res/values'
into 'src/main/assets/www/xml'
}
assemble.dependsOn myCopy
EDIT: I assumed you had a compile task. Use assemble instead
Related
I wanted to compile my android studio project, somehow i ran into an error with firebase crashalytics. So I tried to fix the issue.
what I have now:
buildscript {
repositories {
...
maven { url = "https://maven.fabric.io/public" }
}
dependencies {
...
classpath "io.fabric.tools:gradle:1.25.1"
}
}
apply plugin: 'com.android.feature'
apply plugin: 'io.fabric'
So far so good, theoretically that should be it, from what I've read online. But I get an error now, ERROR: Cause: compileSdkVersion is not specified. so i googled this error, but all the solutions i found online where about the compileSdkVersion abd the targetSdkVersion differ.
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
applicationId 'ch.workouttracker'
minSdkVersion 24
targetSdkVersion 29
versionCode 11
versionName '0.7.6'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "de" // And any other languages you support
}
so this is not the case here, what else should I try?
I would like to add a gradle task to my Android build under Android Studio. Various on-line documentation shows clearly how to create a task, but not where to place it in a build.gradle file and which one of them.
A simple, complete example would be perfect.
BTW, I'd like to add a pre-build task to prepare some data, and maybe a post-build task to do some verification/validation.
By trial-and-error and input from Martin Zeitler, I successfuly added pre- and post-build tasks to my build.gradle (app module) as shown below:
This works perfectly.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "MyPackage"
minSdkVersion 11
targetSdkVersion 26
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
// My libraries here
}
// MY PREBUILD TASK
task PreBuild {
println "MY PRE-BUILD TASK"
}
// MY POSTBUILD TASK
gradle.buildFinished {
println "MY POST_BUILD TASK"
}
}
I have an Android application ("myapp") that uses an Android library ("mylib").
I need to get mylib build.gradle versionCode from the application build.gradle.
This is what I have for now:
mylib's build.gradle:
apply plugin: 'com.android.library'
android {
...
defaultConfig {
...
versionCode 42
...
}
...
}
myapp's settings.gradle:
include ':myapp', ':mylib'
myapp's build.gradle:
apply plugin: 'com.android.application'
...
android {
...
defaultConfig {
...
versionCode project(":mylib").versionCode
...
}
...
}
But Gradle outputs the error:
Could not find property 'versionCode' on project ':mylib'
Do you have any idea?
This question already has answers here:
Android Test Module (Gradle Plugin 1.3) doesn't work: "debug-classes not found"
(2 answers)
Closed 7 years ago.
We have a project which is using flavors and want to use the new com.android.test plugin available with gradle 1.3 to have our integration tests in a separate project. We've followed the instructions here, but when we try to sync gradle we get the following error:
Error:Configuration with name 'MyFlavorDebug-classes' not found.
Here is our test project's build.gradle file. We have a matching flavor in our app.
buildscript {
repositories {
mavenCentral()
jcenter()
}
}
apply plugin: 'com.android.test'
android {
compileSdkVersion 21
buildToolsVersion = '22.0.1'
targetProjectPath ':MyApp'
targetVariant 'MyFlavorDebug'
}
You should have a structure like this:
root
app
build.gradle
flavor1test
build.gradle
In app/build.gradle
android{
defaultConfig {
applicationId 'com.example.myapp'
}
productFlavors {
flavor1 {
//
}
}
}
In flavor1test/build.gradle something like:
apply plugin: 'com.android.test' // A plugin used for test-only-modules
android {
compileSdkVersion 22
buildToolsVersion = '23.0.0rc3'
defaultConfig {
minSdkVersion XX
targetSdkVersion 22
// The package name of the test app
testApplicationId 'com.example.myapp'
// The Instrumentation test runner used to run tests.
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
// Set the target app project.
targetProjectPath ':app'
targetVariant 'flavor1Debug'
}
dependencies {
// Android Testing Support Library's runner and rules and hamcrest matchers
}
I've followed following topic with no result. Decided to find|grep all support-v4 contents in project folder and remove them. Every time I make and run project it respons with:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
My build.gradle from module is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.android"
minSdkVersion 14
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.2.+'
compile 'com.android.support:appcompat-v7:+'
}
build.gradle from project root:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
}
}
allprojects {
repositories {
jcenter()
}
}
I know it is similar topic but suggested sollution does not fit this case.
I would appreciate any explanation of this all dependencies structure which might have impact in that problem.
When we find|grep for "support-v4" inside this project folder it looks like this:
...\.gradle\1.12\taskArtifacts\fileSnapshots.bin
...\.gradle\1.12\taskArtifacts\taskArtifacts.bin
...\.idea\workspace.xml
...\.idea\libraries\support_v4_21_0_0_rc1.xml
...\app\app.iml
...\app\build.gradle
...\app\build\intermediates\incremental\mergeResources\debug\merger.xml
...\build\intermediates\model_data.bin
Regards
Replace:
compile 'com.android.support:appcompat-v7:+'
with:
compile 'com.android.support:appcompat-v7:19.1.0'
In general, do not use + wildcards at the top version level. If you wanted to use 19.1.+, or even 19.+, I wouldn't argue (though others would).