Error when compiling with Gradle (can't find downloaded dependencies) - android

I develop an app generation system that is regenerating apps by command line Gradle compilation commands.
In my Windows Server 2008, I'm facing a problem after updating to the last Gradle version and Gradle plugin version.
When compiling I'm getting this errors:
C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.0.0.aar\e93435c34d5cae8b6677dcef529711a5\res\drawable-xxhdpi-v4\abc_text_select_handle_middle_mtrl_light.png: error: file not found.
C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.0.0.aar\e93435c34d5cae8b6677dcef529711a5\res\drawable\abc_btn_colored_material.xml: error: file not found.
C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.0.0.aar\e93435c34d5cae8b6677dcef529711a5\res\drawable-hdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png: error: file not found.
and a lot more of errors like those...
I'm not sure why I'm getting this error, because the file is correctly downloaded and it's correctly located on that exactly direction.
It has a path length of 204 characters, so supposedly it's not surpassing the limit of 255 path characters on NTFS Windows file system.
It is possible to change the location where Gradle downloads it's cached dependencies? Is this problem caused by this or by other thing?

finally i solved this setting the environmental variable GRADLE_USER_HOME in windows to c:/gradle-cache
so definitively it's related to file path lenght

I meet this same error in windows jenkins
I solved this error.
gradle assembleDebug -g C:\gradle-cache
-g:
gradle -h
-g, --gradle-user-home Specifies the gradle user home directory

Path length cause failure.
I defined
"-Dorg.gradle.user.home=%GRADLE_USER_HOME%"
in gradle run parameters and it solved the problem.

Related

How to fix com.android.builder.internal.aapt.AaptException: Failed to crunch file?

I have the latest version of Android Studio (as of Sep 21, 2016). When I create a brand new project in Android Studio and try to build it, I am getting this build error:
Error: com.android.builder.internal.aapt.AaptException: Failed to
crunch file
H:..pathTo..\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.2.1\res\drawable-xhdpi-v4\abc_list_selector_disabled_holo_light.9.png
into
H:..pathTo..\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\abc_list_selector_disabled_holo_light.9.png
What does this mean? And how do I fix it?
Build log:
https://jpst.it/NCnu
Amazing. It's 2016 and Google's tool chain still has these annoying file path limitations.
Error: File path too long on windows, keep below 240 characters
Move project further up your project file path and the problem goes away!
There is a workaround. If you add the following to the project build.gradle file, inside the allprojects section, it will move the Build output files to this folder. Meaning the app will now build.:
buildDir = "C:/tmp/${rootProject.name}/${project.name}"
It does give you an additional app module at the root of the project but this is a much more convenient option than moving whole Project folder path.
I Found the same Error (Error: com.android.builder.internal.aapt.AaptException: Failed to crunch). I Copied the directory one level above. It Works!
The solution that help me was to delete node_modules folder,
remove android platform by running the command ionic platform remove android
and then go upper the project folder in system hirarchy
and then:
npm install
ionic platform add android
ionic run android
I faced this problem when trying to generate an unsigned apk using Gradle in Android Studio IDE 3.0
I solved it by creating a fresh new project and copied each file with the slightest amendment needed e.g. changing the package name, but I left the icons as they are thus I haven't added a new icon in several files like I did in the previous project.
And the problem was solved, it builds with no such error.
(However the generated apk file wasn't found in app\build\outputs\apk but inside app\build\outputs\apk\debug, but that's another problem which is not so important I hope).
I encountered a similar error. Just try to reduce the path length by moving the project folder up.
This will surely solve the problem.
Update you gradle to latest one, it solve the problem, i was also facing same problem, it work for me.
I was using classpath 'com.android.tools.build:gradle:2.0.0', then replace to
classpath 'com.android.tools.build:gradle:3.0.0' , it work for me.

The specified task executable location ... is invalid

I'm new to Xamarin. I'm having a problem with deployment. The project builds successfully but then I get an error message:
C:\Program Files
(x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2):
Error MSB6004: The specified task executable location
"C:\android\sdk\tools\zipalign.exe" is invalid. (MSB6004) (FirstApp)
". " Deployment failed. Packaging failed ".
I'm not sure what the problem is or what to do to resolve this. Please help.
Because of a new Android version, the zipalign got switched from directory. See over here
Currently, I saw they updated Xamarin with a fix for this. You should try to update Xamarin first. Version 5.1.2 fixes this: "Fixes a regression introduced by Android SDK Tools r23 and Android Build-tools r20 that changed the path of the zipalign tool."
This solution just worked for me:
You need to copy
C:\Program Files (x86)\Android\android-sdk\build-tools\19.1.0\zipalign.exe
not in
C:\Program Files (x86)\Android\android-sdk\tools
but in
C:\Users\yourfolder\AppData\Local\Android\android-sdk\tools
Also see:
ApkClean 0.9.02
https://code.google.com/p/apkclean/downloads/detail?name=ApkClean-0.9.02.zip&can=2&q=
:)

Phonegap error android sdk build.xml:950 : null returned: 1

I'm trying to launch phonegap android app in android sdk, but I am receiving an error:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[error] An error occurred while building the android project.Error executing "ant debug -f "/Users/me/Projects/one/platforms/android/build.xml"":
BUILD FAILED
/Applications/Android/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:932: The following error occurred while executing this line:
/Applications/Android/adt-bundle-mac-x86_64-20131030/sdk/tools/ant/build.xml:950: null returned: 1
I followed this guide http://docs.phonegap.com/en/2.2.0/guide_getting-started_android_index.md.html but it is not working.
What could have caused this?
You are most likely also getting the line
invalid resource directory name:
/YOUR/PROJECT/ROOT/PATH/bin/res/crunch
right before the error codes, so open up terminal and enter the following:
cd YOUR/PROJECT/ROOT/PATH
rm -fR $(find . -type d -name crunch|xargs)
I just had to cd into the platforms/android dir and run ant clean and it fixed this issue for me.
had the same issue. something that can help is to read ant log as recommend here
to do so run ant -logfile //antLogFile.txt release -f ./AppMain/build.xml
or in the folder itself. i.e : platforms\android run ant -logfile ./antLogFile.txt release
My issue was a file with Hebrew characters on its name..
Hi Sorry for the late answer
An alternative to other solutions possibly OS-X Specific but i was having the same issue and none of the solutions for me worked however the mention of assets made me go back and scour over my build logs and i noted this:
[aapt] /Users/rowdoggnz/Development/cordova/surveyapp/platforms/android/assets/www/lib/fa/Icon
[aapt] : error: Invalid filename. Unable to add.
This was the cause of my error which shared the same error code and line references as the original poster.
OS-X seems to generate ghost icon files for some reason which are not visible in finder due to being hidden, i used an app called "Invisiblix" to view my project folder and removed all of the 'Icon' files and my app would build fine.
I'm guessing the iOS build naturally ignores these Icon files however Ant doesn't.
Hope this helps someone.
If you have more than one project and you are using the same assets eg: images, ant will fail to build. You can use ant clean to remove the cache from other projects and avoid this issue as suggested in this post crunch/resource packaging with aapt in ant build uses cache from other projects
Nevertheless, In my case I just have one project with many images, some of them were called with the same name, but with different letter case. Ant's build process is case-insensitive, so those images were duplicated, being error cause.
My particular fix was to rename or eliminate one of the images to allow cordova build my project.
I was having this issue in OSX using Ionic framework. This was my fix:
I ran this on the command line in the project root folder:
find . -name Icon -exec rm {} \;
What the above does descend through the whole project to search for files name Icon. Upon finding them they are deleted.
After this I ran my build process and all was good again.
Make sure you have installed the prerequisites correctly.

Android - Phonegap - Conversion to Dalvik format failed with error 1

I installed this:
https://github.com/mwbrooks/cordova-plugin-menu
and have cordova 1.8.1 installed.
I copied "libs/phonegap-1.0.0.jar" to ANDROID_PROJECT/libs.
When i try and run the app in the simulator, i get :
"Conversion to Dalvik format failed with error 1"
I believe this is to do with conflicts with libraries, but I don't know what to do to remove the error?
please help.
I have found myself in the same situation after upgrading from 2.0.0 to 2.1.0
First of all make sure you have reconfigured the build path by removing the JAR from the old PhoneGap version and adding the new one.
At this point I started getting the Dalvik error. Cleaning the build environment didn't help.
So I remove the old jar from the libs directory and voilá, it worked.
Project -> Turn off Build Automatically. Then Build project manually and clean. Then export signed project. Problem has been gone.

Android, Proguard 'Unknown option 'and' in argument number 9'

I'm getting the following error every time I try to export my application from Eclipse.
Proguard returned with error code 1. See console
proguard.ParseException: Unknown option 'and' in argument number 9
at proguard.ConfigurationParser.parse(ConfigurationParser.java:170)
at proguard.ProGuard.main(ProGuard.java:491)
I'm using the defualt proguard.cfg file that Eclipse generated. My android sdk is in C:\Android\SDK(here)
My default.properties file is like this:
target=android-7
proguard.config=proguard.cfg
I have also done a clean and build.
I also made sure Eclipse and my SDK tools were up to date.
The 'spaces in the pathnames' problem is well documented here - note that you can use Junctions/Links to get around this without moving or renaming files...
The Dalvik error is usually just Eclipse 'having a moment' - a 'Clean Project' and Rebuild usually cures it.
So, in my workspace for the name of the project I had C:\workspace\Name Android Name for the name, so I changed that to C:\workspace\NameName, then I changed my sdk to C:\sdk, then I exported to C:\NameAndroidName.apk, and I got the failure to convert to dalvik format error.
And then I went to this question and that solved the dalvik format error, and it exported successfully.

Categories

Resources