build.gradle

Gradle project refresh failed in Android Studio 1.2.1.1

谁说胖子不能爱 提交于 2019-12-22 10:53:46
问题 I created sample project on the fresh installation of the Android Studio v 1.2.1.1 and i faced with this error message: Gradle project refresh failed in Android Studio 1.2.1.1 See image below: So i tried to find any solution on the Google and i checked gradle.properties file where is: dependencies { classpath 'com.android.tools.build:gradle:1.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } After that i tried to update

android Volley library NegativeArraySizeException

不想你离开。 提交于 2019-12-22 10:52:45
问题 I'm getting this NegativeArraySizeException from Volley library. This error started after I changed Volley android-library-module to a maven dependencies like compile 'com.android.volley:volley:1.0.0' I've this singleton pattern and I change the addToRequestQueue method to avoid double request bug with following link: public <T> void addToRequestQueue(Request<T> req) { req.setRetryPolicy(new DefaultRetryPolicy( 0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT

How do I overwrite a task in gradle kotlin-dsl

梦想与她 提交于 2019-12-22 10:28:08
问题 In Groovy, I overwrite a task like this: task jar(overwrite: true) { ... } How do I do that with Kotlin-dsl? I know that I can create a task like this: tasks { val jar by creating { ... } } but I can't find the equivalent way to declare it as overwrite, this leads to an error 回答1: By opening an issue on the kotlin-dsl github I found the correct syntax: tasks.replace("jar") { ... } However, this is the old way and does not work within a tasks { } block, so this issue will be further tracked

Can I get properties defined in “gradle.properties” in JAVA STATEMENT?

纵饮孤独 提交于 2019-12-22 09:15:03
问题 I defined a property in gradle.properties file like below: user.password=mypassword Can I use it as a variable value in my java statement? 回答1: Yes you can, however this is not a good idea nor a good practice. gradle.properties file is meant to keep gradle's properties itself, e.g. JVM args used at build time. If you need to store user/pass pair in properties file, it should be placed under src/main/resources or other appropriate folder and separate from gradle.properties . Side note: Not

Can't generate signed APK in Android Studio, 'java.io.IOException'

佐手、 提交于 2019-12-22 08:34:20
问题 I have a problem with generating signed APK in Android Studio. It was working fine few days ago, I dont know what went wrong. I'm getting this error for any project I try to fgenerate signed APK of: Warning:Exception while processing task java.io.IOException: Can't write [/Users/bhaveshmisri/Downloads/littleone-dagger-mvp/app/build/intermediates/transforms/proguard/release/jars/3/1f/main.jar] (Can't read [/Users/bhaveshmisri/Downloads/littleone-dagger-mvp/app/build/intermediates/transforms

Gradle dependency version syntax

人盡茶涼 提交于 2019-12-22 08:23:33
问题 I'm new to gradle. I have such a dependecy im my gradle script: compile group: 'com.ning', name: 'async-http-client', version: '[1.6.1,1.9[' Could someone explain me, what does this version: '[1.6.1,1.9[' mean in this case? 回答1: It's Ivy-style versions range, take a look here. In this case, this means, version can be greater or equal to 1.6.1 and lower than 1.9. 来源: https://stackoverflow.com/questions/32623290/gradle-dependency-version-syntax

set applicationIdSuffix depending on productFlavor

拟墨画扇 提交于 2019-12-22 06:58:46
问题 We have 2 productFlavors ( testServer, liveServer ) and 2 build types ( debug, release). Due to existing API keys, I have to append package names based on buildType + productFlavor. For example something like: buildTypes { debug { applicationIdSuffix '.dbg' + (testServer ? '.test' : '.live') } release { applicationidSuffix '' + (testServer ? '.test') } } is this possible? how? 回答1: productFlavors { testServer { applicationId = "com.example.my.pkg.test" } liveServer { applicationId = "com

How to enable Java 8 language features in Android studio

时光总嘲笑我的痴心妄想 提交于 2019-12-22 05:59:29
问题 Now release with Android Studio 2.4 Preview 4, it is now support Java 8 language features. Jack is no longer required, and need to disable Jack to use the improved Java 8 support built into the default toolchain. Now we need to disable Jack and switch to the default toolchain. How enable Java 8 features to use in android studio project? 回答1: Enable Java 8 Support : To start using supported Java 8 language features, update the Android plugin to 2.4.0-alpha4 (or higher) and add the following to

Build gradle : Could not find method packagingOptions() for arguments root Project “fasterDev”

空扰寡人 提交于 2019-12-22 05:45:11
问题 I am using single build.gradle file in application. Regarding version 1.6 it's working properly. but I want to use this for location update with module. apply plugin: 'com.android.application' ... dependencies { compile 'com.google.android.gms:play-services:fp9.0.0' } Here is my build.gradle. build.gradle buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' } } apply plugin: 'android' dependencies { compile fileTree(dir: 'libs', include

How to parse .json file with a gradle task and get the json data from it?

旧街凉风 提交于 2019-12-22 05:45:09
问题 Is there a way where in I can parse a xyz.json file with help of a gradle task and get all the individual json data inside it? for eg. I want to parse this data which is stored in a xyz.json file in my assets folder and get all the values inside it, eg. get the value of "type". { "type":"xyz", "properties": { "foo": { "type": "pqr" }, "bar": { "type": "abc" }, "baz": { "type": "lmo" } } } 回答1: You can create a gradle task like this gradle myTask{ doLast{ def inputFile = new File("xyz.json")