2017-06-14 100 views
0

林: https://beonews.inspireui.com/beonews-setup.html陣營母語:以下步驟

,並試圖運行 react-native run-android

獲取錯誤時:

BeoNews應用程序運行的Android執行失敗的任務 ':transformClassesWithJarMergingForDebug:應用程序'
: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' 
      } 
     } 
    } 
} 

應用的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。
  • 改變谷歌PKGS版本
  • 運行gradlew clean(順便說一句說,建立成功的,但仍然沒有後與run-android工作)
  • 移除谷歌PKGS並添加編譯火力作爲單獨的一個

我怎樣才能修理它?

回答

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" 
+0

感謝您的答覆。試過 - 保留了其他重複的新錯誤。不知何故,似乎這個問題來自操作系統(Windows),並且一切正常Mac –

+0

嗯抱歉,因爲我使用Mac。 – felangga