React-native:BeoNews app run-android执行失败的任务':app:transformClassesWithJarMergingForDebug'

时间:2017-06-14 17:08:06

标签: javascript android react-native

我按照以下步骤操作: https://beonews.inspireui.com/beonews-setup.html

试图跑步的时候 react-native run-android

获取错误:

:app:transformClassesWithJarMergingForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: 
java.util.zip.ZipException: duplicate entry: 
com/google/android/gms/internal/zzatb.class

root build.gradle:

// Top-level build file where you can add configuration options common to 
all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
project(':react-native-fbsdk') {
  configurations.all {
    resolutionStrategy {
      force 'com.facebook.android:facebook-android-sdk:4.22.1'
    }
  }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        configurations.all {
            resolutionStrategy {
              force 'com.facebook.android:facebook-android-sdk:4.22.1'
            }
        }
    }
}

app build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

apply from: "../../node_modules/react-native/react.gradle"


def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.beonews"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 10
    versionName "2.4"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
    manifestPlaceholders = [onesignal_app_id: "85cbc2b5-4e0d-4214-9653-8054d06f4256",
                            onesignal_google_project_number: "REMOTE"]


    // Enabling multidex support.
    multiDexEnabled true
}
signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}
}

dependencies {
compile project(':react-native-google-analytics-bridge')
compile project(':react-native-admob')
compile project(':react-native-onesignal')
compile project(':react-native-google-signin')
compile project(':react-native-fbsdk')
compile project(':react-native-blur')
compile project(':react-native-linear-gradient')
compile project(':react-native-vector-icons')

compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"  // From node_modules
//compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.facebook.android:facebook-android-sdk:[4.22.1)'


//compile 'com.android.support:multidex:1.0.1'
compile(project(":react-native-google-signin")){
    exclude group: "com.google.android.gms" // very important
}
compile "com.google.android.gms:play-services-auth:10.2.6"  // should be at least 9.0.0

compile "com.google.android.gms:play-services-base:10.2.6"
compile "com.google.android.gms:play-services-location:10.2.6"
compile "com.google.android.gms:play-services-ads:10.2.6"
}
apply plugin: 'com.google.gms.google-services'


// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

Windows 10。 尝试:

  • 使用Android Studio和简单的cmd命令和PhpStorm。
  • 更改google pkgs版本
  • 运行gradlew clean(顺便说一下,构建成功,但仍然无法使用run-android
  • 删除google pkgs并将编译firebase添加为单独的

我该如何解决?

1 个答案:

答案 0 :(得分:0)

尝试将此行更新至版本11.0.0

compile "com.google.android.gms:play-services-auth:10.2.6"  // should be at least 9.0.0

compile "com.google.android.gms:play-services-base:10.2.6"
compile "com.google.android.gms:play-services-location:10.2.6"
compile "com.google.android.gms:play-services-ads:10.2.6"