Android - DJI UX SDK and Espresso - VerifyError - gradle

What modules do I have to exclude in my build.gradle file in order to get rid of the following error:
java.lang.VerifyError: Verifier rejected class dji.keysdk.CameraKey due to bad method void dji.keysdk.CameraKey.<init>(dji.sdksharedlib.keycatalog.DJISDKCacheKey) (declaration of 'dji.keysdk.CameraKey' appears in /data/app/pl.company.dev.test-1/base.apk:classes3.dex)
at dji.ux.widget.FPVOverlayWidget.<clinit>(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
My build.gradle file contains the following DJI dependencies:
implementation 'com.dji:dji-uxsdk:4.9'
compileOnly 'com.dji:dji-sdk-provided:4.9'
androidTestImplementation 'com.dji:dji-uxsdk:4.9'
I want to write some Espresso tests for the activity that uses the DJI UX SDK
What I already tried and didn't work:
rebuild app
invalidate caches and restart in Android Studio
delete folders: build, .idea, .gradle
the whole process on another PC
exclude some unneeded dependencies from the DJI SDK

You should not include the same dependency in the app and the tests.
Everything in the app is already in the classpath of the instrumentation tests.
In your specific case, remove
androidTestImplementation 'com.dji:dji-uxsdk:4.9'

Related

gradle default configuration, what is it and how can I define it

I am having a weird error, for which I found a lot of hits in google but most about android studio or library imports and I don't use android studio nor am I trying to build any app/library so I'll try and ask here and see if I understand the background of it.
I have a project in which I have this plugin:
https://gitlab.com/zkovari/gradle-mermaid-plugin/-/blob/master/examples/single-project/build.gradle
This is a plugin that displays my dependencies as a mermaid graph.
Everything was fine until today I updated some dependencies and created a sub-project to do something else.
I'm trying to generate the graph again and somehow it's failing with this error message.
> Task :generateMermaidDependenciesDiagram FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateMermaidDependenciesDiagram'.
> Configuration with name 'default' not found.
I can see in the source code of the plugin that it automatically sets some configurations
#Override
public void apply(Project project) {
GenerateMermaidDependenciesDiagram generateDependencyDiagramsTask = project.getTasks()
.create(GENERATE_MERMAID_DEPENDENCIES_DIAGRAM_TASK_NAME, GenerateMermaidDependenciesDiagram.class);
generateDependencyDiagramsTask.setConfiguration("default");
generateDependencyDiagramsTask
.setOutput(project.getBuildDir().toPath().resolve("mermaid/dependencies.mmd").toFile());
generateDependencyDiagramsTask.setDiagramGenerator(new MermaidDiagramGenerator());
}
So my question is a bit high level but what is the "default" configuration?
And in my project I don't really have any configuration block I simply have my dependencies:
dependencies {
implementation group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: awsVersion, transitive: false
...
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: slf4jVersion
}
My structure looks like this:
project:
-- build.gradle
-- settings.gradle
-- sub-project:
--- build.gradle
I think this stopped working when I added my sub-project but the plugin is applied at the root project level.
I do have a dependency between my sub-project and my root project (one of my sub-project tasks depends on the root project)
I'm trying to understand that this might be very similar but I'm not fully getting it.
Gradle: What Is The Default Configuration and How Do I Change It
I do apply the java plugin on my main project so I expect the configuration.default should exist.
Even if I think I shouldn't do it I tried to re-define a default configuration extending implementation but that did not work
https://docs.gradle.org/current/userguide/declaring_dependencies.html
configurations {
default.extendsFrom implementation
}
build file 'C:\dev\repo\connector-custom\build.gradle': 66: unexpected token: default # line 66, column 5.
default.extendsFrom implementation
I did a quick test and removing my subproject did work so I know the problem is there but no idea why.
It means somehow I must pass to my subproject the default configuration of the main project?

InvokeDynamic not supported when building for Android

I'm running Gluon/charm version 3.0.0. I added a Java8-compiled library into my JavaFX project (created via the IntelliJ plugin) and on iOS it works and builds as expected, but when executing the gradle tasks android or androidInstall I get this error back:
[ant:java] Java Result: 1
:createMainDexList FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':createMainDexList'.
> Exception in thread "main" com.android.dx.cf.iface.ParseException: InvokeDynamic not supported
at com.android.dx.cf.cst.ConstantPoolParser.determineOffsets(ConstantPoolParser.java:226)
at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:132)
at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)
at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:491)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToEndIfNecessary(DirectClassFile.java:397)
at com.android.dx.cf.direct.DirectClassFile.getAttributes(DirectClassFile.java:311)
at com.android.multidex.MainDexListBuilder.hasRuntimeVisibleAnnotation(MainDexListBuilder.java:191)
at com.android.multidex.MainDexListBuilder.keepAnnotated(MainDexListBuilder.java:167)
at com.android.multidex.MainDexListBuilder.<init>(MainDexListBuilder.java:121)
at com.android.multidex.MainDexListBuilder.main(MainDexListBuilder.java:91)
at com.android.multidex.ClassReferenceListBuilder.main(ClassReferenceListBuilder.java:58)
...while preparsing cst 0002 at offset 0000000f
...while parsing de/<removed>/traffic_light/library/Test.class
What I find a bit weird is that I don't even have a Test class for traffic_light, not even in the library. Searching for the error I found that it probably needs Java 8 to invokeDynamic/Support Lambdas, but for example Gluon's Presenter itself uses Lambdas.
Also, googling I find this hit about the same issue but sadly Gluon removed their forum and the page isn't cached anywhere.
Typically this error happens when you add some third party dependencies to the project that use lambda expressions, since currently the retrolambda plugin is applied to the source code of your project only.
You can try:
Remove that dependency and add its source code instead.
Apply retrolambda to the original dependency, and then add it to your project.
Or use the most recent jfxmobile plugin: the 1.0.10-SNAPSHOT will apply retrolambda to both the source code and the third party dependencies (even if no source code is provided).
For the last option, just change the jfxmobile plugin version on top of your build.gradle file:
buildscript {
repositories {
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.10-SNAPSHOT'
}
}

Cannot resolve symbol TexturePacker

Using libgdx 1.7.0/Android Studio, TexturePacker is supposed to be included out of the box if checking the tools option when creating the project (and so I did).
In fact, if I check my build.gradle file, in the project(":desktop") section I have the compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion" added.
But even with that, the build is not able to find the tools package (even though I can successfully use the Controllers extension, which should be the same I think)
I'll leave here the desktop part of the build.gradle, just in case:
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
And a image with the libraries in the project, where you can see the tools...
This is an issue caused by importing tools in Core Dependency. Remove the dependency in the project(":desktop") of the Core Dependency and add it to desktop dependency.
You can also solve it by downloading the gdx tools and importing the jar file. Just create a library folders and paste the jar file. Then go to File > Project Structure > Modules and add the File Dependency which is your jar file.
dependencies {
compile files('libs/runnable-texturepacker.jar')
}
This should work fine.
I was trying to use the TexturePacker class within a class in the core module. However I discovered it to only be available in the desktop module.
This seems logical as the dependency of the tools extension is placed within the desktop project in the root build.gradle file when using the setup utility or following the official instructions to add the extension manually (see Add tools dependency).
Technically, you could move the dependency in the module you want to use TexturePacker in (say core), but according to the provided link this is discouraged. So I recommend you just write your class using TexturePacker within the desktop module.
PS: Note that due to the deprecation of "compile" a replacement by "implementation" in build.gradle might become necessary, but Android Studio will inform you in that case (use ctrl + r for efficient replacements).

Can't install Kontakt Android SDK using Gradle on Android Studio

I'm trying to install the Android SDK from Kontakt into a project in Android studio. I'm following the (seemingly basic) instructions on the Kontakt site here:
http://docs.kontakt.io/android-sdk/quickstart/#installing-the-sdk---android-studio
In brief, these steps say add maven { url 'http://repo.kontakt.io/repository/internal/' } in the repositories in your top-level build file, and add to add compile 'com.kontakt.sdk.android:library:1.0.5' in the dependencies in the main module build file.
However, when I try to sync my project with the updated files, it fails with an error message:
Error:Failed to find: com.kontakt.sdk.android:library:1.0.5
I tried with a totally fresh project and the same issue.
I'm guess this all has something to do with the fact that the instructions are written for Android's 0.12 version of the Gradle tools, but I'm using v1.1.0. I'm not across the detail of Gradle, so so any help would be appreciated.
My guess is that path to Kontakt.io public repository should be added to allprojects section instead of buildscript.
allprojects {
repositories {
jcenter()
maven { url 'http://repo.kontakt.io/repository/internal/' }
}
}
I am not 100% sure so don't shoot me:P
I think adding this line:
-->compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.kontakt.sdk.android:library:1.0.6'
Directly above the gradle project I wanted to compile fixed it.
Go to the Kontakt.io Android Proximity SDK https://github.com/kontaktio/kontakt-android-sdk on GitHub.
Click the Download ZIP button
Un-zip the file to a temporary location.
Add the jar file in your Android Studio Project.
File -> New Module -> Import .JAR/ .AAR Package -> Click Next -> Browse the SDK path (2.1.1) -> Finish (Take time to add in the project)
Then, Add module in dependencies
Right Click on Project Name -> Open Module Settings -> Under the list (Modules) -> Click on Dependencies -> Click on '+' -> Module Dependency -> Add Kontakt.io-android-sdk
Now Build your project It worked for me to kontakt io SDK. If anybody find the way to do this as Gradle build, please let me know.

Android studio include aar dependency

I'm trying to add ActionbarSherlock as dependency using line I got from gradleplease
(Instead of these methods. At least according to this link:
"In Gradle you no longer need to add in these libraries as source code projects; you can simply refer to them as dependencies, and the build system will handle the rest; downloading, merging in resources and manifest entries, etc. For each library, look up the corresponding AAR library dependency name (provided the library in question has been updated as a android library artifact), and add these to the dependency section."
this setup should not be necessary anymore)
But it doesn't work and module settings in Android studio shows error: "Library 'ComActionbarsherlockComActionbarsherlock440.aar': Invalid classes root"
Any idea?
Add these line in your module build.gradle
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
}

Resources