I'm developing a script to build android project which referencing lib-project so there is some preparations before launching ant, so I decided put that actions into a .bat-file.
The .bat's structure is like the following:
1 - #some preparation actions (moving files, updating properties etc.)
2 - ant debug
3 - #clean everything that was done in the first section
So, the problem is that nothing is executed after the second section - 'ant debug' - though build was successful.
Can anybody shed some light on what am I doing wrong and how to make the script after ant debug-command be executed?
Thanks in advance!
Try the following
...
call ant ...
...
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 trying to run
RobolectricSample
RobolectricDemoProject
project with IDEA and i got error
Class not found: "de.peterfriese.robolectricdemo.MainActivityTest"
Process finished with exit code 1
but when i use gradle test command all is ok.
this is my Junit config
now, in IDEA you have using non gradle project. That mean you can look on project structure (Ctrl+Shift+Alt+S) and look on Library visibility. (Runtime, Provided,etc) also export property are exist. When library are provided or no exported, it will be absent in target apk.
Also you can build project as gradle test project. so IDEA will use your gradle test target. Build will take litle more time.
(This is an Android SDK tools v17 problem. Expect a fix in v18)
I have a test target project A, and a tester project B.
Project A has FlurryAgent.jar in its libs folder.
Project B has robotium-solo-3.1.jar in its libs folder
When I compile and run them,
cd A
android update project -p .
cd ..
cd B
android update test-project -p . -m ../A
ant all clean debug
ant uninstall
ant installt
ant test
ant test fails to execute tests:
test:
[echo] Running tests ...
[exec]
[exec] com.example.r17.test.TestOne:
[exec] INSTRUMENTATION_RESULT: shortMsg=java.lang.NoClassDefFoundError
[exec] INSTRUMENTATION_RESULT: longMsg=java.lang.NoClassDefFoundError: com.flurry.android.FlurryAgent
[exec] INSTRUMENTATION_CODE: 0
I've read some posts/questions that solve this problem in Eclipse. But I don't think I can run Eclipse on headless Jenkins slave.
Since this post was the first in search engine results when I entered "java.lang.NoClassDefFoundError: com.flurry.android.FlurryAgent" and my issue was not related to Ant at all, I thought I'd add some info for people who might be scratching their heads after re-installing the ADT.
Basically, in Eclipse when you add an external library in the Java Build Path dialog, don't forget to also switch to the Order and Export tab and tick that library's name in the list. This is needed so that the library is found at run-time, not only at compile time :)
http://code.google.com/p/android/issues/detail?id=27608
I submitted the issue to Google and they uploaded a temporary fix. The fix will also be included in v18 release.
"project member x...#android.com, Today (34 minutes ago)
get the anttasks.jar from the bottom of http://tools.android.com/download to replace the one in your sdk."
The file to replace is at \Android\android-sdk\tools\lib\
It took me a very long time to figure this same problem out when using android-junit-report, but with the help of "adb logcat" I discovered that it wasn't actually missing the instrumentation class that I included, but it was missing its inherited superclass. So I needed to put this back into AndroidManifest.xml:
<application>
<uses-library android:name="android.test.runner" />
</application>
I dont have the rep to comment Qi but I think this may be related to my question here:
VerifyError in android test-project build tools v17
Xav has been instrumental in getting this back up and running and looks like hes got a fix
I have the same case and it doesn't work even if I followed Levon's post. Then I realized I need to copy the FlurryAnalytics.jar into the libs folder in my work space to make it work. Hope this helps.
I have just fix this problem "08-14 08:33:43.398: E/AndroidRuntime(6748): java.lang.NoClassDefFoundError: com.flurry.android.FlurryAgent"
I flow the official web when I want to add the flurry to my android app,it tell me add an external library in the Java Build Path dialog, And then I don't forget to also switch to the Order and Export tab and tick that library's name in the list. This is needed so that the library is found at run-time, not only at compile time,But however it do not works until I just remove the jar from build path,and then copy it to the lib. Done!!!
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.
I have started to have a play with Android programming and I got a basic project setup a couple of weeks ago and followed a tutorial from a magazine. I know that I managed to get the basic ant compilation to work but now I come back to it it fails with a slightly weird message:
$ ant debug
Buildfile: /home/taft/android_code/countdown/build.xml
BUILD FAILED
/home/taft/android_code/countdown/build.xml:37: Cannot find /home/pete/android-sdk-linux_x86/tools/ant/pre_setup.xml imported from /home/taft/android_code/countdown/build.xml
Total time: 0 seconds
taft is my username; I have the sdk installed in ~/bin/ and my path is setup sensibly (I think):
$ echo $PATH
/home/taft/bin:/home/taft/bin/android-sdk-linux_x86/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/taft/bin/android-sdk-linux_x86/platform-tools/
I don't have a pete user and I am not sure where it is getting this path from; line 36 & 37 of the build.xml looks like this:
<!-- Required pre-setup import -->
<import file="${sdk.dir}/tools/ant/pre_setup.xml" />
Now I am guessing that sdk.dir should be automatically populated by something... but I don't know what? Has anyone else run into this problem or have suggestions for what I can try next?
Make my comment an answer
After much digging about I think I have fixed it
$ android update project -p .
I navigated into the project & fired off the above command which should update any projects. Running the command I got the following output:
$ android update project -p .
Updated local.properties
File build.xml is too old and needs to be updated.
Updated file ./build.xml
Updated file ./proguard.cfg
After that everything seems to have build fine again. I hope someone else finds this useful as I was stumped by this for about an hour (OK it was late last night, so I was not at my best).