Showing posts with label Android Studio. Show all posts
Showing posts with label Android Studio. Show all posts

2020-11-12

Android Studio: “No tests were found” Error, Trying to Run Android Instrumented Tests (androidTest)

 

In Android Studio I was getting to “No tests were found” error when trying to run Android Instrumented Tests (androidTest).
In another Android project of mine I had no such problems.
None of the suggestions from stack overflow helped.

In my case, I had the following statement the testOptions block in build.gradle(:app) in my problematic Android project.
testOptions {
    . . .
    execution 'ANDROIDX_TEST_ORCHESTRATOR'
}

Removing / commenting out execution 'ANDROIDX_TEST_ORCHESTRATOR' resolved my problem.

I hope this helps!

2020-09-26

Android Studio: "androidTest" Raising "java.lang.ClassNotFoundException: Didn't find class"

 

If you are trying to run an androidTest with Android Studio and get the following error:

java.lang.NoClassDefFoundError: Failed resolution of: L....
. . .
Caused by: java.lang.ClassNotFoundException: Didn't find class "..." on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file ...
. . .

Check your build.gradle (:app) File, if you have "minifyEnabled true" enabled in your debug build type

buildTypes {
    debug {
        . . .
        minifyEnabled true
        . . .

Try commenting it out.

I hope it helps.


2020-02-27

How to Copy File From Host to App Data Folder in the Android Emulator

You are developing an Android app with Android Studio.
And you want to copy some files from the Android emulator to your computer (I call it host).
You can do it easily with the Android Studio by using the Device File Explorer.

But the Device File Explorer does not allow to copy files in the opposite direction
(e.g. from the host the the emulator).

Here are the steps how to do this.

Open the Android Studio terminal.

Copy your file (here for example: MyFileToCopy.txt) to a "public accessible folder" on the android emulator (i.e. /sdcard/):
OS> adb push MyFileToCopy.txt /sdcard/
MyFileToCopy.txt: 1 file pushed. 0.1 MB/s (30 bytes in 0.016s)

Logon to the adb shell:
OS> adb shell
generic_x86_64:/ $

Change to "your App account" (here as example: ch.my.app-name):
127|generic_x86_64:/ $ run-as ch.my.app-name

generic_x86_64:/data/data/ch.my.app-name $

In the Android emulator, copy (or move) the file
from the "public accessible folder" (i.e. /sdcard/)
to "your App folder" (here for example: /data/data/ch.my.app-name/files/):
generic_x86_64:/data/data/ch.my.app-name $ 

cp /sdcard/MyFileToCopy.txt /data/data/ch.my.app-name/files/

2019-11-04

How To Correct Logcat Missing Filter In Android Studio


Before trying to restart the Android Studio in order to make the logcat filter fields re-appear (this did not worked for me the last time), simply try first to change the window size to “Restore Down” and back to “Maximize” or the other way around. (This worked for me on Windows 10).

Here is what I mean:

"Restore Down"

"Maximize"

I hope this helps.


2018-08-13

Handling "org.gradle.api.GradleException: Lint found fatal errors while assembling a release target"


If the following error occurs when building the app . . .
org.gradle.api.GradleException: Lint found fatal errors while assembling a release target.

To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}
. . .

Instead of simply adding the android block as suggested by the message, perform a manual lint check as follows
"Analyze" -> "Inspect code .."

Most of the time the problems I had, were that some translation was missing.