Gradle build failed in Android Studio 1.5.1 - java

I'm unable to run my app. Every time I'm trying to run my app in emulator Android studio shows me following error.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 2
Here's my build.gradle files.
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.gripxtech.kasim.unipayretailer"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.malinskiy:superrecyclerview:1.1.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.codinguser.android:contactpicker:3.0.0#aar'
compile 'com.squareup.okhttp:okhttp:2.7.0'
compile project(':materialdatetimepick')
}
build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
I've already tried to apply solution from many question similar to mine but, still I can't solve my issue. Thanks in Advance.

Add this to build.gradle file:
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
Here you would find an explanation why this error happened:
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define
If it wouldn't work, please delete all files and folders from:
YOUR_APP_NAME\app\build\intermediates
It sometimes happens when you have duplicated dependencies with different versions
Try this command and check if there something twice:
./gradlew dependencies
Hope it help

Related

Error:(11, 0) Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed

Hello i am working now on android application with 2 modules the first is my app with buildgradle like
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.alexvasilkov:android-sign-release:0.8.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.alexvasilkov.sign'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "dz.condorpos"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
storeFile file("foldable-layout-release-key.keystore")
keyAlias "release"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':library')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.github.barteksc:android-pdf-viewer:1.4.0'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.alexvasilkov:android-commons:2.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.afollestad:easyvideoplayer:0.3.0'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
the second module is a library included to my project here is the buildgradle(module:library):
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
}
}
// New version can be uploaded with 'gradlew clean :library:jar :library:uploadArchives'
apply from: 'gradle-mvn-push.gradle'
dependencies {
}
the project buildgradle is like :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects { project ->
repositories {
jcenter()
maven { url 'https://dl.bintray.com/drummer-aidan/maven' }
}
// Enabling checkstyle for all sub projects
project == rootProject || project.afterEvaluate {
project.apply plugin: 'checkstyle'
project.extensions.getByName('checkstyle').with {
toolVersion = '6.15'
configFile file("${rootDir}/checkstyle.xml")
}
task checkstyle(type: Checkstyle) {
source 'src'
include '**/*.java', '**/*.xml'
classpath = files()
}
project.tasks.getByName('check').dependsOn 'checkstyle'
project.extensions.getByName('android').with {
lintOptions {
ignore 'GoogleAppIndexingWarning', 'ContentDescription'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}
the project was working perfectly till yesterday when i added a compile dependencies of picasso in my app module after the gradle sync failed it show this
Error:(11, 0) Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.
now even if i remove picasso the error still happening Of course I did not ask the question before long research i found some solutions but didnt work like this
note : an old version of my project still working normal with the same clean task but after some gardle syncs i will get this problem.
I would like to thank you in advance for your assistance
After so many research i found we have to just comment the line of clean task in bulid.gradle(Project) like below :
// task clean(type: Delete) {
// delete rootProject.buildDir
// }][1]

Android import project fails

I am trying to import a project in android Studio but if Fails
Following is the project:
project
I get this error:
> C:\xampp\htdocs\freedom\Android-IP-Camera-master\spydroid-ipcamera-master\app\build\intermediates\res\merged\debug\values-ldltr-v21\values-ldltr-v21.xml
> Error:(3) Error retrieving parent for item: No resource found that
> matches the given name 'android:Widget.Material.Spinner.Underlined'.
> Error:(3) Error retrieving parent for item: No resource found that
> matches the given name 'android:Widget.Material.Spinner.Underlined'.
> C:\xampp\htdocs\freedom\Android-IP-Camera-master\spydroid-ipcamera-master\app\build\intermediates\res\merged\debug\values-v21\values-v21.xml
> Error:(17) Error retrieving parent for item: No resource found that
> matches the given name 'android:TextAppearance.Material.Inverse'.
EDIT:
Below are both gradle files of the project.
build.gradle (Module:app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "net.majorkernelpanic.spydroid"
minSdkVersion 14
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/acra-4.4.0.jar')
compile files('libs/GoogleAdMobAdsSdk-6.1.0.jar')
compile files('libs/sc-light-jdk15on-1.47.0.2.jar')
compile files('libs/scpkix-jdk15on-1.47.0.2.jar')
compile files('libs/scprov-jdk15on-1.47.0.2.jar')
}
build.gradle(Project: spydroid-ipcamera-master):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
}
}
First of all change
compile files('libs/acra-4.4.0.jar')
compile files('libs/GoogleAdMobAdsSdk-6.1.0.jar')
compile files('libs/sc-light-jdk15on-1.47.0.2.jar')
compile files('libs/scpkix-jdk15on-1.47.0.2.jar')
compile files('libs/scprov-jdk15on-1.47.0.2.jar')
to compile fileTree(include: ['*.jar'], dir: 'libs')
second try to use the app combat library, cause some resources are missing
compile 'com.android.support:appcompat-v7:25.4.0'
or you can up your compileSdkVersion && targetSdkVersion to 21+
I import related project and chages some thing in build.gradle to last version that recomended by AS.
Change your build.gradle (Module:app) with this and try:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "net.majorkernelpanic.spydroid"
minSdkVersion 14
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services:11.0.0'
compile files('libs/acra-4.4.0.jar')
compile files('libs/GoogleAdMobAdsSdk-6.1.0.jar')
compile files('libs/sc-light-jdk15on-1.47.0.2.jar')
compile files('libs/scpkix-jdk15on-1.47.0.2.jar')
compile files('libs/scprov-jdk15on-1.47.0.2.jar')
}
In my case project sync and run perfectly.
UPDATE:
I'll add that you must also change deprecated apache HttpClient with the new HttpURLConnection.
For this purpose add below code to your build.gradle (Module:app) : useLibrary 'org.apache.http.legacy'

Error:Execution failed for task dexDebug'. C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2

Hi all: I am trying to bring a program from Eclipse to Android Studio. Doing so I've encountered many errors which I have solved using the help of Stackoverflow and my intuition. However, I havent been able to solve this issue as I see no duplicates in my program as links have stated to look for and i have no idea where to look.
The complete error is
Error:Execution failed for task ':tourismApp:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2
Research and reading has brought me to this link
Java finished with non-zero exit value 2 - Android Gradle
However nothing worked, not even multidex true.
would like if anyone could let me know if my situation is somewhat unique.
Project Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.iziss.tourismapp"
minSdkVersion 15
targetSdkVersion 23
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v7'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile project(':facebook')
compile 'com.google.android.gms:play-services:7.5.0'
// compile files('libs/httpclient-4.0.1.jar')
// compile files('libs/httpmime-4.2.2.jar')
// compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
// compile files('libs/signpost-core-1.2.1.1.jar')
// compile files('libs/twitter4j-core-4.0.4.jar')
// compile files('libs/universal-image-loader-1.2.1.jar')
compile "org.apache.httpcomponents:httpcore:4.3.2"
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Facebook Gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
// compile files('libs/bolts-android-1.1.2.jar')
compile 'com.android.support:support-annotations:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}

Execution failed for process app:dexDebug after adding BaseGameUtils

I just imported baseGameUtils to my android game in order to add a Google play Leaderboard however, when I press play I get this error: `Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2`
I tried following the instructions from these two pages: Stackoverflow question 1, Stackoverflow question 2.
I tried setting the google support libraries to 22.2.1 and 8.1.0 in the basegameutils build.gradle, but then I get missing dependencies in the .java files in that library.
I'm all out of ideas and in need of help.
Thank you all in davance.
app:build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.honeycomb.touchtycube"
minSdkVersion 14
targetSdkVersion 22
versionCode 11
versionName "1.1.6"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile project(':facebook');
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile 'com.google.android.gms:play-services-games:8.1.0'
compile project(':BaseGameUtils')
//compile project(':libs:basegameutils')
//compile 'com.purplebrain.adbuddiz.sdk:AdBuddiz-Java:3.0.15'
compile files('src/main/java/com/honeycomb/touchtycube/testapp/libs/AdBuddiz-3.0.15.jar')
}
repositories {
maven {
url 'http://repository.adbuddiz.com/maven'
}
}
BaseBuildUtils:build_gradle:
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
dependencies {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!hasProperty('appcompat_library_version')) {
ext.appcompat_library_version = '20.0.+'
}
if (!hasProperty('support_library_version')) {
ext.support_library_version = '20.0.+'
}
if (!hasProperty('gms_library_version')) {
ext.gms_library_version = '7.8.0'
}
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile "com.google.android.gms:play-services-games:${gms_library_version}"
compile "com.google.android.gms:play-services-plus:${gms_library_version}"
compile "com.google.android.gms:play-services-appstate:${gms_library_version}"
}
android {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!hasProperty('android_compile_version')) {
ext.android_compile_version = 20
}
if (!hasProperty('android_version')) {
ext.android_version = '20'
}
compileSdkVersion android_compile_version
buildToolsVersion android_version
}
EDIT:
I can do a "make Project" without any errors, the errors only appear when I do a "run app" (Or well I guess it's technically "run 'configuration'").
Check you prograud rules once. Also add your gradle build file.

Android Studio - Failed to resolve library in gradle

I have tried to import multiple libary for project in android studio.But it always shows error like
For this, I tried multiple solution like sdk update , studio update , build.gradle update and so on.Eventhough, i could not get any result.anyone give solution please.
Herewith I mentioned my gradle sepcification too.
app - build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.abof.android"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:7.5.0'
compile files('libs/volley.jar')
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':libraries:facebookV2')
compile files('libs/httpcore-4.3-beta1.jar')
compile files('libs/httpmime-4.3.5.jar')
compile project(':libraries:gson-2.2.4')
compile project(':libraries:citruslibrary')
}
project - build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}

Categories