Cannot build Google Play Services on command line - android

I updated my Google SDK a couple of days ago and now I cannot build the google-play-services_lib. Upon issuing an "ant release", I get the following stacktrace:
BUILD FAILED
/home/abc/Java/android-sdk/tools/ant/build.xml:649: The following error occurred while executing this line:
/home/abc/Java/android-sdk/tools/ant/build.xml:694: Execute failed: java.io.IOException: Cannot run program "/home/abc/Java/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/${aapt}": java.io.IOException: error=2, No such file or directory
I cannot figure out what's causing this, I've even redownloaded the SDK and cleared everything out. The emulator works fine and I can run my code OK.
Any suggestions would be appreciated.

The real solution is to move to Gradle, but in the meantime I found out that setting ${aapt} and ${dx} to the location of these files fixes the issue. So until I move over the Gradle, my workaround is to set
<property name="aapt" value="${sdk.dir}/build-tools/xxx/aapt"/>
<property name="dx" value="${sdk.dir}/build-tools/xxx/dx"/>
in my build.xml (where xxx is the version android version). It is also necessary to perform an "ant clean" before issuing the "ant release" command, which can be done in one step "ant clean release".

Related

Android resource compilation failed after android gradle version update

I am developing an android app, everything was going fine until i updated gradle version to 3.2. Whenever i try to build or sync the project it shows 'Android resource compilation failed'
Output: C:\Users\User\AndroidStudioProjects\MyApp\base\build\intermediates\incremental\mergeDebugFeatureResources\merged.dir\values\values.xml:2316: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\User\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\fc444429c9ac9f1db8d9bb3790bf9413\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \ -o \ C:\Users\User\AndroidStudioProjects\MyApp\base\build\intermediates\res\merged\feature\debug \ C:\Users\User\AndroidStudioProjects\MyApp\base\build\intermediates\incremental\mergeDebugFeatureResources\merged.dir\values\values.xmlDaemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0\
The error comes up in this line
<item name="textviewprofile" type="id">Logout</item>
I tried to delete the logout element, but the changes does not reflect after build and it still shows up.It says you cannot edit values.xml. I also tried to clean and invalidate the project but that also didn't worked. I have been trying it for several days but cannot fix it.
Any help would be appreciated
Thanks in advance for it
did you already tried deleting the .gradle file located in your root project dir? That sometimes works for me.
Gradle keeps a cache of the task it runs so by deleting the .gradle folder you are invalidating the gradle cache and forcing to redo it again.

Gradle suddenly doesn't build Arm8Release any more

When I say
./gradlew installArm8Release
I get this error:
:app:generateJsonModelArm8Release UP-TO-DATE
:app:externalNativeBuildArm8Release FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:externalNativeBuildArm8Release'.
> java.io.FileNotFoundException: D:\TestApp\app\.externalNativeBuild\cmake\arm8Release\arm64-v8a\android_gradle_build.json (The system cannot find the file specified)
I believe my Gradle configuration has somehow been corrupted because as you can see it says on :app:generateJsonModelArm8Release that it is up to date but as you can see from the error below android_gradle_build.json isn't there at all.
The following line works fine, though:
./gradlew installArm7Release
It's only Arm8Release that fails although it used to work before. This makes me think that somehow something got corrupted. I have already tried the following:
./gradlew clean
./gradlew cleanBuildCache
All to no avail. It refuses to build the Arm8Release target. I have also tried deleting the .externalNativeBuild directory and running
./gradlew wrapper
again. But it didn't solve the issue either.
I have also rebooted the system to make sure any gradle daemon is gone but the error is still there.
I'm pretty much out of ideas now. All targets are working fine except Arm8Release. What else can I try?
Just for the record: Deleting really everything from my build directory except the source and resource files solved this issue. So it seems like
./gradlew clean
./gradlew cleanBuildCache
doesn't really clean everything...
In Android Studio 3.5 (and probably above), that missing file is under a .cxx folder, so deleting the build folder has no effect. Cleaning build doesn't help either. Instead an invalidate cache and restart did the trick for me.
Just add --rerun-tasks to your gradlew command, e.g.
./gradlew installArm8Release --rerun-tasks
just restart Android Studio, it worked for me.

Android code coverage with EMMA build.xml

I'm very new to using EMMA and I'm trying to generate some code coverage for a test project I have but keep getting this error when I try to run
I have been working from multiple tutorials online and have stumbled across this one recently which seems the most simplified to use http://blog.rabidgremlin.com/2010/11/19/android-tips-generating-a-coverage-report-for-your-unit-tests/
from the cmd line in my workspace i run:
C:\Users\roward\workspace\my-app>android update test-project -m C:/Users/roward/
workspace/my-app -p C:/Users/roward/workspace/my-app-test
Resolved location of main project to: C:\Users\roward\workspace\my-app
Updated project.properties
Updated local.properties
Updated file C:\Users\roward\workspace\my-app-test\proguard-project.txt
Updated ant.properties
This seems to work.
Then I run :
C:\Users\roward\workspace\my-app-test>ant coverage
and get this error
Buildfile: C:\Users\roward\workspace\my-app-test\build.xml
BUILD FAILED
Target "coverage" does not exist in the project "my-app-test".
Total time: 0 seconds
I got these errors when I tried the command below for the heck of it but figured if it can shed more light on what I'm doing wrong I might as well post it.
>ant emma debug install test
BUILD FAILED
C:\Users\roward\Documents\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-
x86_64-20140321\sdk\tools\ant\build.xml:601: Invalid file: C:\Users\roward\works
pace\appcompat_v7_6\build.xml
C:\Users\roward\Documents\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-
x86_64-20140321\sdk\tools\ant\build.xml:620: The following error occurred while
executing this line:
Since SDK 14 you must use :
ant emma debug install test
instead of
ant coverage

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.

Emma does not generate coverage.ec

I setup Emma and it used to work for me. Then we had source code changes and now it doesn't generate coverage.ec at all. It does generate coverage.em.
Near the end of testing, it has error messages:
[exec] INSTRUMENTATION_CODE: 0
[echo] Downloading coverage file into project directory...
[exec] remote object '/sdcard/coverage.ec' does not exist
BUILD FAILED
/var/lib/jenkins/android-sdk-linux_x86/tools/ant/build.xml:1056: exec returned: 1.
Line 1056 of build.xml is
"{adb}" failonerror="true".
I see that I do have coverage.em on the desktop, which means my code are instrumented.
the command I use under the \test is
ant emma debug install test
This worked for me before. Running code coverage always crashes for me, usually near the end of the unit test, but it'd always get me some coverage. Now it crashes out and doesn't produce coverage.em.
I also tried to access /sdcard/ and it's perfectly accessible and writable.
This has blocked me for days, any input would be much appreciated. I am also new to all this Android, Ant and Emma, so thanks!!
Update:
I just cleaned up the environment and ran the command again.Now coverage.em is no longer generated either. Which tells me the source code are not instrumented. But the command I used above should instrument project, its test project, install and start test. I didn't change emma def in build.xml except to change the coverage.ec location to /sdcard/coverage.ec. This is because by default it goes to /data/data, and I don't have permission to access data/data on this phone
I am using r15 of Android SDK, and the default build.xml. I only changed the path to coverage.ec to /sdcard/coverage.ec. To run instrumentation
Go to main_project
$andriod update project -p .
Go to main_prject\test
$android update project -m ../ -p .
To start code code
$ant emma debug install test
It generated main_project-instrumented.apk and test_project-debug.apk. Both are installed and I can see it executes testing.
You have to make a test project with the android command line tools first.
Create Project & Test Project
Assuming your project is stored in D:\AndroidProject and your programming against android API level 8. First you use this command to create the project:
android update project --path ./ --name blabla~ --target android-8 --subprojects
Then create an folder for the test project and navigate into that folder:
mkdir Android_test
cd Android_test
Then create the android test project with the below command
android create test-project --main ../AndroidProject --path ./
Ant building with emma coverage report (with root)
Execute this command (from jenkins select and build step) to get a build done with emma reporting:
ant emma debug install test
Caution : For this to work you have to connect rooted device or emulator, then execute ant command!
Change Build xml file (so no root is required)
If you don't want to root your device an alternative solution is to alter the location of these coverage reports. For this you should modify the build.xml file.
(you should googling about that for more information, briefly explained here)
Open the build.xml -> find the location where the coverage.ec file is stored. In most cases this will be stored in /data/data/com.example.Android/coverage.ec
The problem here is that the /data/data/~~~ path is protected (hence the required root).
anyway~ you can get a coverage.html file in your test project folder/bin. The next steps explain how to change this to save this file on the /sdcardinstead!
You can open your build.xml file and at the last line ~ you can find the command import ~~~ build.xml which means that your build.xml file will import anoother build.xml file.
The other build.xml file is part of the android SDK and is located at ${Android-sdk}/tools/ant/build.xml.
Required changes for build.xml file
We can't change this file (without getting into trouble) so instead copy the complete file to an alternative location or directly into your projects build.xml file.
Don't forget to adapt or change the import statement in your build.xml file whatever you choose to do.
This is what you need to change in that new build.xml file:
Erase the import= ~~build.xml
Erase the first line which is xml=ejkwjkw?e jw ""project = "android_rule" ~~ ~blabla)
and last line /project
update address to /sdcard/coverage.ec
Then, you can get coverage.ec file~
I ran into this issue after updating my SDK to r16: Emma code coverage not working in r15 of tools
and this fixed it for me:
ant all clean emma debug install test
But I am unsure if you have the same problem.
I don't have permission to access data/data on this phone
Is it a non-rooted device? Note that the build says:
WARNING: Code Coverage is currently only supported on the emulator and rooted devices.
Maybe you can't work around this limitation by just changing the location of the coverage file. Does it work on a virtual device?

Categories

Resources