Robolectric 4 AndroidX NoClassDefFoundError MonitoringInstrumentation with IntelliJ 2018.3.4 - intellij-idea

Problem
after switching to androidX
with a multi-module Android library
using IntelliJ 2018.3.4 #IC-183.5429.30
using Robolectric 4.1 with android gradle plugin 3.3.1
when executing Robolectric tests, I receive:
java.lang.NoClassDefFoundError: androidx/test/runner/MonitoringInstrumentation
No duplicate question:
I read the other topics which pop up when using google or stackoverflow search but they are about a more specific error which is worked-around via adding specific dependencies. In my case I was not able to determine which dependency to add.

I add dependencies to androidx.test:core
for the build type under test.
In my case it was debug so in the build.gradle I add
debugImplementation 'androidx.test:core:1.2.0'

I read that no workaround should be required with Android Studio 3.3 and Robolectric 4.0.
Use Android Studio 3.3.1+ with Robolectric 4.0+
This works for me.

Related

Kotlin Multiplatform project include cocoapod dependency

Trying to setup cocoapods for my Kotlin MPP:
plugins {
kotlin("multiplatform") version "1.5.10"
kotlin("native.cocoapods") version "1.5.10"
id("com.android.library")
id("maven-publish")
}
Syncing the project ends up in this error:
Execution failed for task ':podspec'.
> this and base files have different roots: C:\Users\user\AppData\Local\Temp\wrap6957loc\gradlew and G:\Workspace\tracking-lib.
I am on windows and always will be. The project should build on Windows and Mac. So I assume basic inclusion of that plugin should work?
What can I do to fix the paths?
This looks like a bug. The plugin should be disabled, but the build should be working fine. Please consider reporting it to https://kotl.in/issue The cocoapods plugin strongly relies on pre-installed components, such as Xcode CLI Tools, cocoapods and cocoapods-generate. All of them are described here. The iOS targets of the Kotlin MPP project themselves can't be built on Windows, this is a restriction of the compiler. See a full list of targets and their availability here.

How to solve Could not find com.android.tools.build:gradle:4.1.1.?

Can't build react native app in android studio.
I tried:
Sync Project with Gradle Files, but I can't do it because of an
error
File -> Invalidate Caches/ Restart
Clear cache from $HOME/.gradle
Delete $HOME/.gradle
Change com.android.tools.build:gradle version on 2.3.0, because it's
the latest version in this list
(https://repo.jfrog.org/artifactory/libs-release-bintray/com/android/tools/build/gradle/), but when I use npx react-native init projectName, used Android Plugin Version 4.1.2, but this version there isn't in this list.
Also know the difference between Gradle, Android Gradle Plugin,
Gradle Wrapper, already read https://developer.android.google.cn/studio/releases/gradle-plugin?hl=en. I tryied to use the latest Gradle v. 6.8.2 and Android Gradle Plugin v. 4.1.2, it also didn't help to build the project.
Change distributionUrl in
projectName/android/gradle/wrapper/gradle-wrapper.properties
Change in File->Settings->Build, Execution, Deployment->Gradle use
Gradle from Specified location and set C:/Gradle/gradle-6.8.2, it didn't help and left it at default
I know there are exactly the same questions on stackoverflow and on github, but the solutions haven't helped.
Build output:
Could not find com.android.tools.build:gradle:4.1.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.1/gradle-4.1.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :react-native-settings
Add google Maven repository and sync project
Open File
Now used:
Gradle v. 6.5
Android Gradle Plugin v. 4.1.2
gradle-wrapper 6.5-all
Android Studios 4.1.2
Android SDK Platform: Android 10, 9, 8.1, 8.0, 7.1.1, 7.0
Your google Maven library is missing. Rebuild project after adding it

option to create a kotlin multiplatform project not present in idea 2019.3

i want to create a kotlin mp project in intellij idea 2019.3 Community, but the options i see in new project window for kotlin are just jvm|idea and js|idea.
In several articles there are options like mobile shared library | gradle, present even for older versions oj IJIdea.
I already have kotlin in another project, as part of a maven project
any hints?
Make sure you have latest Kotlin plugin installed and Gradle bundled plugin enabled.
See these steps about creating Kotlin MPP project.
gradle plugin was enabled, but still something smelled, so after some time spent enabling/disabling plugins, i decided to enable android support plugin - then after restart idea complained that gradle-java plugin is not enabled, after enabling that (from the error tab link, not the plugin management window in preferences) - the options to create various gradle projects appeared, including the ones for kotlin/multiplatform

Dexguard mapping files not being uploaded for Android Plugin for Gradle 3.0+

We are using Dexguard and the latest Fabric Gradle Plugin version 1.25.2. However, when we run the build with Android Plugin for Gradle 2.3.3, we see the gradle task run for '{namespace}:crashlyticsUploadDeobs{flavor + buildvariant}, but with Android PLugin for Gradle 3.0.1, we don't see this gradle task run and the logs in Crashlytics are not de-obfuscated.
My assumption is that this is the task that uploads the Dexguard mapping files up to Crashlytics.
I see the Fabric Gradle Plugin version 1.24.0 changelog indicates that it addressed this very issue for Proguard. Could there be another issue for Dexguard that needs to be addressed in the Fabric Gradle Plugin?
With help from GuardSquare I was able to identify the issue. Dexguard 8.1 provides a 'dexguard-partial' plugin that let's you exclude dexguard for certain buildTypes. By excluding dexguard on debug builds, you get faster build times. However, this 'dexguard-partial' plugin does not appear to be recognized by Fabric's plugin for Gradle. Therefore, those tasks for uploading the Dexguard mapping files to Crashlytics, never run.
I was able to resolve this issue by switching from the 'dexguard-partial', back over to the 'dexguard' plugin and adding the following conditional check to ensure the plugin is only included for Release builds:
getGradle().getStartParameter().getTaskRequests().toString().contains("Release")
This keeps our build times down for debug builds, by excluding dexguard for those builds. And resolves the Crashlytics issue by including dexguard for release builds.

UiAutomator 2.0 and Eclipse

Is there any way to compile UiAutomator 2.0 with Eclipse and Ant?
I have added the android.jar and uitautomator.jar files from Android-23 but to no avail. Eclipse still does not see UiAutomator 2.0 specific methods like UiObject2.
I have also attempted to build a .jar file with Ant in Gradle which generates the required .jar file but only works for UiAutomator 1.0. I used the method detailed here.
I know Android now officially only supports Android Studio+Gradle now but my setup requires the usage of a standalone uiautomator.jar file that Ant builds, which is not supported (at least as far as I know) with Android Studio and Gradle.
Will appreciate any push in the right direction.