I've created an Android module in Android Studio to create a home screen widget for including in a Delphi app. To do this I need to manually run part of the build process a second time via a manual build script. This script runs aapt to generate the R.java, then javac and dex to re-compile it with some additional modules, which works well.
However, the resulting app + widget doesn't work correctly and I suspect it's the R.java file not being complete. When I host the same widget in a native Java app, the resulting R.java generated by Gradle contains lots of additional items, which I believe may be the problem.
I'd like to see what the generateReleaseRFile Gradle task actually does - i.e. what terminal commands it runs, and, if it calls aapt, what parameters it passes into it so I can compare to my manual build script.
Does anyone know if this is possible?
Thanks!
Related
When running a unit test from within Android Studio on a mac, I can manually run it 1 time, then it fails with the error "Could not execute build using Gradle distribution 'https://services.gadles.org/distributions/gradle-4.10-all.zip'".
I can run it again by deleting my .gradle folder and restarting Android Studio, but this isn't sustainable for testing.
When running the unit test manually with ./gradlew, it works every time but that doesn't lend itself well to debugging.
This applies to even the most simple of tests.
Wanted to add specific error message from the Build tab. This happens on a simple test, with the first time running it working, and the second time running it not working:
#Test
fun testTrue(){
assertTrue(true)
}
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.NullPointerException (no error message)
So, I have a suspect that could be the cause, and a hack that makes it work in the short term.
First, the hack. As many other people have answered, deleting the .gradle folder resolves the issue for me temporarily. However, that is a bit over overkill and forces a complete build every time you run it.
You can get around this partially by deleting just the fileHashes.bin and fileHashes.lock file in .gradle/4.7/fileHashes folder. I wrote a quick script to delete those two files and edited the "Android JUnit" Template in "Run/Debug Configurations" to run that script before every junit run. See screenshot for details, but you'll need to make sure it is the first thing that runs. (Drag it to the first)
The .bsh file is an executable which just deletes those two files.
#!/bin/bash
echo This script deletes the .gradle files necessary for my android studio to work
cd wealth-android/.gradle/4.7/fileHashes
rm fileHashes.*
Now, the real problem may be that I could have multiple implementations of gradle on my machine. I'll look into that more and update the answer.
Recently, I was working on a project in which we have a code-base and we make some changes in the application and make the application available for testing to the tester.
The changes are variables changes such as our test site name, icon and splash screen.
What we are trying to achieve is that without opening Android Studio, we can make the application package(.apk) for the code base that we have. It will save a lot of time for us
We have searched for several options which are Jenkins CI etc, but have not been able to do so.
Any sort of help regarding this topic will be appreciated.
You can run a gradle task from the console / terminal.
Go to the project root folder and run gradle + command, generally the command is gradle assembleDebug or gradle assembleRelease depending on the build type you are aiming for.
You can check the existing gradle tasks on Android Studio
I am trying to set up a CI environment with Jenkins and Robotium. I want to use the same project for both built and test, but seems so tricky to get all working. I was wondering if someone had something like that working and if it can publish at least build.gradle and the project structure. Thanks.
Have been running in production for a few months now. See this question for a sample project and video of how to use robotium with gradle.
https://stackoverflow.com/a/23295849/1965124
As for the jenkins side of things:
Install the android sdk on the machine that will be running jenkins
set up android home variable
install the android plugin
run the following tasks from inside a jenkins job: clean connectedAndroidTest
after running 1 build (it will fail the first time), change the local.properties file to point to the local installation of the android sdk.
Let me know if you need any more pointers, its not as hard as I initially thought it would be.
I configured TeamCity as CI server. Also, project builds by Gradle.
The main idea is to execute gradle connectedInstrumentTest, that task will execute all project's tests on all connected devices, then it will put the test results in standard ant-junit format, so then you can set Jenkins to parse app-folder/build/instrumentTest-results/connected/*.xml test results.
If you got more questions, you can post them to the comments.
I'm wondering if there is a way to run the configured annotation processors from a command ( build in, ant, external tool) so i can add it to my run configuration before "make".
The reasoning behind this is that I have a large Android project with multiple modules, but only my main module uses AndroidAnnotations. Now i have to rebuild the entire project every time i change something of importance in my main module, which adds to my build time. In IDEA 11, annotation processing was also run on "make", but the build system changed in 12.
Any ideas to trigger annotation processing via another way than "rebuild project" ?
Switching to Eclipse compiler in IDEA settings should help until this bug is fixed, otherwise annotations should work fine in 12.0.2 release.
I have Eclipse with Android set up. The problem is when ever I run a project from eclipse to test it, the application never launches and the emulator never shows up. Even though the launching progress bar shows 100%.
Make sure the AVD's memory is set to 512, if it's higher the emulator will get a memory heap error and fail. Also try to enable verbose output when building, this can be set from within the properties.
Do you have a device attached? Eclipse switches to mobile devices automatically
I had once or twice had such problem. Restart of eclipse worked for me. And Yes also check the Run configuration, make sure your project is linked with emulator.
Go to Window->Preferences->Android->Build and select verbose build output
Now run your project and check Android console. In my case there were thousands of
"Dx processing %classname%..." which took several minutes to finish.
Just to make it clear: dx.bat is an ADT utility program, it converts multiple Java class-files to single "classes.dex" file(Dalvik executable file).
I had a project which used several libraries with lot of classes and the compilation was very fast(several seconds), but the launching was quite slow(2-4 minutes).
Then I found out that the most time consuming part was converting class files from my project and from all third-party libraries to *.dex file(the resulting size of dex-file was about 4 Mb). As far as I know, it's impossible to attach libraries to android project without dexing their class-files, so you have to be patient during launching your project.
UPD: It's possible to strip all unused code from your application.
Please check this link: Always running proguard before Android dex'ing in Eclipse