Manifest Merger Error - Different versions of support library - java

I'm adding the stepper indicator library - https://github.com/badoualy/stepper-indicator - to my project. To do so, I added jitpack to my project gradle file and the stepper-indicator library to my app gradle file. However, I'm getting the following build error:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(25.4.0) from [com.android.support:preference-v14:25.4.0] AndroidManifest.xml:25:13-35
is also present at [com.android.support:appcompat-v7:26.0.0-beta2] AndroidManifest.xml:28:13-41 value=(26.0.0-beta2).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:23:9-25:38 to override.
The other dependencies in my app include:
compile 'com.android.support:preference-v7:25.4.0'
compile 'com.android.support:preference-v14:25.4.0'
compile 'eu.davidea:flexible-adapter:5.0.0-rc2'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-gcm:11.0.2'
compile 'com.google.android.gms:play-services-auth:11.0.2'
compile 'com.google.android.gms:play-services-ads:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
Without upgrading all of the android support libraries to an alpha version, is there a solution to this problem?

In build.gradle you can exclude conflicting dependencies. For example:
compile ('com.github.badoualy:stepper-indicator:1.0.7'){
exclude group: 'com.android.support', module: 'appcompat-v7'
}
To inspect dependencies, you can use Gradle toolbar in Android Studio -> application module -> tasks -> android -> androidDependencies
Update:

Related

Package 'com.example' reads package 'javafx.beans' from both 'javafx.base' and 'javafx.base'

In module-info.java i get the error
Package 'com.example' reads package 'javafx.beans' from both 'javafx.base' and 'javafx.base'.
Not only does the migration (Java 8 to Java 11) frustrate me slowly but surely, this error does not make any sense to me.
The dependencies part fo my build.gradle:
def springFrameworkVersion = '5.1.2.RELEASE'
def hibernateVersion = '5.3.7.Final'
def junitJupiterVersion = '5.3.1'
dependencies {
compile 'org.transentials:cardhouse-commons:1.1.1'
compile 'ch.qos.logback:logback-classic:1.2.3'
compile "org.springframework:spring-context:$springFrameworkVersion"
compile "org.springframework:spring-jdbc:$springFrameworkVersion"
compile "org.springframework:spring-orm:$springFrameworkVersion"
compile "org.hibernate:hibernate-core:$hibernateVersion"
compile 'org.apache.commons:commons-dbcp2:2.5.0'
compile 'org.apache.commons:commons-lang3:3.8.1'
compile 'commons-io:commons-io:2.6'
compile 'com.h2database:h2:1.4.197'
compile 'javax.xml.bind:jaxb-api:2.3.1'
compile 'com.google.guava:guava:27.0-jre'
compile 'org.flywaydb:flyway-core:5.2.1'
compile 'javax.validation:validation-api:2.0.1.Final'
compile "org.openjfx:javafx-base:11:$platform"
compile "org.openjfx:javafx-graphics:11:$platform"
compile "org.openjfx:javafx-controls:11:$platform"
compile "org.openjfx:javafx-fxml:11:$platform"
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.+'
testCompile 'de.saxsys:jfx-testrunner:1.2'
testCompile 'org.apache.commons:commons-text:1.6'
testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testCompile "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
testCompile 'org.hamcrest:hamcrest-all:1.3'
}
And the module-info.java:
module open.terms.client.jfx {
requires org.transentials.cardhouse.commons;
requires com.google.common;
requires org.apache.commons.lang3;
requires org.hibernate.orm.core;
requires java.persistence;
requires slf4j.api;
requires javafx.graphics;
requires javafx.fxml;
requires java.desktop;
}
Can someone explain to me what the compiler wants to tell me by this?
With the required list of dependencies, if you remove all the required modules from the module-info, the IDE will still complain with the same error:
Module '' reads package 'javafx.beans' from both 'javafx.base' and 'javafx.base'
So the problem is not in your module-info, but in your dependencies. If you comment out all of them, except the JavaFX ones, the problem is gone.
This means that some dependency is carrying some unnecessary JavaFX dependency.
I've managed to isolate the problem by commenting only the first dependency:
compile 'org.transentials:cardhouse-commons:1.1.1'
So the question is why is this happening and how can we fix it.
If you go to Maven Central repo it shows the GitHub repo of the dependency, where you can find the build.gradle file and its module-info.
As expected, it uses JavaFX:
compile "org.openjfx:javafx-base:11:$platform"
and it also requires javafx.base in its module-info.
When you consume this artifact with your dependencies you are importing their javafx.base import, along with yours from your JavaFX dependencies and there is the conflict.
The fastest way to solve the issue is just changing this in your build:
compile 'org.transentials:cardhouse-commons:1.1.1'
to this:
compile ('org.transentials:cardhouse-commons:1.1.1') {
exclude group: 'org.openjfx'
}
so you will exclude its JavaFX dependencies and will use yours.
A more permanent fix will be changing the artifact org.transentials:cardhouse-commons's module-info to:
`requires transitive javafx.base`
You can read about the use of transitive here.
An issue should be reported to the author.
Note
As an aside, you can use the javafx gradle plugin to take care of all the related JavaFX parts of the build, simplifying it to:
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.5'
}
repositories {
mavenCentral()
}
dependencies {
compile ('org.transentials:cardhouse-commons:1.1.1') {
exclude group: 'org.openjfx'
}
compile files('libs/cardhouse-commons-master-1.1.1.jar')
...
compile 'javax.validation:validation-api:2.0.1.Final'
}
javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
mainClassName = 'open.terms.client.jfx.Main'
The OpenJFX docs already make use of this plugin.
The error reads, that you've ended up placing same module twice in your modulepath for JavaFX.
The chances are that you might have placed both the jmods for the OpenJFX as well as the OpenJFX SDK/lib on your modulepath.
The JavaFX 11 runtime is available as
a platform-specific SDK
as a number of jmods and
as a set of artifacts in maven central.
Either(one) of these three should be sufficient enough to work with further depending on how you are planning to build your application - modular or non-modular.
Edit 1 [Conceptual Improvement]
In your build.gradle, you should just need to have dependencies over
compile "org.openjfx:javafx-controls:11:$platform"
compile "org.openjfx:javafx-fxml:11:$platform"
since the module, javafx.base and javafx.graphics are transitively present in the module path via javafx-controls anyway. Also, you must ensure, given these dependencies you are not adding any libraries under Project Settings > Libraries.
Edit 2 [Extensible improvement]
Following the documentation at OpenJFX, you can make use of the plugin and get rid of the openjfx dependencies
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.5'
}
javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
dependencies {
// all dependencies except openjfx
}
Edit 3 [Hands on]
The actual culprit in your example is the dependency
compile 'org.transentials:cardhouse-commons:1.1.1'
disabling this fixes the issue. You might want to raise it to the library owner(or fix this if you own it) to ensure that it doesn't bring along javafx.base module along with. To be precise this dependency is bringing in the org.openjfx:javafx-base:linux:11.0.1 as a dependency the reason being clear in their pom.xml dependencies.

Gradle DSL method not found: exclude()

i am using a lot of library in my project. And some libraries using same jar file therefore i writed this on build.gradle :
dependencies {
compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.twotoasters.jazzylistview:library:1.2.1'
compile 'com.google.firebase:firebase-core:10.2.4'
compile 'com.google.firebase:firebase-database:10.2.4'
compile 'com.orhanobut:dialogplus:1.11#aar'
compile 'com.github.recruit-lifestyle:FloatingView:2.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.nineoldandroids:library:2.4.0'
compile ('com.specyci:residemenu:1.6+'){
exclude group: 'com.nineoldandroids', module: 'library' }
compile files('libs/poppyview.jar'){
exclude group: 'com.nineoldandroids', module: 'library' }
}
And i am getting error :
Error:(54, 0) Gradle DSL method not found: 'exclude()'
Possible causes:The project 'DopingEng' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.1 and sync projectThe project 'DopingEng' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
Gradle already update , how can i solve this problem ?
Here's the problem
compile files('libs/poppyview.jar'){
exclude ...
}
A file based dependency does not work in the same way as a dependency coming from a repository. There is no meta data associated with it (eg no dependency information) so there's also nothing to exclude (since there's no transitive dependencies).
Do you have the pom/ivy meta-data for libs/poppyview.jar? If so then you shouldn't declare it like this (I suggest a local maven repository folder). If you don't then there's nothing to exclude

conflicting dependencies - android studio

I am trying to add a dependency giphy4j in my project and this dependency is using junit 4.8.1 but my project is using the latest junit 4.12.
build.gradle(module:app):
androidTestCompile 'junit:junit:4.12'
compile 'at.mukprojects:giphy4j:1.0.1'
This configuration is giving me error on gradle sync.
When I change androidTestCompile to compile and vice versa, It works. I am not getting this point. I dig into dependency stuff compile, apk, TestCompile etc. but couldn't get the proper idea.( As I am a Freshman). And, this conflicting error is also not comprehensible.
point 1: Is compiling the junit(to release with apk) wrong? junit 4.12 is set by default when I create a new project.
point 2: I don't want to configure my third-party-dependency with androidTestCompile becuase It does not show up in release configuration when I run ./gradlew app:androiddependencies.
./gradlew app:androiddependencies output
Error: Error:Conflict with dependency 'junit:junit' in project ':app'. Resolved versions for app (4.8.1) and test app (4.12) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Exclude junit from library.
compile ("at.mukprojects:giphy4j:1.0.1") {
exclude group: 'junit', module: 'junit'
}

Yet another zip duplicate entry

I've use Kryo libs and it's pretty good. However, when I want to create a signed APK, it keeps failing to build because of the error:
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
java.io.IOException: Can't write [C:\AndroidProjects\App\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar] (Can't read [C:\AndroidProjects\App\app\importLibs\minlog-1.3.0.jar(;;;;;;**.class)] (Duplicate zip entry [minlog-1.3.0.jar:com/esotericsoftware/minlog/Log$Logger.class]))
build gradle (module app)
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.android.support:design:24.1.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile files('importLibs/kryo-2.23.0.jar')
compile files('importLibs/minlog-1.3.0.jar')
compile files('importLibs/objenesis-2.1.jar')
compile files('importLibs/reflectasm-1.10.1-shaded.jar')
}
proguard file
proguard-rules.pro
-dontwarn com.esotericsoftware.**
-dontwarn org.objenesis.**
-keep class com.esotericsoftware.**{*;}
What exactly do I need to write to make it work?
There can be case where a library is part of another library that you have imported in your project
Check the lib dependency tree using following command
For Android, use this line
gradle app:dependencies
or if you have a gradle wrapper:
./gradlew app:dependencies
Or else there is a less popular Android studio plugin called GradleView that can give you entire lib tree used in your application and also where it might be clashing with some other library.
I had similar problem, and I solved it with just including retrofit:
'com.squareup.retrofit:retrofit:1.9.0'
I hope it will help you too.

Getting QueryResultIterable not found error with Gradle appengine project using Objectify

I've set up an Gradle App Engine project and ported over my code that was working perfectly well. But on building the project through Gradle I get the following error:
20:28:32.036 [INFO] [org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler] Compiling with JDK Java compiler API.
20:28:32.088 [ERROR] [system.err] D:\Projects\WordBuzzIntegrated\wordbuzzserver\src\com\wrc\wordbuzzweb\service\Login.java:21: error: cannot access QueryResultIterable
20:28:32.088 [ERROR] [system.err] User user = ofy().load().type(User.class).id(facebookUser.id).now();
20:28:32.089 [ERROR] [system.err] ^
20:28:32.089 [ERROR] [system.err] class file for com.google.appengine.api.datastore.QueryResultIterable not found
I don't really have a clue what's causing the problem and Googling the error returns zero results. My dependencies list is as follows:
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.15'
providedCompile 'javax.servlet:servlet-api:2.5'
testCompile group: 'junit', name: 'junit', version: '4.11'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.3'
compile 'com.googlecode.objectify:objectify:5.1.1'
}
If anyone has any idea what might be going on here then your help would be greatly appreciated.
There are other App Engine dependencies that need to be included in the Gradle build. I ended up including all of the following for good measure - although I'm not sure all are required:
dependencies {
appengineSdk "com.google.appengine:appengine-java-sdk:$appEngineVersion"
compile "com.google.appengine:appengine-api-1.0-sdk:$appEngineVersion"
compile "com.google.appengine:appengine-endpoints:$appEngineVersion"
compile "com.google.appengine:appengine-endpoints-deps:$appEngineVersion"
compile "com.googlecode.objectify:objectify:5.1.1"
compile group: "com.google.guava", name: "guava", version: "18.0"
}
If using IntelliJ be sure to add the jars to your artifact for deployment.
If you want to run unit tests (junit included below) then you'll also need to add the following
testCompile group: "junit", name: "junit", version: "4.11"
testCompile "com.google.appengine:appengine-testing:$appEngineVersion"
testCompile "com.google.appengine:appengine-api-labs:$appEngineVersion"
testCompile "com.google.appengine:appengine-api-stubs:$appEngineVersion"
You'll also need to include the following in your Gradle script to set the app engine version. (Check what the latest version is)
ext.appEngineVersion = '1.9.21'
The Problem can be solved by adding the following dependendy in Gradle:
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.21'
You do not need to have the dependency for Cloud Endpoints if you are not using it, although it will also solve the problem as it has itself a dependeny on the missing one.
Ran into the same issue when generating a module with Android Studio which did not include this API. I could not even find any information on it in the documentation.

Categories