React Native编译版本apk错误程序类型已存在:com.facebook.react.modules.intent.IntentModule

时间:2018-10-30 15:58:15

标签: android reactjs react-native android-gradle

我正在尝试运行我的react native apk的发行版,但是我遇到了这个错误,我已经删除了整个构建文件夹,但失败了。我正在使用默认的react-native-firebase模板。它曾经在某个时候合规。请帮忙。

这是我遇到的错误。

Program type already present: com.facebook.react.modules.intent.IntentModule
    Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
            at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:132)
            at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:117)
            at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101)
            at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:36)
            at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
            ... 4 more
    Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
            at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:65)
            at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:43)
            at com.android.tools.r8.D8.run(D8.java:90)
            at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:115)
            ... 7 more
    Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.facebook.react.modules.intent.IntentModule
            at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:116)
            at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:74)
            at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:59)

我的build.gradle(根)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
  ext {
    buildToolsVersion = "28.0.2"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 26
    supportLibVersion = "28.0.2"
  }
  repositories {
    google()
    jcenter()
    maven {
      url 'https://maven.fabric.io/public'
    }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0'
    classpath 'com.google.gms:google-services:4.0.1'
    classpath 'com.google.firebase:firebase-plugins:1.1.5'
    classpath 'io.fabric.tools:gradle:1.25.4'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

allprojects {
  repositories {
    google()
    mavenLocal()
    jcenter()
    maven {
      // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
      url "$rootDir/../node_modules/react-native/android"
    }
    maven { url "https://jitpack.io" }
    maven { url "https://maven.google.com" }

  }
}

subprojects {
  project.configurations.all {
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "28.0.2"
        }
     }
  }
}

task wrapper(type: Wrapper) {
  gradleVersion = '4.6'
  distributionUrl = distributionUrl.replace("bin", "all")
}

我的build.gradle(应用程序)

apply plugin: "com.android.application"
apply plugin: "com.google.firebase.firebase-perf"
apply plugin: 'io.fabric'

import com.android.build.OutputFile

project.ext.react = [
  entryFile: "index.js"
]

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

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

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

android {
  lintOptions {
    disable 'GradleCompatible'
    disable 'InvalidPackage'
  }

  // because of firestore:
  dexOptions {
    javaMaxHeapSize "4g"
  }
  compileSdkVersion rootProject.ext.compileSdkVersion
  buildToolsVersion rootProject.ext.buildToolsVersion

  defaultConfig {
    applicationId "com.isiroo.isiroo"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    ndk {
      abiFilters "armeabi-v7a", "x86"
    }
    // because of firestore:
    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
    }
    debug {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
  // 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-splash-screen')
    compile project(':lottie-react-native')
  implementation(project(':react-native-camera')) {
    exclude group: "com.google.android.gms"
    implementation 'com.android.support:exifinterface:25.+'
    implementation ('com.google.android.gms:play-services-vision:12.0.1') {
        force = true
    }
}
  implementation(project(':react-native-svg'))
  implementation(project(':react-native-firebase')) {
    transitive = false
  }

  implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
    transitive = true
  }

  // RNFirebase required dependencies
  implementation "com.google.firebase:firebase-core:16.0.4"
  implementation "com.google.android.gms:play-services-base:16.0.1"

  // RNFirebase optional dependencies
  implementation "com.google.firebase:firebase-ads:15.0.1"
  implementation "com.google.firebase:firebase-analytics:16.0.4"
  implementation "com.google.firebase:firebase-auth:16.0.4"
  implementation "com.google.firebase:firebase-config:16.0.1"
  implementation "com.google.firebase:firebase-database:16.0.3"
  implementation "com.google.firebase:firebase-firestore:17.1.1"
  implementation "com.google.firebase:firebase-functions:16.1.1"
  implementation "com.google.firebase:firebase-invites:16.0.4"
  implementation "com.google.firebase:firebase-storage:16.0.3"
  implementation "com.google.firebase:firebase-messaging:17.3.3"
  implementation "com.google.firebase:firebase-perf:16.1.2"

  //noinspection GradleDynamicVersion
  implementation "com.facebook.react:react-native:+"
  implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
  implementation "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"

  implementation fileTree(dir: "libs", include: ["*.jar"])
}

// 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'
}

apply plugin: 'com.google.gms.google-services'

0 个答案:

没有答案