My JUnit 4 tests are failing after updating to Android Studio Arctic Fox | 2020.3.1 Patch 3.
I noticed that it is creating a JUnit test configuration instead of Gradle test configuration when a test is run using the play button/icon near the test class or #Test method.
How to set the testRunner as GRADLE instead of PLATFORM in Android Studio Arctic Fox? There is no runner configuration found in Build, Execution, Deployment -> Build Tools -> Gradle.
Or is there any way we can set this in the build.gradle file?
P.S. This is only for unit-tests and NOT for instrumentation tests.
The GUI where to select the default runner isn't there anymore ..and I'm not sure if Android Studio would pick up idea.properties, but maybe in gradle.properties - or elsewhere, if it still exists:
idea.gradle.prefer.idea_test_runner=true
Related
I need to build a project in Android Studio using second settings gradle file (for sample settings-lite.gradle). How to do that? Andriod Studio version is 2021.2.1.
PS: I don't need to build the project by CLI.
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
To use firebase I need to use the The Google Services Gradle Plugin however I m not under android studio. I already downloaded from maven the google-services-3.0.0.jar but what to do with it? is their any way to make it running outside android studio ? else what exactly this plugin do ? is it possible to do it manually ?
It is possible.
Gradle is just a build tool. Android studio uses Gradle to describe, build and run your project. Gradle plugin is something you add to your build.gradle script. While it's theoretically possible to use it outside Gradle, it's not meant to be used that way.
You can still use the Gradle script in any IDE that supports Gradle, or simply run it from the command line.
The only thing you need in your Gradle project is the following line:
apply plugin: 'com.google.gms.google-services'
I am trying to build an Android Java app using Android Studio 1.0.1. However, my app uses some C++ code that I build using the NDK as controlled by Android.mk and Application.mk files. But Android Studio tries its own build and gets it wrong as it is not using my *.mk files. I know there have been some answers how to do this for previous versions of Android Studio but they evidently do not work for 1.0.1.
So how do I disable Android NDK builds in Android Studio 1.0.1?
Just add the sourceSets.main.jni.srcDirs = [] to 'android' section of your build.gradle. This will disable automatic call of ndk-build with auto-generated Android.mk.
And yes, this line should be added to the project-specific gradle file.
I've got a project that used to be in Eclipse. I've since moved it from there into Android Studio, though it's not using the Gradle build system yet.
I've setup my gradle files so that I can do gradlew build from the command-line and it will generate an APK for me.
My question now is how do I get Android studio to build using the gradle files that I've got setup instead of the using the "old" way?
For what it's worth, I'm on Windows 7.
Not sure how you are compiling the project with Android Studio without actually using Gradle because AFAIK Android Studio always uses Gradle under the hoods to build sources.
Anyway, if you have your Gradle config file ready you only have to import it to a new project in Android Studio (File > Import Project... and then select the build.gradle or settings.gradle)