I'm automating the publication of my Android app and I'm using Gradle, great utility!
Just a problem, consider this .bat file (under Windows 7):
:: assemble the project
gradle assemble -Pprofile_name=%profile_name% -p%destination_dir%
::copy apk to repository
copy "D:\compile\myapp\build\apk\*.apk" "d:\build_repository"
Well the copy command is never executed, never. It seems that the execution stops after calling gradle utility. Any idea?
The build within Gradle has ends with success and no error at all...
I ran into this very same problem, but for a webapp. Gradle isn't necessarily the issue, but how you are invoking it. As explained in this post,
How to execute more than one maven command in bat file?
because gradle is a batch file itself, it completes execution and doesn't return control back to your batch file. Use the same 'call' strategy and everything should work.
Like so for your original post,
call gradle assemble -Pprofile_name=%profile_name% -p%destination_dir%
::copy apk to repository
copy "D:\compile\myapp\build\apk\*.apk" "d:\build_repository"
If you are on ionic/cordova and batch execution is stopping after ionic cordova build --release android use call before
call ionic cordova build --release android
Related
I am very new to KMM (Kotlin Multiplatform Mobile) and iOS development (including CocoaPods). I have come across the following build error in Android Studio.
Execution failed for task ':shared:podInstall'.
java.io.IOException: Cannot run program "pod" (in directory "/Users/.../AndroidStudioProjects/.../iosApp"): error=2, No such file or directory
The directory definitely exists and I seem to be able to manually run pod commands from within the directory. I am not sure but it seems like this problem came about when I updated the Kotlin plugin from 1.5.0 to 1.5.10. This problem occurred even when starting a completely new KMM project.
I thought it might have something to do with Android Studio not being able to find the pod command so I added it to the path but that didn't seem to do anything. Any help with this would be appreciated.
Check your Gradle JDK :
Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Gradle
Then select Gradle JDK -> Embedded JDK
Maybe you must execute in command line :
./gradlew :shared:podInstall
Have you tried File > Invalidate Cache and Restart?
I had exactly same issue, but It got fixed after invalidate cache and restart.
I tried ./gradlew build but that didn't work, because it doessnt see the changes made in gradle file. The only thing that works for me is restarting and invalidating cache, but there must be a better way to do it.
Thank you
You should try running ./gradlew clean before building.
change directory to /{your project}/android then run below commands
./gradlew clean
./gradlew build
Note :-
you will get error : ./gradlew: No such file or directory
if you are trying gradlew commands outside android folder.
also check this : Why run 'gradle clean build' instead of 'gradle build'?
We have Gradle set up to build and test our Android app. Now we ran into the problem, that Gradle test runs fail reproducibly after a class was renamed somewhere in the project:
Execution failed for task ':PROJ:compileDebugUnitTestJavaWithJavac'.
> Unable to read class file: '/path/to/class/with/the/name/before/renaming.class'
This error is reproducible both..
locally (run gradle tests from Android Studio, or on command line using ./gradlew test), and
remotely, when the tests run on our CI (a Teamcity server).
What solves the issue, is manually triggering a rebuild locally (e.g. in Android Studio Build > Rebuild Project) or re-running the Teamcity task with the flag clean all files in the checkout directory before the build set.
Is there any way we can get our tests to not fail after a class has been renamed?
While the above solution is simple enough it is kinda annoying that a simple rename which makes it to our repo will blow up the CI builds... We really want those to stay green. :)
This is a known issue in Gradle 2.14 and 2.14.1 and there will be a workaround for it in upcoming Android Gradle plugin release.
As a workaround you can do a clean build for your project. For a CI build, a clean build is a good idea anyway.
You could use the Swabra build feature of TC that cleans out the working directory either before or after each build, so that all generated files are blown away and the build always starts with a clean working copy. For reproducible builds this is a must-be-used feature in my opinion.
Alternatively you can of course also add the clean Gradle task to your TC configuration so that Gradle cleans away previous build artefacts. But if using TC I'd prefer Swabra as it restores VCS state reliably.
My build.gradle for an Android app has become quite lengthy. Chanced upon this plugin called gradle-lint-plugin and configured it properly. In its documentation it says
Run ./gradlew fixGradleLint to automatically fix your build scripts
but upon running that I get Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain.
Does this have anything to do with the Android Studio using its own Gradle plugin? I do not have Gradle installed systemwide.
Edit: I do not wish to install Gradle systemwide - is there any way to do this within Android Studio only?
Sounds like the wrapper is not setup correctly. Likely missing the wrapper jar.
$ ls gradle/wrapper
gradle-wrapper.jar gradle-wrapper.properties
When you look in gradle/wrapper do you see gradle-wrapper.jar?
if you install gradle you can generate the jar with this command:
$ gradle wrapper
I was having this error and I solved it correcting the path which had special caracters.
Ex: .../T&G/appmobile
to ../TG/appmobile
This sometimes happens if you have "&" or "/" kind of special characters in your folder or in the parent folder. Rename those folders and the error is simply gone.
I recently added push notification to my app using react-native
and since at seemingly random times I get messages such as in the added photo
Execution failed for task
':app:processDebugResources'.
java.io.IOException: Could not delete folder ..\android\app\build\generated\source\r\debug\com\facebook\drawee
Did anyone experienced something like that or has a solution?
Run this command to clean project:
cd android && gradlew clean
After, run the following command to run project again:
cd .. && react-native run-android
I had the same problem. I changed the permissions of the project folder and all subfolders to full access from all users, and now it seems to work!
So apparently the packager can cause two types of file-access errors to occur during gradle syncing and building:
1) "EPERM: operation not permitted, lstat"
2) "java.io.IOException: Could not delete path"
These are actually two separate problems -- one of them caused by the watchman npm module, and the other caused by the packager itself.
Instructions to solve them can be found here: https://stackoverflow.com/a/47420765/2441655
If you are running the application in android device then go to the android director in your react native project then Delete the build folder/(Directory) then again run the project.Its work for me
The path of the build folder
YourProject/android/