naderio / nativescript-socket.io

Fully-featured Socket.IO client implementation for NativeScript
The Unlicense
48 stars 21 forks source link

Android build fail #20

Closed zoeitsolutions closed 7 years ago

zoeitsolutions commented 7 years ago

Hi, I updated my android sdk tools yesterday to the latest version etc.

This caused my android app to fail during the build process:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':transformResourcesWithMergeJavaResForF0F1F2F3F4F5Debug'.

    com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties File1: /Users/user/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.5.0/4b0bb6bfbecbdd42b97ff400af342bfe7f32bc83/okhttp-3.5.0.jar File2: /Library/WebServer/Documents/demos/background-geo-test/platforms/android/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/10.2.6/jars/classes.jar

I removed the nativescript-socket.io (through debugging etc) and the build passes.

I created a new app and added in your plugin and ran a build which passed. So I think it clashes with the firebase plugin, here is my package.json:

"dependencies": { "@angular/animations": "~4.0.0", "@angular/common": "~4.0.0", "@angular/compiler": "~4.0.0", "@angular/core": "~4.0.0", "@angular/forms": "~4.0.0", "@angular/http": "~4.0.0", "@angular/platform-browser": "~4.0.0", "@angular/platform-browser-dynamic": "~4.0.0", "@angular/router": "~4.0.0", "angular2-moment": "^1.2.0", "nativescript-angular": "~1.5.1", "nativescript-ngx-fonticon": "^2.0.0", "nativescript-photoviewer": "^1.2.0", "nativescript-plugin-firebase": "^3.9.3", "nativescript-socket.io": "^0.5.0", "nativescript-telerik-ui-pro": "nativescript-ui-pro.tgz", "nativescript-theme-core": "~1.0.2", "reflect-metadata": "~0.1.8", "rxjs": "~5.2.0", "tns-core-modules": "^2.5.2", "zone.js": "~0.8.2" }, "devDependencies": { "babel-traverse": "6.24.1", "babel-types": "6.24.1", "babylon": "6.17.1", "lazy": "1.0.11", "nativescript-dev-android-snapshot": "^0..", "nativescript-dev-sass": "^0.4.2", "nativescript-dev-typescript": "~0.3.5", "typescript": "~2.1.0" } my tns info:

┌──────────────────┬─────────────────┬────────────────┬──────────────────┐ │ Component │ Current version │ Latest version │ Information │ │ nativescript │ 2.5.5 │ 3.0.1 │ Update available │ │ tns-core-modules │ 2.5.2 │ 3.0.1 │ Update available │ │ tns-android │ 2.5.0 │ 3.0.0 │ Update available │ │ tns-ios │ │ 3.0.1 │ Not installed │

Do you have any thoughts?

zoeitsolutions commented 7 years ago

I was able to resolve it by adding the following to my gradle file:

packagingOptions { exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml' exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties' exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml' exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'

}

The build passes and I can run the app. I am going to test to see if the plugin still works as intended.

naderio commented 7 years ago

@zoeitsolutions you can can also change include.gradle of one of the conflicting plugins to exclude the unwanted package. for instance:

    compile ('io.socket:socket.io-client:0.8.+') {
       exclude group: 'org.json', module: 'json'
+      exclude group: 'com.squareup.okio', module: 'okio'
+      exclude group: 'com.squareup.okhttp3', module: 'okhttp'
    }

here org.json is a dependency of one of google packages (play services, I think), thus no need to re-include it.

Personally, I keep within version control all include.gradle and Podfile from dependencies (node_modules). This make fixing conflicts and tuning native dependencies versions easier.

zoeitsolutions commented 7 years ago

Thank you this works well.