i tring to run my app but the gradle give me this error
:app:transformClassesWithJarMergingForDebug FAILED Error:Execution
failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/inject/Inject.class
Information:BUILD FAILED
this my AndroidMainifist.xml
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.example.mohamed.movieapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'org.glassfish.jersey.core:jersey-client:2.22.1'
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.22.1'
}
repositories {
maven { url 'java.lang.android.support.v7.app.WindowDecoreActionBar' }
}
can any one help please
The duplication comes from jersey client. It depends on both org.glassfish.hk2.external:javax.inject and javax.inject:javax.inject.
So, you need to exclude one of them:
dependencies {
...
compile ('org.glassfish.jersey.core:jersey-client:2.22.1') {
exclude group: 'javax.inject', module: 'javax.inject'
}
...
}
I try to use org.glassfish.jersey.media:jersey-media-moxy in my project and had to apply the same exclusion for that dependency too - likely it will be the same for org.glassfish.jersey.media:jersey-media-json-jackson.
Related
I updated to AndroiStudio 3.4
and now I get Error: "Gradle Project sync failed "
ERROR: ParseError at [row,col]:[19,9]
Message: expected start or end tag
Affected Modules: app
But I cant find any illegal character or mistake in my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.tye.vbassistent"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation "org.jetbrains.anko:anko-common:0.8.3" // TyE: Hinzugefügt 2018-04 für 'alert'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
What's my mistake?
The error message does not refer to the build.gradle file, but the AndroidManifest.xml.
Check for syntax errors in the AndroidManifest.xml at [row,col]:[19,9]
I was trying to create a new project which has two flavor, and the sdk is independent of app.
So I modified these build.gradle files like below:
For the android lib module: sdk:
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
en
zh
}
publishNonDefault true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile(name: 'HERE-sdk', ext: 'aar')
}
repositories {
flatDir {//HERE SDK
dirs 'libs'
}
mavenCentral()
}
For the android app module: app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "cn.hudplay.testgradle"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
en
zh
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
enCompile project(path:":sdk",configuration:"enRelease")
zhCompile project(path:":sdk",configuration:"zhRelease")
//compile(name: 'HERE-sdk', ext: 'aar')//this seems to be workaround if un-blocked
}
repositories {
flatDir {//HERE SDK
dirs 'libs'
}
mavenCentral()
}
Then it told me Failed to resolve ::HERE-sdk:, and no other reasons..
I tried to move Here-sdk related gradle code to app's build.gradle, no more wrong.But I do need it in the sdk module..
What should I do..Anyone could help me?
Workaround used temporarily :
compile HERE-sdk for both app and sdk, no more wrong again. But I still feel something not right there...
Hi HERE updated the documentation maybe that help you with the issue. I had the same problem too and it worked out following these steps here:
https://github.com/heremaps/here-android-sdk-examples
What worked for me using the code above as an example (and if someone looks for a solution that works) was this approach:
copy the "\HERE-sdk\libsHERE-sdk.aar" file (dowloaded from your account on Here) to your \App\libs folder, then:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar','*.aar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
//compile(name: 'HERE-sdk', ext: 'aar')
}
NOTE: what changes was only 2 lines:
COMMENTED -> //compile(name: 'HERE-sdk', ext: 'aar') and ADDED -> '.aar' extension to array scope here -> compile fileTree(dir: 'libs', include: ['.jar','*.aar']).
OBS: I know thi's an old question and maybe someone out there in this outside world must have already answered it, but I leave here my humble contribution. If someone wants to employ me, I'm looking for a job hehehe
I got the aar compile without error by adding by adding it from
Open Module Settings
Step 1 , add the aar into app/libs folder
Step 2, Right Click App and negative to Open Module Settings
Step 3, Click on dependencies on the left and then click on the + under Declared Dependencies
Step 4, Select the libs/HERE-sdk.aar from the drop down and then click OK
Can Anyone explain me what is Version Tag for git in this, I am getting error while importing this.
apply plugin: 'com.android.application'
buildscript {
repositories {
maven { url 'https:example.com' }
jcenter()
mavenCentral()
mavenLocal()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.jatinder.bdugame"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG'
}
Error:
Error:(45, 13) Failed to resolve: org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG
Show in File<br>Show in Project Structure dialog
What does you question have to do with Git or Maven?
It does not even have anything to do with Android, besides coming from an Android project.
You declared the compile time dependency org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG which means group org.bitbucket.5elements, artifact SmartTones-SDK, version VERSION_TAG. This combination is not found in any of your declared repositories, so it fails to be resolved, just as the error tells you.
In my gradle android application when I run the application I got below error.
Error:Gradle: duplicate files during packaging of APK /home/WorkSpace/MyProject/app/build/outputs/apk/app-debug-unaligned.apk
Error:Gradle: Execution failed for task ':app:packageDebug'.
Duplicate files copied in APK META-INF/license.txt
File 1: /home/.gradle/caches/modules-2/files-2.1/org.springframework.android/spring-android-rest-template/1.0.1.RELEASE/e132d929bd181941f79b0d63edafb8a86ae6fd33/spring-android-rest-template-1.0.1.RELEASE.jar
File 2: /home/.gradle/caches/modules-2/files-2.1/org.springframework.android/spring-android-core/1.0.1.RELEASE/e68f0e8e4b636ee30c4de58953be38d9b72a5e3b/spring-android-core-1.0.1.RELEASE.jar
Below is my gradle file.
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.myproject.app"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/notice.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:gridlayout-v7:23.2.0'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'joda-time:joda-time:2.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.2'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.android.support:design:23.2.0'
}
How I can solve this error? Please help me.
Add below lines in the packagingOptions and dependencies.
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
And in dependencies use as below.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile('org.springframework.android:spring-android-auth:1.0.1.RELEASE') {
exclude module: 'spring-core'
}
compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'joda-time:joda-time:2.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.2'
compile 'com.google.code.gson:gson:2.6.2'
}
I think this will solve your issues.
You already have this in your build file:
packagingOptions {
exclude 'META-INF/notice.txt'
}
You can just add license.txt there as well.
I've introduced a dependency for my unit tests to a custom task I've written in gradle. In android-gradle v1.2.3 the unit test task is named test. So I assumed you add a dependency with test.dependsOn. Gradle doesn't like that.
Error:
C:\coding\source\testapp\app\build.gradle
Error:(30, 0) Could not find property 'test' on project ':app'.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.nilzor.myapplication"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
task myTask() {
}
test.dependsOn 'mytask'
Where do I go wrong and how do I fix it?
Solution: Wrap it in
afterEvaluate {
test.dependsOn 'mytask'
}