Is it possible to run a unix shell script in Android Studio before every (gradle) build?
I'm having some trouble with gradle builds taking forever and one (admittedly bad) solution that works is to kill all java processes if they hold more than say 6Mb memory.
What I would like to do is run a shell script that does that before every build in Android Studio.
I'm not looking to add a gradle task to run before my build. That won't work because if I kill all java processes, gradle will also be killed.
So again:
Can I set up Android Studio (or gradlew) to run a script before building?
Instruction for Intellij Idea, but I hope it works for Android Studio
Edit configirations...
Select\create run configuration for gradle build. Add "before launch" option
Select ptoper option. For example - "Run external tool"
Related
I have created a basic KMM by following "Create your first app" guide
https://kotlinlang.org/docs/kmm-create-first-app.html
Then I've tried to build the framework with the following command from Terminal in Android Studio.
./gradlew :shared:embedAndSignAppleFrameworkForXcode
But I'm getting this error.
Task 'embedAndSignAppleFrameworkForXcode' not found in project ':shared'.
Android Studio 2020.3.1 Patch 3
Kotlin 1.5.31
There's a similar question on SO. People say that embedAndSignAppleFrameworkForXcode should work with Kotlin 1.5.20 at least.
KMM - Error Task 'embedAndSignAppleFrameworkForXcode' not found in project ':shared'
But it doesn't in my setup.
Does anyone know how to fix this?
UPDATE
The task is running perfectly fine when launched form XCode/Build Phases script.
Somehow it is not able to launch from terminal (Android Studio or system one).
I think embedAndSignAppleFrameworkForXcode is not supposed to run from the terminal as packForXCode used be.
The proper way to run this task is from XCode build system.
Anyway, I was able to run embedAndSignAppleFrameworkForXcode from terminal after exporting the following variables.
export CONFIGURATION\=Debug
export ARCHS\=x86_64
export EXPANDED_CODE_SIGN_IDENTITY\=-
export FRAMEWORKS_FOLDER_PATH\=iosApp.app/Frameworks
export SDK_NAME\=iphonesimulator15.0
export TARGET_BUILD_DIR\="../build/ios/${CONFIGURATION}-iphonesimulator"
Since upgrading to AS 3.4 I can no longer debug any of my apps. I have made no changes to any of the projects, I just upgraded AS. Now all I get is "Waiting for application to come online".
When I click on Run->Attach Debugger To Android Process, there are no processes to attach.
The apps load and run, but I cannot debug them.
Is there anything I can do to get the debugger working?
(I have tried clean, rebuild, invalidate cache and restart, make project and gradlew clean).
I found the same trobles in Android Studio Dolphin (2021.3.1) when created a new project with no activity. After the project creation I created a main activity and add a launcher intent-filter and tried to debug it. And found "Waiting for application to come online". I found that "Launch" argument in "Lunch Option" for my "Run Configuration" is "Nothing". Problem solved by changing it to "Default Activity"
To change run configuration option select Run->Edit Configurations, or "Modify Run Configuration" in Run or Debug panel.
I had the same problem, I tried: Update Android studio to 3.5, restart cache, delete cache folders, killing adb server and restart it... but nothing works.
I solved executing the next commands on ADB terminal:
On windows, you have to change to platform-tools folder path in order to excecute ADB commands, something like this:
cd C:\Users\YourUser\AppData\Local\Android\Sdk\platform-tools
Then, compile your app on debug mode. (I think shift + F9 on Windows), when you started to see "Waiting for application to come online" message, execute the next adb command:
adb shell am start -n com.example.yourPackage/com.example.yourPackage.MainActivity -D
Just change com.example.yourPackage and make sure MainActivity its your Luncher Activity inside your Manifest File.
I updated Android Studio to version 3 and since then all my spock tests, when in a java module, do not run when trying to run them from inside the application (right click on groovy folder -> Run 'Tests in groovy'). I get a:
Class not found: "package.name.classname"Empty test suite."
Same if I try to run a single test.
If I run the test task from the gradle panel I get this:
error. Cause: unknown.
On the other hand:
Any spock tests in android modules run fine.
All my java tests in all my modules run fine.
All my tests (spock and java) run fine when running them from outside AS using gradle (gradlew clean test).
My setup:
gradle v4.1
android gradle plugin v3.0.0
java version compatibility v1.8
in my java modules i use the gradle groovy plugin
in my android modules i use the groovy android gradle plugin
A few things I tried after searching in both google and here:
changing the android gradle plugin back to v2.3.3 and gradle to v3.3
trying to copy all groovy classes to build/classes/java/test
So this is more of a workaround than an actual solution but it should give you your debugger back which is probably 90% of the value anyway:
You can run your test suite like:
./gradlew <module>:test --debug-jvm
And the jvm running your tests will suspend until a debugger attaches.
From Android Studio bring up the action chooser by pressing ctrl + shift + a (on linux anyway, check the equivalent for your OS) and select:
Attach to local process...
Once Android Studio attaches the tests will begin running.
The --debug-jvm flag can be used together with --tests to debug an individual test:
./gradlew <module>:test --tests fully.qualified.test.Test --debug-jvm
I have an Android Studio NDK module with about 200 small C files I'm trying to build as a native library. When I do a build either from within Android Studio or from the command line with gradlew, the build process hangs part way thru compiling one of the files. Which file it hangs on is random from build to build. When the build hangs the only recourse is to kill the clang process(es) and try again. On rare occasions it will actually complete.
One guess I have is that there is some windows issue with multiple simultaneous compiles for the module. Is there a way to force make to use -j1 to test this?
Are there other reasons the build would hang?
Environment - Windows 10, Android Studio 2.3.3, Gradle 3.4.1
I am just starting to play with the JHipster framework / code generator using intellij 14.1.5 on OSX Yosemite. I have a simple app with a couple of domain objects which I have imported into Intellij as a gradle project. When I attempt to run the app via the gradle build "run" task, the build fails on the bower command. I can successfully run this gradle task from the osx terminal app AND from withing Intellij's terminal window. It fails when I invoke the run task from the from the gradle tasks pane or if I run it from the "run configurations" drop down in the toolbar. It feels like it fails when Intellij invokes gradle, but succeeds when gradlew is invoked in a terminal. I'm not sure why there would be a difference in these environments / invocations.
I have installed npm/gulp/bower/yoeman via nvm/node and am up on current versions (installed today). Node is at 4.1.1.
Posting this answer because no one has posted one yet. I have followed the recommendation of this other post. It fixes the Intellij app launcher on the mac to recognize the path for node commands. The original technique is described in apple.stackexchange.com. I am using this technique with the latest Intellij Idea 2016.1.3 and Intellij invoked gradle runs bower / npm just fine.
Just update gradle version.
Open gradle/wrapper/gradle-wrapper.properties
and change version like
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip