Gradle finished with non-zero exit value 2? - android

I am trying to integrate Google Sign-in into my app
Google developer.
As mentioned I have also added to build.gradle files as follows:
dependency to project's top-level build.gradle:
classpath 'com.google.gms:google-services:1.4.0-beta3'
plugin to app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
when I start syncing,it downloads some stuff.
But after running it shows error that Gradle finished with non-zero exit value 2.
Currently I am using Android Studio v1.4

The most probable cause of this would be, you have a lot of libraries and thus lots of methods. Try enable multiDex in your app's build.gradle like below
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "in.alphawolf.wallmax"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true // Like this
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
and you will be able to build your project!

Related

Android app is not building after change the android studio version

I created an Android app using the android studio (2016) with the following parameters
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.2.1'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.stl.sciocardio.app.androidapp"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Also, I use third party projects inside the project as well. When I change the Android studio 2020 the app is not built or even not detected as an android project. It gives me the following error once I try to rebuild it
Unable to find Gradle tasks to build: [:app, :, :GraphView-master].
Build mode: REBUILD.
Tests: None.
How can I fix the issue?
Try this:
Delete folders [build, .idea, .gradle]
Invalidate Caches / Restart
If it does not get resolved, then repeat the above step by removing
include ':app' from settings.gradle

firebase messaging notification .dex file cannot exceed 64K on android studio

After I add Firebase to receive Push Notifications to my app, it gives me this error:
I tried to put multiDexEnabled true on defaultConfig
and compile 'com.android.support:multidex:1.0.0' on dependencies, but the problem still persists.
This is my build.gradle
apply plugin: 'com.android.application'
defaultConfig {
applicationId "com.egcd.egypt"
minSdkVersion 15
targetSdkVersion 23
versionCode 2
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Any help?
Try removing compile compile 'com.google.android.gms:play-services:10.2.0'
from your project dependencies.
You should never depend on com.google.android.gms:play-services because that is a gigantic library that groups together every Google library for android in a single archive.
Instead you should use com.google.android.gms:play-services-[LIBRARY.YOU.NEED]

Cannot resolve symbol (after Android Studio update) but the project builds for app/library project

I have an an Android Studio project A which is an app, and a project B which is a library project. I have included project B in project A. Project B has some dependencies (android async http, and org.json) that are used in both project B and project A. I upgraded Android Studio to 2.2 Preview 2, and am now having an issue where all of my usages of android async http are saying Cannot Resolve Symbol. However, my JSON usages are just fine. When I build the project, I get no errors and can run it just fine. How can I fix the Cannot Resolve Symbol issue in Android Studio?
I have tried
cleaning & rebuilding both projects
making a change in the app's build.gradle & syncing grade
re-arranging the order of dependencies
sync project with gradle files
delete android async http.xml from .idea/libraries & sync project with gradle files
opening and closing android studio
setting minifyEnabled=true in the app & library
Is there something I am missing?
app > build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 33
versionName "2.3"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile project(':mylibrary')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v13:21.0.3'
}
library > build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 2
versionName "1.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile files('libs/org.json-20120521.jar')
compile files('libs/android-async-http-1.4.5.jar')
}

Android studio importing in gradle issue

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.

Gradle build fails in Android Studio

I am using Android Studio and created a new project, which created the standard "Hello world" mock.
My gradle.build file has the following contents:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.whatever.blabla"
minSdkVersion 19
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Even though I did not change anything, Gradle still fails when trying to build it with the error:
Failed to complete Gradle execution.
Cause:
A fatal exception has occurred. Program will exit.
First of all, is there any way of getting extra info about the problem? And secondly, why is this happening since I only created a standard project?
I had the same problem and could fix it by following solution provided in the below link -
https://code.google.com/p/android/issues/detail?id=67946
Though I am not sure how setting the maxheapsize has fixed the issue.

Categories

Resources