I have created the following gradle.build file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName '1.0'
applicationId 'com.kibo.mobi.app'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
flavor1{
applicationId 'com.kibo.mobi.flavor1'
minSdkVersion 14
targetSdkVersion 20
}
flavor2{
applicationId 'com.kibo.mobi.flavor2'
minSdkVersion 14
targetSdkVersion 20
}
}
sourceSets {
flavor1{
manifest.srcFile 'flavor1/AndroidManifest.xml'
assets.srcDirs = ['src/flavor1/assets']
}
flavor2{
manifest.srcFile 'flavor2/AndroidManifest.xml'
assets.srcDirs = ['src/flavor2/assets']
}
}
}
dependencies {
compile project(':AppSDK')
}
Pressing the Play/Run button in Android Studio results in building, compiling and installing the "flavor1" version on the connected device.
How can I manually configure what version will be installed? When the default version (not a flavor - but the "main" folder) is also a version I need to install sometimes. So basically there are 3 version here that I need to have the ability to install each one of them as requested.
The "Build Variants" tool window (View menu > Tool windows > Build variants) lets you select which flavor + build type combination will be built and run by default.
Related
I Have build my app in android 6 without any error, but when I build my app in android 4.4.2 I get this error
This app has been built with an incorrect configuration.
Please configure your build for VectorDrawableCompat.
and this is my gradle:
android {
compileSdkVersion 24
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.faranegar.channel"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
note: when I set compileSdkVersion 23, every thing is fine and there isn't any error.
This worked well for me
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
generatedDensities = []
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Notice this in the above code:
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
and
generatedDensities = []
UPDATE
If this generatedDensities = [] is showing deprecated, use the following instead.
vectorDrawables.generatedDensities = []
Hope it helps
This issue was alread reported here Issue 214182: appcompat-v7 24.0.0 is incompatible with rasterized vectors.
One of the developer mention:
What version of the Gradle plugin are you using?
As of v2.0 of the Gradle plugin, library resources are never
rasterized so this should never happen.
The workaround for this is to update your Gradle by following this official link. Android Plugin for Gradle Release Notes.
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
if you are using rasterized vector drawables
for Gradle plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
...
}
}
for Gradle plugin before 2.0
android {
defaultConfig {
generatedDensities = []
...
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
you should add appcompat-v7 23.2.0+ to your build.gradle.for me,i am using
compile 'com.android.support:appcompat-v7:23.4.0'
This happened to me while implementing unit tests with JUnit and Robolectric. If that's your case maybe you need to add this to your gradle file, inside the android section. That's how I fixed it:
testOptions {
unitTests {
includeAndroidResources = true
}
}
When I try to sync gradle, it shows this error.
Warning:Unable to find optional library: org.apache.http.legacy
My build.gradle:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.myapp.mynamespace"
minSdkVersion 15
targetSdkVersion 23
versionCode 17
versionName "1.7"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions.encoding = 'UTF-8'
}
My root build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
I tried to use gradle 1.3.1 and buildToolsVersion 23.0.2 but it didn't work. There aren't many questions like this and they didn't resolved out. So I needed to ask this question to come to a fine end.
I had this problem before and the way I solved it was by copying the JAR into the libs/ folder of your project, Gradle will not resolve this jar automatically.
You should have a copy in your local machine already under SDK/platforms/android-23/optional
I am new to Android Studio and was just trying to import my eclipse project. i am trying to resolve this issue for quite a while now but unable to.
I have a mainactivity project which uses mmany other libraries staggeredgridview, devsmart, google maps and appcompactv7. I am getting following 2 errors.
Note: mainactivity project is the one which i am working on and uses other external libraries.
Error:(7, 5) uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library B:\Android Studio Projects\mainActivity\build\intermediates\exploded-aar\com.google.android.gms\play-services\6.5.87\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.google.android.gms" to force usage
:mainActivity:processDebugManifest FAILED
Error:Execution failed for task ':mainActivity:processDebugManifest'.
Manifest merger failed with multiple errors, see logs
build.gradle of mainactivity
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.staggeredgridviewdemo"
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':devsmartAndroid')
compile project(':staggeredGridViewmaster')
compile 'com.google.guava:guava:16.0.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/commons-codec-1.6.jar')
}
build.grade for devsmart
apply plugin: 'com.android.library'
android {
compileSdkVersion 14
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 4
targetSdkVersion 4
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
}
build.gradle for sttageredgridview
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
}
Just edit minsdk of your build.gradle of mainactivity to 9 :
defaultConfig {
applicationId "com.example.staggeredgridviewdemo"
minSdkVersion 9 // changed line
targetSdkVersion 16
}
Note : Also did the same for other libs if there minsdk is small then 9
Please open your manifest file and write the bellow code it will work
<uses-sdk tools:overrideLibrary="com.google.android.gms"/>
and add the list of libraries for uses-skd separated by comma
Go to all the manifest files or build.gradle files of all the projects and make the minSDKversions the same.8 for instance.
I am trying to add asset files to my android test project but somewhy assets from test dir are not available from inside test classes. What I am doing wrong?
The purpose is to have additional asset files for test cases.
Compilation is success from IDEA and command line, but test results are the same.
When I am trying to call getContext().getAssets().open("test.json") I have FileNotFoundException.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.0'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.0'
debugCompile 'com.android.support:support-v13:13.0.0'
compile 'com.google.android.gms:play-services:3.1.36'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
testBuildType "debug"
sourceSets {
androidTest {
assets.srcDirs = ['src/androidTest/assets']
}
androidTest.setRoot('src/androidTest')
}
defaultConfig {
versionCode 1
versionName "1.0"
minSdkVersion 14
targetSdkVersion 19
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
buildTypes {
debug {
applicationIdSuffix ""
}
}
}
Created an issure in the android tools project. Looks like a bug.
I'm getting the following error in Android Studio 0.4.2 when I'm trying to Sync project with gradle.
Gradle 'GooglePlayServicesTest' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'android()'!
My projects gradle file is as follows :-
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
android{
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
sourceSets{
main{
manifest.srcFile 'GooglePlayServicesTest/src/main/AndroidManifest.xml'
}
}
}
gradle file of module:-
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
also I have removed the miniSDKVersion and targetSDKVersion from AndroidManifest.xml
can someone help me to solve this error.
android method in project gradle file is not needed.Try to remove it.
Add top of your project build.gradle file:
apply plugin: 'com.android.application'