I recently added a new activity to my android studio project and now I am getting an error when I try and run it. It builds fine but I get the error below when I run it:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --output /Users/davidcavanagh/joshcpdandroid/app/build/intermediates/pre-dexed/debug/classes-22ecb8c50fefe43948d87c9fee8e36a6b7d1bb5a.jar /Users/davidcavanagh/joshcpdandroid/app/build/intermediates/exploded-aar/com.android.support/support-v4/20.0.0/classes.jar
Error Code:
1
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.joshcpd.android"
minSdkVersion 15
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'])
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.android.support:appcompat-v7:20.0.0'
compile project(':libraries:zbar')
}
I have tried removing the supportLappcompat dependency but then I get even more errors. Any help greatly appreciated.
I finally solved this issue by downloading the latest version of gradle.
I still get this error every so often and I just fix it by going to File ----> Invalidate caches/restart
I find Android Studio to be very buggy
Based on where it's trying to find the dx command:
/Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx
it looks like you've crossed a build tools version with something else. The build file you posted in your question looks okay, but look in the other build files in your project (there's at least going to be something in libraries/zbar) and make sure their buildToolsVersion statements are okay. I suspect somewhere you have:
buildToolsVersion 'android-4.4W'
where you should have:
buildToolsVersion '20.0.0'
Now i know the reason of the problem. It was causes by wrong code in \sdk\android-sdk\tools\lib\find_java.bat
Wrong code:
find /i "x86" > NUL && set arch_ext=32 || set arch_ext=64
Correct code:
find /i "x86" > NUL && set arch_ext=32||set arch_ext=64
The wrong code leads to the path of java_exe be
E:\Android\sdk\ANDROI~1\tools\lib\\find_java32 .exe
So, when dx.bat runs
call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
it will report the wrong status:
Error Code:
1
My platform: win8-32 bit android studio 1.0 - 4GB RAM
I had a similar issue, so I uninstalled the java jdk and reinstalled the latest version from oracle and everything went OK. The link for installing the latest version of jdk is here
Note: you need to update the jdk directory in android studio after doing the above
Related
I have a simple project androidproj which I'm trying to build with Jenkins. That is the reason I'm trying to build it from terminal with gradle. The project consists from:
androidmodule1
androidapp1 (androidapp1 has dependency on androidmodule1)
When I execute the cradle by using the following line:
./gradlew build --stacktrace
I get the following error:
FAILURE: Build failed with an exception.
Where: Build file '/Volumes/Storage/Jenkins/jobs/XXX-Android-Compilation/workspace/android/androidmodule1/build.gradle' line: 17
What went wrong: A problem occurred evaluating project ':androidmodule1'.
Ambiguous method overloading for method java.io.File#. Cannot resolve which method to invoke for [null, class
java.lang.String] due to overlapping prototypes between: [class
java.lang.String, class java.lang.String] [class java.io.File,
class java.lang.String]
I found this topic and checked that required SDK is installed, build tools are available:
ANDROID_HOME variable is set:
admin$ echo $ANDROID_HOME
/Users/admin/Library/Developer/Xamarin/android-sdk-macosx
My gradle is:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.company.androidmodule1"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Locally project started just fine.
Do you have any suggestions?
It turned our that Jenkins for some reason wasn't able to see configured environment variables. I had to go to Jenkins->Configuration->Environment Variables and manually specify JAVA_HOME & ANDROID_HOME paths:
I'm a student programmer and I'm continuing an Android project that has been previously started by other students before me. My problem is that I'm getting an error when I try to execute the Android app inside Android Studio. You can see the error message below. The compilation must have worked for the other students since I have an apk file. What's wrong with zipalign?
:app:zipalignDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:zipalignDebug'.
> Process 'command 'X:\Sdk Android Studio\build-tools\21.1.2\zipalign.exe''
finished with non-zero exit value -1073741502
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "csf.dfc.friendtracker"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/guava-18.0.jar')
compile files('libs/Pubnub-Android-3.7.2.jar')
compile files('libs/mysql-connector-java-5.1.34-bin.jar')
}
EDIT:
I haven't found the cause of the error but I added all the project objects in a new one and the error disappeared.
Remove the apk file in the Deploy directory and the export worked fine then.
I realized this happen when you have the directory "..\app\build\outputs\apk\" open in your Windows Explorer. You just need to close it and rebuild the project.
This happened to me too, when I tried to generate the apk in the following path:
C:\users\desktop
Change your signed generated apk destination path used to generate to the following:
<your project path>\app\build\outputs\apk
Example:
E:\androidStudio\CountDownTimer\app\build\outputs\apk
I downloaded the android studio on ubuntu a few days back to start learning android application development, but I am stuck with this build error which I am not able to solve since past two days.
here is the error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/rohit/Android/Sdk/build-tools/21.1.2/aapt package -f --no-crunch -I /home/rohit/Android/Sdk/platforms/android-21/android.jar -M /home/rohit/AndroidStudioProjects/TheTestProject/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/rohit/AndroidStudioProjects/TheTestProject/app/build/intermediates/res/debug -A /home/rohit/AndroidStudioProjects/TheTestProject/app/build/intermediates/assets/debug -m -J /home/rohit/AndroidStudioProjects/TheTestProject/app/build/generated/source/r/debug -F /home/rohit/AndroidStudioProjects/TheTestProject/app/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package com.example.rohit.thetestproject -0 apk --output-text-symbols /home/rohit/AndroidStudioProjects/TheTestProject/app/build/intermediates/symbols/debug
Error Code:
132
and here is the build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.rohit.thetestproject"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
I tried to fix it by reading some solutions posted on similar questions but they did not work.
Build -> Clean Project (didn't work)
using build tool version 20 and target SDK version 20 (didn't work)
tried to look for undefined string values (couldn't find)
deleted menu_main.xml (didn't work)
changed this app:showAsAction="never" to this android:showAsAction="never" (didn't work)
I'm having issues building a project with gradle on Ubuntu 14.04. The project in particular is the ROS android_sensors_driver project. I get a build error after executing gradlew clean debug. The offending line is compile project(':android-15') . I think that it is looking for the android-15 platform in the SDK. I have set ANDROID_HOME to the directory where the SDK is located. The project was cloned from here. The build.gradle file is.
dependencies {
compile "org.ros.rosjava_core:rosjava:0.2.0"
compile "org.ros.rosjava_core:rosjava_tutorial_pubsub:[0,)"
compile 'com.android.support:support-v4:21.0.0'
compile project(':android-15')
}
apply plugin: 'android'
/*debug.dependsOn project(':android_gingerbread_mr1').tasks.debug*/
android {
compileSdkVersion 15
defaultConfig {
minSdkVersion 15
applicationId "org.ros.android.android_sensor_driver"
targetSdkVersion 15
versionCode 1
versionName "1.0"
}
}
Any ideas what the issue might be. Let me know what extra info you might need. I'm reasonably new to linux and gradle?
Thanks
the compiler are saying that the class android has no function android() that receive the parameters are you passing:
MissingMethodException: Could not find method android() for arguments
Check if the arguments that you are sending to the method are the same needed and if the class has some function overloading to a method that receive these arguments you are giving.
I hope it help!
I'm trying to continue working on an older project of mine, it's about a year old, and was working fine back then, but now after that I've updated AndroidStudio, it can't even build anymore.
I'm getting an error saying that I've got the same dex file twice:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
To fix this, I could simply do 'gradle dependencies' to find the culprit, and exclude the faulty file(s), but this is where I run into my actual problem.
When I do 'gradle dependencies', I get the following error:
FAILURE: Build failed with an exception.
* Where:
Build file 'F:\Github\Coinbook\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not create plugin of type 'AppPlugin'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
And here is my full build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.moonrain.coinbook"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "0.7"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':libs:AndroidBootstrap')
compile files('libs/socialauth-4.4.jar')
compile files('libs/socialauth-android-3.2.jar')
compile 'com.doomonafireball.betterpickers:library:1.5.2'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.github.castorflex.smoothprogressbar:library:1.0.0'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.4'
compile 'com.google.code.gson:gson:2.3'
}
So this is were I'm basically stuck at the moment, I've tried the following to fix the issue:
- Updated AndroidStudio
- Updated all SDK related items
- Updated gradle
- Re-created the entire project in a new folder, then copied over my files to the new project
Each post I find regarding this issue, it says to use Gradle 0.7.3 Instead of 0.7.2 Because of a bug.. But that's like a year old, and no longer valid.
Try changing gradle version in gradle/wrapper/gradle-wrapper.properties
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
to something like
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip