android-gradle

Copying APK file in Android Gradle project

▼魔方 西西 提交于 2019-11-28 03:27:49
I'm trying to add a custom task to my Android project's build.gradle to copy the final APK and Proguard's mapping.txt into a different directory. My task depends on the assembleDevDebug task: task publish(dependsOn: 'assembleDevDebug') << { description 'Copies the final APK to the release directory.' ... } I can see how to do a file copy using the standard Copy task type, as per the docs: task(copy, type: Copy) { from(file('srcDir')) into(buildDir) } but that assumes you know the name and location of the file you want to copy. How can I find the exact name and location of the APK file which

What Product Flavor does Android Studio build by default in build.gradle?

社会主义新天地 提交于 2019-11-28 03:21:31
We have an Android project that uses the new Gradle build system, and we use Android Studio as a development tool. When there are several product flavors specified in build.gradle , we notice that Android Studio builds the first one specified alphabetically. Is there a way to tell Android Studio to build and test only a specific product flavor during development? On the lower left of the Studio window there's a docked view called "Build Variants". Open it and choose whichever variant you want to work on. This will impact which variant is built but also the enabled source folders, which will

Gradle: More than one variant of project :myLib matches the consumer attributes

霸气de小男生 提交于 2019-11-28 03:14:10
A library that I wrote myLib uses RemoteMessage from Firebase , the app itself also uses Firebase . Using gradle 4.7. Also facing this in 4.4.1. How to fix it? project.gradle buildscript { repositories { google() jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.google.gms:google-services:3.3.0' } } allprojects { repositories { google() jcenter() mavenCentral() mavenLocal() } } task clean(type: Delete) { delete rootProject.buildDir } app.gradle apply plugin: 'com.android.application' android { compileSdkVersion 27 defaultConfig {

Is it possible to declare git repository as dependency in android gradle?

为君一笑 提交于 2019-11-28 03:07:38
I want to use master version of my lib from mavencentral. Is it possible to declare git repository as dependency in android gradle? sunnyday For me the best way is: https://jitpack.io Step 1. Add the JitPack repository to build.gradle at the end of repositories: repositories { // ... maven { url "https://jitpack.io" } } Step 2. Add the dependency in the form dependencies { compile 'com.github.User:Repo:Tag' } It is possible to build the latest commit on the master branch, for example : dependencies { compile 'com.github.jitpack:gradle-simple:master-SNAPSHOT' } trupin Or you can register a

Error:Jack is required to support java 8 language features [duplicate]

懵懂的女人 提交于 2019-11-28 02:59:58
This question already has an answer here: How to enable Jack (Java Android Compiler Kit) in android studio 6 answers When I tried to update my android project to use Java 8 after getting android studio 2.1 and android N SDK by adding compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } I had this error Error:Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8. What should I do? Error:Jack is required to support java 8 language features. Either enable Jack or remove

How can I access a BuildConfig value in my AndroidManifest.xml file?

☆樱花仙子☆ 提交于 2019-11-28 02:56:12
Is it possible to access a BuildConfig value from AndroidManifest.xml? In my build.gradle file, I have: defaultConfig { applicationId "com.compagny.product" minSdkVersion 16 targetSdkVersion 21 versionCode 1 versionName "1.0" // Facebook app id buildConfigField "long", "FACEBOOK_APP_ID", FACEBOOK_APP_ID } FACEBOOK_APP_ID is defined in my gradle.properties files: # Facebook identifier (app ID) FACEBOOK_APP_ID=XXXXXXXXXX To use Facebook connect in my app, I must add this line to my AndroidManifest.xml: <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/applicationId"

Is there a safe way to manage API keys?

回眸只為那壹抹淺笑 提交于 2019-11-28 02:54:06
I am using an API within my app. I currently manage the API key from a java interface public interface APIContract { //The API KEY MUST NOT BE PUBLISH. It is possible to generate a new one for free from www.themoviedb.org //Remove before commit !!! String API_KEY = "abcdefghijklmnopqrstuvwxyz"; /... } This do the job. I can access the key using APIContract.API_KEY , but as you can see in the comment this is not safe if I use git and a public repository (I am not suppose to publish this key). So here is my question : is it possible to move this key in another place which I can easily access

Gradle, Android and the ANDROID_HOME SDK location

做~自己de王妃 提交于 2019-11-28 02:49:24
edit: (aug-2016) That question is from November 2013 (while Android Studio was still in Developer Preview mode), Currently (AS v2.2, Aug-2016) during instalation AS asks to choose the SDK folder (or install on their default) and it automatically applies to which ever project you're opening. That means any possible workaround or fix is irrelevant as the issue is not reproducible anymore. original question: we have this project with several modules that is already configured and executes correctly on another developer PC using a wrapper. I cloned the complete git submodules into my machine.

Common code for different android flavors

纵然是瞬间 提交于 2019-11-28 02:47:45
I am building 4 different flavors of my Android app. I have a class Customization.java that is the same for 3 of them and different for 1. Since I cannot put the same class both in the main folder and in the flavor folder, I now have to maintain 3 copies of the exact same class for those 3 flavors. Is there any way that I could do with keeping just two versions of this class? Things I have considered so far: I looked at flavor dimensions, but turns out they are not applicable in this case. Keeping just one file in one of the flavors and copying it through my build script. I am wondering if

How to set gradle home while importing existing project in Android studio

≯℡__Kan透↙ 提交于 2019-11-28 02:44:19
How to set gradle home while importing existing project in Android studio. While trying to import I need to set up this path. The gradle plugin (which contains a bundled version of gradle) should be already installed in where/you/installed/android-studio /plugins/gradle so you shouldn't need to manually download it. Depending on the version of Android Studio, that last directory may be where/you/installed/android-studio /gradle/gradle-x.y.z (x.y.z is the version, so check your filesystem for the exact path). If you intend on doing gradle development outside Android Studio or want a different