If I run ant release in the shell in my dir proj it works fine, however, when I try to execute it from python, it fails, why?
/Users/hunterp/proj
Buildfile: /Users/hunterp/proj/build.xml
BUILD FAILED
/Users/hunterp/proj/build.xml:46: sdk.dir is missing. Make sure to generate local.properties using 'android update project'
It is difficult to answer this question without more information about your setup or the code you are using. Particularly the parts that are generating the error since we don't know what your code looks like (either in build.xml or in your python script).
An easy thing to start with, as indicated by #Mark, is to <echo>${basedir}</echo> in your release task to see where exactly it thinks it is running from. My guess is that you are trying to load a properties file or some such and it isn't finding it in an earlier step.
What you can do if the location of ${basedir} looks different when run from within the directory versus within your python script is use a reference to where your build.xml file lives and reference from there:
<dirname property="project.basedir" file="${ant.file.project_name}"/>
Then use use ${project.basedir} instead of ${basedir}.
All of this assuming, of course, that your ${basedir} appears differently between the two. Otherwise I'd need to know more in order to diagnose the issue.
Related
I have an Android Studio App that now has close to 100 "productFlavors" associated with it, of course all defined in the build.gradle. I would like to build them from command line since building them one at a time in the IDE would be a nightmare. My issue arises when I run into an error in the middle of building them using the command line gradlew.bat assembleRelease. Once I fix the error I would like to start building at the point of failure (maybe 50 flavors into the build) rather than at the beginning. Is there a way to do that with Gradle? With Ant I was forced to comment them out, I am hoping there is a better way with Gradle since the structure is much more complicated in the file.
UPDATE
I finally went with a solution that encompassed Gradle and Ant (yucky but it works). Basically I wanted to build on of my 100 White Label flavors, with a prefix of the version, and then copy it to the deliver APK without the version. To do this my ANT script looks like:
#!/bin/sh
DEPLOY_DIR=C:/AndroidBuilds/MyCompany.Build
VERSION="63"
NAME="WhiteLabel1"
DEPLOY_FOLDER="whitelabel1"
APK_NAME=$NAME$".apk"
gradlew assemble$NAME
cp $DEPLOY_DIR/$DEPLOY_FOLDER/$VERSION"-"$APK_NAME $DEPLOY_DIR/$DEPLOY_FOLDER/$APK_NAME
NAME="WhiteLabel2"
DEPLOY_FOLDER="whitelabel2"
APK_NAME=$NAME$".apk"
gradlew assemble$NAME
cp $DEPLOY_DIR/$DEPLOY_FOLDER/$VERSION"-"$APK_NAME $DEPLOY_DIR/$DEPLOY_FOLDER/$APK_NAME
This results in 2 APKs being generated, 63-WhiteLabel1.APK and 63-WhiteLabel2.APK, which are then copied to their respective deploy directories as WhiteLabel1.APK and WhiteLabel2.APK
I suppose if you are clever you could make this take parameters to run just the one you want, but Android Studio does a pretty decent job of that.
You can't specifically do that, but you can work around the issue and fix it with some script-magic.
If you have a build type called Release, and a flavor called Iron, you could run:
gradlew.bat assembleIronRelease
So you could write a script that would run through a loop of all flavors, and if it fails, it would tell you which one failed. You can then fix the error, and start the script again, telling it to start at X flavor (you would have to write the logic to tell it where to start though).
I'm relatively new to Android and I have a problem using the ndk-build command.
I use the NDK r9d under Windows 7 64bits.
When I run my build system which creates my Android project (makefiles etc...) and then creates a process running ndk-build.cmd (I checked that it is call in the Android project) I get the error:
make.exe: *** create_child_process: DuplicateHandle(In) failed (e=6)
But when I run ndk-build.cmd "manually" in the windows command console in the same Android project created by my build system (or any Android project) everything is working.
I did find some related questions like here:
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014825836
https://cygwin.com/ml/cygwin/2004-09/msg01506.html
But all I found says either that it's a problem of make version which is not (I think) since ndk-build works fine when I use it "manually" or it says that it is related to stdin handling and again I don't think that the issue here. Plus all the anwsers that I found was related to a similar error but not exactly the same:
process_easy: DuplicateHandle(In) failed (e=6)
Maybe someone knows the meaning of my error message. I don't think that's specific to Android ndk-build but maybe.
Thank you for reading (and sorry for any english mistakes, I am french and not fluent in english)
Finaly, I found a solution to my problem here:
http://www.zeusedit.com/zforum/viewtopic.php?t=174
I am not sure about what the problem was but according to this link, it was related to the make environment and the handles.
The solution : Instead of using the createProcess function (from Windows) directly to call ndk-build.cmd, I created a batch file containing:
start ndk-build.cmd
And I called this batch (.bat) via the createProcess function.
I let you see the link for more details.
I'm trying to build just a phone app from aosp. I've configured my work dir as it was described in google's guide. Then i'm going to my work dir, execute source build/envsetup.sh and get the following:
including device/asus/grouper/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/armv7-a/vendorsetup.sh
including device/moto/wingray/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash
Then i'm executing command mmm packages/apps/Phone/ and something goes wrong, i get
make: Entering directory `/home/build/WORK_DIR'
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/core_intermediates/javalib.jar', needed by `out/target/common/obj/JAVA_LIBRARIES/com.android.phone.common_intermediates/classes-full-debug.jar'. Stop.
make: Leaving directory `/home/build/WORK_DIR'
Can anyone explain me what should i do? Should i build the whole android project first, or is it a bug in makefile?
Try building the entire source at first...After that whenever you make changes in the source code of any application(in your case Phone), you need to rebuild the entire code. The rebuild process will not take time as only the changes will be built into the system image..Use "make" instead of "mmm" . However don't use "make clean" as it will erase your earlier build and start from scratch. So the outline is:
Execute "make" for building the first time
Make your changes in the application
Execute "make" once again
Use "make snod" if you just want only one component that is built to be attached to the system.img
I have been told that there is a way to use aapt's --version-code option to add/insert a version code into an APK whose manifest doesn't define one. However, I haven't found any examples of people doing this (except for https://groups.google.com/forum/#!msg/adt-dev/XjehZDzfXhk/g2sWBC37_I4J, which links to a dead page and isn't even the same thing I am trying to do) if indeed it is possible to do.
Currently aapt d badging example.apk run on the apk in question returns something like
package: name='com.example.core' versionCode='' versionName='1.0.0'
sdkVersion:'8'
In my manifest I currently have the versionName defined as a string in an xml file, so I can pull it in with something like android:versionName="#string/app_version_name" (inside the manifest tag). However, if I try this with the version code it doesn't seem to want to resolve the reference. It tries to literally set the version code to the path I enter and then fails as it isn't an integer.
I've tried to do something like aapt p --version-code 100 example.apk but it seems to want to package up a whole project and expects a directory of files as input, not an apk file. (I assume that is the default behavior of aapt p[ackage])
Is it possible to set the version code of an APK after it has been built using the aapt tool? If so, what is the correct syntax?
This solution will not use aapt directly, but it will behind the scenes.
You can use Android APKTool to open you APK, alter the AndroidManifest.xml file, adding the version info; and then use APKTool again to repack. That tool is opensource and uses aapt. Thus you can look at its code to figure out how to do it using aapt directly.
So, I have tried everything that I know of possible. I ran an export CLASSPATH=/path/to/bin/classes, and it still isn't able to find the output. I've tried running the command from $PWD/bin/classes, the project's root, and STILL am having troubles getting this to work properly. I have the latest version of the ndk (r8-1 at the time of this writing) and the sdk as well. Generating header files via command line, etc.
So far, I've seen Javah error while using Jni, as well as another question which specified the same problem and received the same answers.
I'm running Arch Linux (Archbang, specifically) in x86_64.
Here's my invocation and output (executed from $PROJECT_ROOT/bin/classes):
javah -d ../../jni com.example.fibonnacinative.libfib
Error: Could not find class file for 'com.example.fibonnacinative.libfib'
I've tried with the -classpath, -verbose, etc. flags and neither appear to help. -classpath just spits out the same error, and -verbose does not give me any information apart from the output I've posted.
Halp?
Yup! It was based on my stupidity.
I should have followed casing conventions for LibFib by typing com.example.fibonnacinative.LibFib as opposed to libfib.
Note: the class itself is typically camel case, whereas the rest of the package directive is lowercase. These are just conventions, mind you.
Sorry folks.