Error with Android gradle task :app:preDexDebug - android

Having an issue with a project that has trouble with the :app:preDexDebug task when trying to run app. Error received is:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Current settings:
Android Studio 0.8.1
Android Build Tools 20.0.0
Java 1.7_55
Windows 7
Even a default project does not run, although a gradle sync builds fine.
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\...\AppData\Local\Android\android-sdk\build-tools\20.0.0\dx.bat --dex --output C:\...\TestApplication\app\build\intermediates\pre-dexed\debug\support-v4-19.1.0-c0d17b20b65717b1b327ef7ea8fea7e8a443e7fe.jar C:\...\AppData\Local\Android\android-sdk\extras\android\m2repository\com\android\support\support-v4\19.1.0\support-v4-19.1.0.jar
Error Code:
1
Output:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.testapplication"
minSdkVersion 10
targetSdkVersion 19
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.android.support:appcompat-v7:19.+'
}

Resolved (on windows) by setting
set _JAVA_OPTIONS=-Xms512m -Xmx512m -XX:MaxPermSize=256m
Now script reports
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m -XX:MaxPermSize=256m
and works correctly.
What is strange, setting up variables GRADLE_OPTS and JAVA_OPTS had no effect.

Related

Execution failed for task app:compileDebugAidl: aidl.exe finished with non-zero exit value 3

I am trying to build my project with AIDL example. But I keep getting this error:
:app:compileDebugAidl
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
Error:Execution failed for task ':app:compileDebugAidl'.
> com.android.ide.common.process.ProcessException:org.gradle.process.
internal.ExecException:
Process 'command 'C:\Users\xuefu\AppData\Local\Android\sdk\build-tools\23.0.1\aidl.exe''
finished with non-zero exit value 3
Information:BUILD FAILED
below is my build file and I am using Android Studio 1.3.2, Gradle 1.3.0 under the windows 8.1 x64 platform:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "org.crazyit.service"
minSdkVersion 10
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
}
Please check your aidl files, make sure all the files include the package name. e.g.
package com.zebra.gogogo;
parcelable GoInfo;

Apps not showing in virtual device Android Studio

I'm currently learning android development but am running a small problem. The last two apps I've attempted to run (Following Bucky's android tutorials) have failed to appear in my virtual device.
This is my build log:
11:58:36 AM Gradle sync started
11:59:14 AM Gradle sync completed
11:59:16 AM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources]
11:59:30 AM Gradle build finished in 12s 258ms
12:19:21 PM Executing tasks: [:app:assembleDebug]
12:19:24 PM Gradle build finished with 15 error(s) in 3s 20ms
12:19:33 PM Executing tasks: [:app:assembleDebug]
12:19:56 PM Gradle build finished in 22s 797ms
12:32:59 PM Executing tasks: [:app:assembleDebug]
12:33:01 PM Gradle build finished in 1s 608ms
My build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.alex.buckysgestures"
minSdkVersion 19
targetSdkVersion 22
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:22.2.1'
}
Please help!
You have successfully built your app, now you should install it on device. Be sure some device is connected (or virtual device), and run
./gradlew installDebug

Error building android project with gradle from terminal

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:

zipalign.exe'' finished with non-zero exit value

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

how do i solve android studio 1.0.2 build error (error code 132)

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)

Categories

Resources