Multiple dex files define Lcom/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream; - android

I downloaded this sample speech-to-text project:
https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech
The project is working fine. However, I want to add the text-to-speech functionality. Whenever I try to compile com.google.cloud:google-cloud-texttospeech:0.70.0-beta I get the following error and the project crashes:
Multiple dex files define Lcom/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream;
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Here's my app's build.gradle:
apply plugin: 'com.google.protobuf'
apply plugin: 'com.android.application'
ext {
supportLibraryVersion = '25.4.0'
grpcVersion = '1.4.0'
}
android {
compileSdkVersion 25
flavorDimensions "default"
defaultConfig {
applicationId "com.google.cloud.android.speech"
targetSdkVersion 25
versionCode 1
versionName '1.0'
multiDexEnabled true
}
signingConfigs {
release {
storeFile file(project.properties.storeFile)
storePassword project.properties.storePassword
keyAlias project.properties.keyAlias
keyPassword project.properties.keyPassword
}
}
productFlavors {
dev {
dimension "default"
// Minimum version with platform multi-dex support
minSdkVersion 21
}
prod {
dimension "default"
// Minimum version that can run gRPC (TLS extension)
minSdkVersion 16
}
}
buildTypes {
debug {
minifyEnabled false
multiDexEnabled true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.2'
resolutionStrategy.force "com.android.support:support-annotations:$supportLibraryVersion"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/INDEX.LIST'
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.3.0'
}
plugins {
javalite {
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
}
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
grpc {
// Options added to --grpc_out
option 'lite'
}
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// UI-related libraries
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
// Support libraries
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support:cardview-v7:$supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
// gRPC
implementation "io.grpc:grpc-okhttp:$grpcVersion"
implementation "io.grpc:grpc-protobuf-lite:$grpcVersion"
implementation "io.grpc:grpc-stub:$grpcVersion"
implementation 'javax.annotation:javax.annotation-api:1.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
protobuf 'com.google.protobuf:protobuf-java:3.6.1'
// OAuth2 for Google API
implementation('com.google.auth:google-auth-library-oauth2-http:0.7.0') {
exclude module: 'httpclient'
}
// Tests
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
implementation ('com.google.cloud:google-cloud-texttospeech:0.70.0-beta'){
exclude module: 'httpclient'
}
compile 'com.android.support:multidex:1.0.3'
}
task copySecretKey(type: Copy) {
def File secretKey = file "$System.env.GOOGLE_APPLICATION_CREDENTIALS"
from secretKey.getParent()
include secretKey.getName()
into 'src/main/res/raw'
rename secretKey.getName(), "credential.json"
}
preBuild.dependsOn(copySecretKey)

Related

Andriod Build failing due to com.android.support:support-vector-drawable:26.0.2 depends on one or more Android Libraries

In my CI pipeline until June 6 it worked. Today it failed. The following build error occurred.
WARNING: Module 'com.android.support:support-vector-drawable:26.0.2' depends on one or more Android Libraries but is a jar
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not find support-vector-drawable.jar (com.android.support:support-
vector-drawable:26.0.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-vector-
drawable/26.0.2/support-vector-drawable-26.0.2.jar
Build.Gradle file
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "io.realm:realm-gradle-plugin:3.1.4"
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.newrelic.agent.android:agent-gradle-plugin:5.+'
classpath 'com.google.gms:google-services:3.1.0'
classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://mobile-sdk.jumio.com' }
maven {
url "https://maven.google.com/" // Google's Maven repository
}
maven {
url "http://kochava.bintray.com/maven"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'newrelic'
apply plugin: "io.spring.dependency-management"
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
defaultConfig {
applicationId "com.seven.eleven.phoenix"
minSdkVersion 19
targetSdkVersion 26
versionCode 16
versionName "1.1.1_1_QA"
multiDexEnabled true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 21
renderscriptSupportModeEnabled true
}
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
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'
}
sourceSets { main { assets.srcDirs = ['src/main/assets',
'src/main/assets/fonts'] } }
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
buildTypes.each {
it.buildConfigField 'String', 'STRIPE_APIKEY',
keystoreProperties['StripeKey']
it.buildConfigField 'String', 'PHOENIX_API_KEY',
keystoreProperties['PhoenixAPIKey']
it.buildConfigField 'String', 'NEW_RELIC_KEY',
keystoreProperties['NewRelicKey']
it.buildConfigField 'String', 'OPEN_WEATHER_API_KEY',
keystoreProperties['OpenWeatherAPIKey']
it.buildConfigField 'int', 'WORKING_BRANCH', getCurrentGitBranch()
}
}
def getCurrentGitBranch() {
def gitBranch = "Unknown branch"
try {
def workingDir = new File("${project.projectDir}")
def result = 'git rev-parse --abbrev-ref HEAD'.execute(null, workingDir)
result.waitFor()
if (result.exitValue() == 0) {
gitBranch = result.text.trim()
}
} catch (e) {
}
if(gitBranch.contains('master')||gitBranch.contains('PROD') ||
gitBranch.contains('7XXX_Master')){
return "1";
} else {
return "0";
}
}
ext {
SDK_VERSION = "2.10.0"
ANDROID_VERSION = "26.0.2"
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.1',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.squareup.retrofit2:retrofit:2.3.0')
{
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
compile('com.squareup.retrofit2:converter-gson:2.3.0')
{
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
compile group: 'de.mindpipe.android', name: 'android-logging-log4j',
version: '1.0.3'
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile "com.android.support:cardview-v7:${ANDROID_VERSION}#aar"
compile "com.android.support:mediarouter-v7:${ANDROID_VERSION}#aar"
compile "com.android.support:palette-v7:${ANDROID_VERSION}#aar"
compile "com.android.support:design:${ANDROID_VERSION}#aar"
compile "com.android.support:appcompat-v7:${ANDROID_VERSION}#aar"
compile "com.jumio.android:core:${SDK_VERSION}#aar"
compile "com.jumio.android:bam:${SDK_VERSION}#aar"
compile "com.jumio.android:nv:${SDK_VERSION}#aar"
compile "com.jumio.android:nv-mrz:${SDK_VERSION}#aar"
compile "com.jumio.android:nv-barcode:${SDK_VERSION}#aar"
compile "com.jumio.android:nv-barcode-vision:${SDK_VERSION}#aar"
compile "com.jumio.android:nv-liveness:${SDK_VERSION}#aar"
compile "com.jumio.android:dv:${SDK_VERSION}#aar"
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile group: 'com.googlecode.libphonenumber', name: 'libphonenumber',
version: '7.0'
compile('com.squareup.retrofit2:converter-simplexml:2.3.0') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
exclude group: 'xpp3', module: 'xpp3'
}
compile files('libs/simple-xml-2.7.1.jar')
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.jakewharton:butterknife:8.8.1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.kochava.base:tracker:3.2.0'
compile 'com.newrelic.agent.android:android-agent:5.+'
compile 'com.stripe:stripe-android:6.0.0'
testCompile 'junit:junit:4.12'
compile 'com.google.dagger:dagger:2.9'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
provided 'javax.annotation:jsr250-api:1.0'
//for pay with google using google wallet service
compile 'com.google.android.gms:play-services-wallet:11.6.0'
compile 'com.google.android.gms:play-services:11.6.0'
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'org.jsoup:jsoup:1.11.2'
compile
compile('com.amazonaws:aws-android-sdk-kms:2.6+') { transitive = true; }
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile "org.robolectric:robolectric:3.6.1"
}
dependencyManagement {
imports {
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.257'
}
}
apply plugin: 'com.google.gms.google-services'
I have included the build gradle file as well as app level project configuration It was unable to download that dependency.Any help would be greatly appreciated.we are using an gradle 4.1 and a docker container to make the build. I used command ./gradle clean initially.

Can't import external project as module in Android Studio 3

I have an app already published on the store, after upgrading to Android Studio 3 (now 3.1) and the forced update of gradle I am unable to import my external projects as modules.
I have tried removing all my modules and adding them one by one, deleting the cache, changing gradle version, and compileSdkVersion but it doesn't work.
When I try to sync gradle I receive some messages like this:
Unable to resolve dependency for ':app#produzioneDebug/compileClasspath': Failed to transform file 'ShareLib-release.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
This is in my settings.gradle to make external project available:
include ':app'
include ':ShareLib'
project(':ShareLib').projectDir = new File('..//ShareLib//')
This is my build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
def AAVersion = '4.4.0'
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.0.0.0"
applicationId "com.xxx.app"
// Enabling multidex support.
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
}
}
}
signingConfigs {
releaseSigning {
///
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
release {
// proguard
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources false
zipAlignEnabled true
signingConfig signingConfigs.releaseSigning
}
}
flavorDimensions "tier"
productFlavors {
dev {
buildConfigField "String", "SERVICE_URL_BASE", "\"dev.xxx.com/xxx-rest\""
applicationId "development.xxx.app"
}
coll {
buildConfigField "String", "SERVICE_URL_BASE", "\"dev.xxx.com/xxx-rest\""
applicationId "test.xxx.app"
}
prod {
buildConfigField "String", "SERVICE_URL_BASE", "\"www.xxx.com/xxx-rest\""
applicationId "com.xxx.app"
}
}
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'
}
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(path: ':shareLib', configuration: 'default')
// implementation project(path: ':shareLib', configuration: 'default') {
// exclude module: 'jsr305'
// }
// compile fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.squareup:otto:1.3.8'
implementation 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation "org.androidannotations:androidannotations-api:$AAVersion"
annotationProcessor "org.androidannotations:rest-spring:$AAVersion"
implementation "org.androidannotations:rest-spring-api:$AAVersion"
annotationProcessor "org.androidannotations:otto:$AAVersion"
implementation "org.androidannotations:otto:$AAVersion"
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
// support AA on Android < 5
// compile 'com.android.support:multidex:1.0.1'
implementation 'com.github.markomilos:paginate:0.5.1'
// mpandroid
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'
// crashlytics fabric
implementation('com.crashlytics.sdk.android:crashlytics:2.6.1#aar') {
transitive = true
}
// recaptcha
implementation ('android.lib.recaptcha:reCAPTCHA:2.0.0') {
exclude group: 'com.android.support'
}
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
}
I have solved opening modules project one by one and doing this for each one:
Project Structure -> Project -> Gradle Version = 4.7
Settings -> Build, Execution, Deployment -> Compiler -> Uncheck "Configure on demand"
Rebuild project once you can see your .aar file into build/outputs/aar
Then repeat these steps for main project module

DexException:Multiple dex files define Lorg/apache/http/params/HttpParamConfig;

I recently updated android studio to 3.0.0 same for the gradle to the corresponding version, the gradle build successfully but I cant run my project anymore here is my gradle file
enter code here
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
google()
}
apply plugin: 'realm-android'
android
{
signingConfigs {
config {
keyAlias 'XXXX'
keyPassword 'XXXX'
storeFile
file('/XXX/XXX/XXXX/XXX.jks')
storePassword 'XXX'
}
}
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "www.XXX"
minSdkVersion 23
targetSdkVersion 26
versionCode 46
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-
android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
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'
}
configurations.all {
resolutionStrategy.force
'com.google.code.findbugs:jsr305:1.3.9'
all*.exclude group: 'org.apache.commons'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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'
})
implementation project(':carpolo_sdk')
implementation project(':material-sheet-fab')
implementation('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
exclude module: 'support-v4'
}
implementation 'com.android.support:multidex:1.0.2'
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.1'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.android.gms:play-services:11.4.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.jakewharton:butterknife:8.6.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.amazonaws:aws-android-sdk-core:2.3.9'
implementation 'com.amazonaws:aws-android-sdk-s3:2.3.9'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.3.9'
implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.3.9'
implementation 'io.saeid:fab-loading:0.6.0'
implementation 'com.google.firebase:firebase-messaging:11.4.2'
implementation 'com.google.firebase:firebase-auth:11.4.2'
implementation 'com.google.firebase:firebase-crash:11.4.2'
implementation 'com.firebaseui:firebase-ui-auth:2.0.1'
implementation 'com.google.android.gms:play-services-auth:11.4.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.github.florent37:singledateandtimepicker:1.1.0'
implementation 'com.github.apl-devs:appintro:v4.2.0'
implementation 'com.github.curioustechizen.android-ago:library:1.3.4'
implementation 'me.relex:circleindicator:1.2.2#aar'
implementation 'com.github.Mariovc:ImagePicker:1.2.0'
testCompile 'junit:junit:4.12'
implementation 'com.google.guava:guava:22.0-android'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
My swagger gradle file contains the following
enter code here
dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.gson:gson:$gson_version"
compile "org.apache.httpcomponents:httpcore:$httpcore_version"
compile "org.apache.httpcomponents:httpmime:$httpmime_version"
compile "org.apache.httpcomponents:httpclient-
android:$httpclient_version"
compile "com.android.volley:volley:${volley_version}"
testCompile "junit:junit:$junit_version"
testCompile "org.robolectric:robolectric:${robolectric_version}"
testCompile "net.jodah:concurrentunit:${concurrent_unit_version}"
}
I cant find whats wrong with my code any help would be appreciated .
Turns out libraries were mixed together since I did the update to solve that I deleted the .idea folder then I clean and rebuild the project and the error was resolved.

Start activity on kitkat devices

This is thrown when trying to open activity using context.startActivity(intent)
java.lang.TypeNotPresentException: Type android/support/v4/app/ActivityCompat$SharedElementCallback23Impl not present
All activities extends AppCompatActivity and I am calling AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) inside a static block of my application.
On newer android versions everyting is ok.
Does anybody met this issue and can share info how to solve it?
Here my gradle configuration
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
lintOptions {
disable 'RestrictedApi'
}
signingConfigs {
release {
keyAlias '****'
keyPassword '*************'
storeFile file('../release.jks')
storePassword '*************'
}
}
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "***.****"
minSdkVersion 19
targetSdkVersion 26
versionCode 8
versionName "1.0.3"
vectorDrawables.useSupportLibrary true
multiDexEnabled true
renderscriptTargetApi 26
renderscriptSupportModeEnabled true
signingConfig signingConfigs.release
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
jcenter()
}
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':googleemoji')
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude module: 'httpclient'
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.http-client:google-http-client-gson:1.22.0') {
exclude module: 'httpclient'
}
compile('com.google.apis:google-api-services-gmail:v1-rev44-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile 'com.google.firebase:firebase-auth:11.4.0'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:customtabs:26.1.0'
compile 'com.android.support:support-vector-drawable:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.google.android.gms:play-services-identity:11.4.0'
compile 'com.google.firebase:firebase-messaging:11.4.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.google.android.gms:play-services-auth:11.4.0'
compile 'com.google.android.gms:play-services-plus:11.4.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'commons-io:commons-io:2.5'
compile 'com.google.android.gms:play-services-location:11.4.0'
compile 'com.google.firebase:firebase-invites:11.4.0'
}
kotlin {
experimental {
coroutines "enable"
}
}
apply plugin: 'com.google.gms.google-services'

java.util.zip.ZipException: duplicate entry: android/net/compatibility/WebAddress.class

Hy! I am having following problem in my Android project
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/net/compatibility/WebAddress.class
I Know this is because of conflict in dependencies. I looked into dependencies but not able to configure which dependencies causing this issue. I am pasting my gradle code bellow
Module 1 :
android {
//useLibrary 'org.apache.http.legacy'
compileSdkVersion Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK)
targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION)
}`sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/main/java']
res.srcDirs = ['res']
}
test {
java.srcDirs = ['src/test/java']
}
}`compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7` }
packagingOptions {
exclude 'META-INF/ASL2.0'
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'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}`lintOptions {
abortOnError false
}
checkstyle {
ignoreFailures = true
}
buildToolsVersion '25.0.3'`}`dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':webViewMarker')
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'com.squareup:otto:1.3.8'`}`
Module 2
apply plugin: 'com.android.library'`ext {
bintrayRepo = 'maven'
bintrayName = 'folioreader'
publishedGroupId = 'com.folioreader'
libraryName = 'WebViewMarker'
artifact = 'webViewMarker'
libraryDescription = 'An epub reader for Android'
siteUrl = 'https://github.com/FolioReader/FolioReader-Android'
gitUrl = 'https://github.com/FolioReader/FolioReader-Android.git'
libraryVersion = '0.2.5'
developerId = 'mobisystech'
developerName = 'Folio Reader'
developerEmail = 'mahavir#codetoart.com'
licenseName = 'FreeBSD License'
licenseUrl = 'https://en.wikipedia.org/wiki/FreeBSD_Documentation_License#License'
allLicenses = ["FreeBSD"]`}`android {
compileSdkVersion 19
buildToolsVersion '25.0.3'
defaultConfig {
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK)
targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION)
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}`
}
apply from: '../folioreader/bintray/installv1.gradle'
apply from: '../folioreader/bintray/bintrayv1.gradle'
Main Module
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}`}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.ebook.stev_ebook"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':folioreader')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.8.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.apache.httpcomponents:httpmime:4.5.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.stripe:stripe-android:+'
compile('com.twitter.sdk.android:twitter:1.3.2#aar') {
transitive = true;
}
compile 'com.android.support:multidex:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.google.android.gms:play-services-plus:9.0.0'
compile 'com.google.android.gms:play-services-auth:9.0.0'
}
Please comment this
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
Try Rebuilding again. Since it's a third party library , there is a chance that it might be causing the trouble
It means you are using different version of support and all android libraries for example you are using support library version 25.0.1 in one module and version 22.2.1 in another and of course you should add just one of these library to your dependencies when you add one library in one module you should not add it to build.gradle file of second.
Solution : remove duplicate libraries.

Categories

Resources