Gradle :app:preDexDebug error Android Studio Project - android

I'm writing an app with Android platform, In my app im using some external jars, due to some errors connected with version of common codecs in android SDK I had to change one of functions in external jar like here Apache Commons Codec with Android: could not find method and export project to new jar file. I have deleted old jar file from android project i have cleaned build added new jar file and now all the time i recieve such an error :
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 1
Maybe build clean does not work as I think it should and it does not delete old version of jar file?

The problem is compiling. Change compile options to Java 6.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}

Change the jdk version to 1.7:
for change go to Project Structure > SDK Location > JDK Location.
this is work for me. I hope work for you.

Thanks for all of clues, actually what i had to do was, in eclipse set jdk to 1.7 and recompile it with such settings then add it do android project.

Related

Error are come \build-tools\23.0.3\aapt.exe'' finished with non-zero exit value 1 [duplicate]

I am trying to import my project.
but when I run the application I am getting the following error:
Error: Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Vishnu Ruhela\AppData\Local\Android\sdk\build-tools\21.1.2\aapt.exe'' finished with non- zero exit value 1
here is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.vishnuruhela.signup"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors { }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':listView1')
}
I was getting this exact same error. I ran the command
./gradlew assembleDebug --info
Where "assembleDebug" was replaced with the assemble task for a debug version of the flavor I wanted.
Look for output
Successfully started process 'command '/usr/local/opt/android-sdk/build-tools/21.1.2/aapt''
Right below that was an error describing a resource which I used in a layout file but which was missing from the dimensions files. Fixing this fixed the build issue.
At first you go to
Build -> Clean Project
and then go to
Build -> Rebuild Project
and finish the error is a way
Install the latest version of the build tools. Adjust your build.gradle to use
android {
compileSdkVersion {X}
buildToolsVersion "{X.Y.Z}"
...
}
Proper values should match your installed SDK. Could be 23.0.3 at the time of this post.
or check and remove duplicate dependencies from list.
Enjoy :)
Follow this simple steps to recover this error:
Method 1:
-Go to File->project structure->Project
-Check Android plugin Version and change it to 1.3.0(Latest one)
-Go to File->project structure->app->Properties->Build Tools Version
-Change it to latest one(22.0.1). Also do this for any other module you have for your project.
-Clean and build project.
Note: If your build tool version is less than 22.0.1 then you may still face same error while gradle build so please update your SDK from SDK Manager to latest one then restart android studio and follow above steps.
Method 2:
-If you don't want to update build tools version or you don't have latest SDK version just Go to File->project structure->Project.
-Check Android plugin Version and change it to 1.0.0(Older one)
-Clean and build project.
I recommended Method 1.
I had the same problem after replacing some .png image resources with .jpg pictures.
I deleted appname/app/build, than I selected Build -> Rebuild project and finally it worked without any errors.
In my case, answers of taciosd and Netero pointed in the correct direction. By analyzing:
gradle assembleDebug --stacktrace --debug
Linux:
./gradlew assembleDebug --stacktrace --debug
i found out that one filepath in the assets folder was too long and aapt.exe stopped by returning 1 (and no specific error message) when processing that file. It seems that files with non ASCII characters in names are not accepted as well.
I had this same exact error all of a sudden the other day. I did a "Clean Project" and a "Rebuild Project" and never saw the error again.
I've only got a few months of Android development under my belt. But whenever I get an unexplained error like this, "Clean Project" and/or "Rebuild Project" are the first things I try.
i had the same problem i resolve it by removing files that i added in the assets folder and those files name contains insupported characteres like "é" , " ", "ï" "è"...
by renaming those name files or removing them you will have no problem.
BuildToolsVersion & Dependencies must be same with Base API version.
buildToolsVersion '23.0.2' & compile
&
com.android.support:appcompat-v7:24.0.0-alpha1
can not match with base API level.
It should be
compile 'com.android.support:appcompat-v7:21.0.3'
Done
Errors in the execution of aapt in task processDebugResources or processReleaseResources generally happen when one or more resources of your project are unsupported.
To find out go to the root dir of your project and run:
gradle processDebugResources --debug
This will print aapt specific error. In my case it was a file in the assets folder whose name had invalid character (LEÃO.jpg). aapt doesn't support some characters in the Latin alphabet.
But, as I explained your problem can be other than that. To know for sure you have to run processDebugResources with the option --debug.
I have faced the same error while compiling. I tried all the methods here but failed only one thing worked but it takes a lot of time. by running this code on CMD to debug my app and shows me the missing tag in my XML layout.
gradle processDebugResources --debug
The best approach is to analyze the error not just ignoring it.
To run this code I installed Java JDK and then set Environment Variable: for JAVA_HOME and Gradle.
for gradle
C:\Program Files\Android\Android Studio\gradle\gradle-4.6\bin
for java
JAVA_HOME=C:\Program Files\Java\jre1.8.0_191
You have to do the following instructions :
Click on Build located in the toolbar, then
Clean project -> Rebuild Project
Please make sure that compileSdkVersion, buildToolsVersion and targetSdkVersion have the same version number. I also have this error because it has different version. This solution worked for me.
I hope it can help you all.
when our code has layout.xml file error ,we get this error message. Check your xml files again.
look through your styles.xml files for a #+id/
I had one in styles.xml in values-v17 which I don't recall creating. This is what I had to change in the end and not build tools 21.1.2 to 22.0.1 as suggested.
I also had the same error with my images .. Just rename the extension from ".png" or whatever you have to ".jpg"
I had the same problem.
Try renaming the files in assets folder with characters other than alphabets, numbers and underlines.
Specially, look for apostrophes and European alphabets not common in English.
I build with command:
./gradlew build --info
It show more error message, my problem is there is special characters in the file name.
I too was facing this issue just because i had renamed my project folder while project was opened in Android Sudio.So,Android Studio created another folder in that directory of my window.
I found in my build.gradle(Module:app), all the support libraries were updated and was throwing error on compile time of project.
All you require to do is,simply change updated support libraries to your current build tool version like this and rebuild the project.
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
my current build tool version is 22.2.1
When i replace the images in project then i get this issue.
Then i found that one of the image was having extension .PNG then i rename it to .png then my issue was resolved.
Hope it helps you
I had this same problem, and it only went away after a removed the .gradle folder from my project's root.
So make sure you:
Close the project in Android Studio
Open your file explorer, find the project's root directory
Completely remove the folder .gradle
I hope this helps. Good luck!
I was also getting this issue.
I generally face this issue when I import some sample or already
existing module into my project.
I just added latest v7 and v4 to my project from maven in
android studio and got it fixed
Removed duplicate dependencies from project like wise if your library project and application project are using v7 or v4 or any other library , they should be of same version. or try to have it only in your library project
I had the same problem. Even JPG files did not work. Put all your image files into mipmap and work. They work perfectly.
I ran to same problem today and try to clean and rebuild project.
I did not solve my problem. I got it solved with change the compileSdkVersion, buildToolsVersion, targetSdkVersion and com.android.support:appcompat-v7:23.0.1 values instead on my Gradle app file. Then I ran clean and rebuild the project afterwards.
For return value 3 "OutOfMemory exception" i added following in gradle android section
android {
............
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
............
}
And for 2nd issue with return value 2, earlier i had following in gradle dependencies for JDK 7
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:7+'
compile 'com.facebook.android:facebook-android-sdk:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:support-v4:+'
Then i updated my JDK to 8 and it started to give me error (probably for jdk 8 there were more than one libs available with 7+ ) while running the application. What fixed my issue is giving specific version instead of 7+. i.e.
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
In my case, I had to install "libz.so.1" library to make it work, on Ubuntu 15.04
sudo apt-get install lib32z1
Error:Execution failed for task com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
finished with non-zero exit value 1
One reason for this error to occure is that the file path to a resource file is to long:
Error: File path too long on Windows, keep below 240 characters
Fix: Move your project folder closer to the root of your disk
Don't:// folder/folder/folder/folder/very_long_folder_name/MyProject...
Do://folder/short_name/MyProject
Another reason could be duplicated resources or name spaces
Example:
<style name="MyButton" parent="android:Widget.Button">
<item name="android:textColor">#color/accent_color</item>
<item name="android:textColor">#000000</item>
</style>
In my case this error was caused by empty layout xml file.
I created the empty file but forgot to add any content to it. AndroidStudio gave this misleading error message, but when I executed the gradle build from command line I could see the real error like "Error parsing XML: no element found" and the file name.
Adding basic layout xml content fixed the error.
look the compileSdkVersion at android/biuld.gradle ,and compileSdkVersion in all other packages
should be the same.
just for the record. I followed all clean/rebuild and update SDK-Tools here, but in the end it turned out disable Instant Run, to solve my issue.
Go to: Android Studio -> Preferences -> Build,ExecutionDeployment -> Instant Run

After updating Android studio library I cannot run or build project

I update my android studio 2.0 to latest 2.1.1 Also I update my sdk and install all required sdk elements.
After that when I run my existing working project then it give me bellow issue.
Error:Execution failed for task ':lib-toolbarindicator:processReleaseResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/tristate/oldSdk/android-sdk-linux/build-tools/24.0.0/aapt'' finished with non-zero exit value 2
This error occur in messages tab. so I cannot go further in project.
Forgive me spieling mistake and grammatical mistake because I am not native in English.
Thank you
Try to Clean up Your Project.
I often get Error but With Just One Clean shot, BUILD SUCCESSFUL
Please change your build.gradel file then sync android because this type of error comes due to unnecessary complie library in build.gradel.
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}

How do I add an 'aar' to my existing android project in Android Studio

I have a aar module by the name of app-debug.aar. I need to add this in my existing android project. I am using Android Studio 1.2.2. I have tried lot of approaches which were suggested like these
How to manually include external aar package using new Gradle Android Build System
When I am trying to use the answers in this post, I mostly come across this issue
Error:Execution failed for task ':app:processIcanpayDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/Shaik/Library/Android/sdk/build-tools/21.1.2/aapt'' finished with non-zero exit value 1
And when I seacrched for that i came to know that I had to add
defaultConfig {
multiDexEnabled true
}
But still I get the same error and I am not successful in adding the aar module to my project. Can anyone let me know how can I achieve it. Thanks in advance.
I think you're looking for something like this (works for me): http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/

finished with non zero exit value

I am trying to import my project.
but when I run the application I am getting the following error:
Error: Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Vishnu Ruhela\AppData\Local\Android\sdk\build-tools\21.1.2\aapt.exe'' finished with non- zero exit value 1
here is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.vishnuruhela.signup"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors { }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':listView1')
}
I was getting this exact same error. I ran the command
./gradlew assembleDebug --info
Where "assembleDebug" was replaced with the assemble task for a debug version of the flavor I wanted.
Look for output
Successfully started process 'command '/usr/local/opt/android-sdk/build-tools/21.1.2/aapt''
Right below that was an error describing a resource which I used in a layout file but which was missing from the dimensions files. Fixing this fixed the build issue.
At first you go to
Build -> Clean Project
and then go to
Build -> Rebuild Project
and finish the error is a way
Install the latest version of the build tools. Adjust your build.gradle to use
android {
compileSdkVersion {X}
buildToolsVersion "{X.Y.Z}"
...
}
Proper values should match your installed SDK. Could be 23.0.3 at the time of this post.
or check and remove duplicate dependencies from list.
Enjoy :)
Follow this simple steps to recover this error:
Method 1:
-Go to File->project structure->Project
-Check Android plugin Version and change it to 1.3.0(Latest one)
-Go to File->project structure->app->Properties->Build Tools Version
-Change it to latest one(22.0.1). Also do this for any other module you have for your project.
-Clean and build project.
Note: If your build tool version is less than 22.0.1 then you may still face same error while gradle build so please update your SDK from SDK Manager to latest one then restart android studio and follow above steps.
Method 2:
-If you don't want to update build tools version or you don't have latest SDK version just Go to File->project structure->Project.
-Check Android plugin Version and change it to 1.0.0(Older one)
-Clean and build project.
I recommended Method 1.
I had the same problem after replacing some .png image resources with .jpg pictures.
I deleted appname/app/build, than I selected Build -> Rebuild project and finally it worked without any errors.
In my case, answers of taciosd and Netero pointed in the correct direction. By analyzing:
gradle assembleDebug --stacktrace --debug
Linux:
./gradlew assembleDebug --stacktrace --debug
i found out that one filepath in the assets folder was too long and aapt.exe stopped by returning 1 (and no specific error message) when processing that file. It seems that files with non ASCII characters in names are not accepted as well.
I had this same exact error all of a sudden the other day. I did a "Clean Project" and a "Rebuild Project" and never saw the error again.
I've only got a few months of Android development under my belt. But whenever I get an unexplained error like this, "Clean Project" and/or "Rebuild Project" are the first things I try.
i had the same problem i resolve it by removing files that i added in the assets folder and those files name contains insupported characteres like "é" , " ", "ï" "è"...
by renaming those name files or removing them you will have no problem.
BuildToolsVersion & Dependencies must be same with Base API version.
buildToolsVersion '23.0.2' & compile
&
com.android.support:appcompat-v7:24.0.0-alpha1
can not match with base API level.
It should be
compile 'com.android.support:appcompat-v7:21.0.3'
Done
Errors in the execution of aapt in task processDebugResources or processReleaseResources generally happen when one or more resources of your project are unsupported.
To find out go to the root dir of your project and run:
gradle processDebugResources --debug
This will print aapt specific error. In my case it was a file in the assets folder whose name had invalid character (LEÃO.jpg). aapt doesn't support some characters in the Latin alphabet.
But, as I explained your problem can be other than that. To know for sure you have to run processDebugResources with the option --debug.
I have faced the same error while compiling. I tried all the methods here but failed only one thing worked but it takes a lot of time. by running this code on CMD to debug my app and shows me the missing tag in my XML layout.
gradle processDebugResources --debug
The best approach is to analyze the error not just ignoring it.
To run this code I installed Java JDK and then set Environment Variable: for JAVA_HOME and Gradle.
for gradle
C:\Program Files\Android\Android Studio\gradle\gradle-4.6\bin
for java
JAVA_HOME=C:\Program Files\Java\jre1.8.0_191
You have to do the following instructions :
Click on Build located in the toolbar, then
Clean project -> Rebuild Project
Please make sure that compileSdkVersion, buildToolsVersion and targetSdkVersion have the same version number. I also have this error because it has different version. This solution worked for me.
I hope it can help you all.
when our code has layout.xml file error ,we get this error message. Check your xml files again.
look through your styles.xml files for a #+id/
I had one in styles.xml in values-v17 which I don't recall creating. This is what I had to change in the end and not build tools 21.1.2 to 22.0.1 as suggested.
I also had the same error with my images .. Just rename the extension from ".png" or whatever you have to ".jpg"
I had the same problem.
Try renaming the files in assets folder with characters other than alphabets, numbers and underlines.
Specially, look for apostrophes and European alphabets not common in English.
I build with command:
./gradlew build --info
It show more error message, my problem is there is special characters in the file name.
I too was facing this issue just because i had renamed my project folder while project was opened in Android Sudio.So,Android Studio created another folder in that directory of my window.
I found in my build.gradle(Module:app), all the support libraries were updated and was throwing error on compile time of project.
All you require to do is,simply change updated support libraries to your current build tool version like this and rebuild the project.
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
my current build tool version is 22.2.1
When i replace the images in project then i get this issue.
Then i found that one of the image was having extension .PNG then i rename it to .png then my issue was resolved.
Hope it helps you
I had this same problem, and it only went away after a removed the .gradle folder from my project's root.
So make sure you:
Close the project in Android Studio
Open your file explorer, find the project's root directory
Completely remove the folder .gradle
I hope this helps. Good luck!
I was also getting this issue.
I generally face this issue when I import some sample or already
existing module into my project.
I just added latest v7 and v4 to my project from maven in
android studio and got it fixed
Removed duplicate dependencies from project like wise if your library project and application project are using v7 or v4 or any other library , they should be of same version. or try to have it only in your library project
I had the same problem. Even JPG files did not work. Put all your image files into mipmap and work. They work perfectly.
I ran to same problem today and try to clean and rebuild project.
I did not solve my problem. I got it solved with change the compileSdkVersion, buildToolsVersion, targetSdkVersion and com.android.support:appcompat-v7:23.0.1 values instead on my Gradle app file. Then I ran clean and rebuild the project afterwards.
For return value 3 "OutOfMemory exception" i added following in gradle android section
android {
............
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
............
}
And for 2nd issue with return value 2, earlier i had following in gradle dependencies for JDK 7
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:7+'
compile 'com.facebook.android:facebook-android-sdk:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:support-v4:+'
Then i updated my JDK to 8 and it started to give me error (probably for jdk 8 there were more than one libs available with 7+ ) while running the application. What fixed my issue is giving specific version instead of 7+. i.e.
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
In my case, I had to install "libz.so.1" library to make it work, on Ubuntu 15.04
sudo apt-get install lib32z1
Error:Execution failed for task com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
finished with non-zero exit value 1
One reason for this error to occure is that the file path to a resource file is to long:
Error: File path too long on Windows, keep below 240 characters
Fix: Move your project folder closer to the root of your disk
Don't:// folder/folder/folder/folder/very_long_folder_name/MyProject...
Do://folder/short_name/MyProject
Another reason could be duplicated resources or name spaces
Example:
<style name="MyButton" parent="android:Widget.Button">
<item name="android:textColor">#color/accent_color</item>
<item name="android:textColor">#000000</item>
</style>
In my case this error was caused by empty layout xml file.
I created the empty file but forgot to add any content to it. AndroidStudio gave this misleading error message, but when I executed the gradle build from command line I could see the real error like "Error parsing XML: no element found" and the file name.
Adding basic layout xml content fixed the error.
look the compileSdkVersion at android/biuld.gradle ,and compileSdkVersion in all other packages
should be the same.
just for the record. I followed all clean/rebuild and update SDK-Tools here, but in the end it turned out disable Instant Run, to solve my issue.
Go to: Android Studio -> Preferences -> Build,ExecutionDeployment -> Instant Run

Gradle build failure (incompatible magic value)

It seems like without any reason the Gradle refuses to build the project in Android Studio. I haven't change anything in the configurations and I can't find any reason of this error. The output is the following
Error:A problem occurred configuring project ':app'.
java.lang.ClassFormatError: Incompatible magic value 931269604 in class file build_f63dreec96sk8elmstb53lfie
No any Android library is recognized. So maybe there might be some problems with sdk but I have checked the dependencies and the path was set correctly. Here is a screenshot of my build.gradle.
I have already tried
1) rebuilding and cleaning the project.
2) File -> invalidate caches and restart
Are there any other ideas about fixing this problem. Thanks in advance
For anyone who finds this in future.
I had this issue and resolved it by typing:
gradlew --recompile-scripts
The problem was that Gradle had a precompiled build script from a previous version of Java. The .class file for that script was invalid, hence the error. You need to recompile that script.
Basically, you have a project or module that was compiled using a source JRE version less than a dependency.
Try the following
sourceCompatibility = 1.6
targetCompatibility = 1.6
More information is here
Gradle sourceCompatibility has no effect to subprojects

Categories

Resources