错误:多个包含包名称的库' com.facebook.react'

时间:2017-02-13 12:34:57

标签: android react-native-android exponentjs

当我分离项目时,我有一个由https://getexponent.com/自动生成的本机项目。现在我在使用react-native-lock和react native链接添加了这些构建错误。它作为一个使用xcode的iOS项目工作正常,但android studio给了我这个错误:

Error:Execution failed for task ':app:processDebugResources'.
> Error: more than one library with package name 'com.facebook.react'

build.grade文件

apply plugin: 'com.android.application'

android {
  compileSdkVersion 24
  buildToolsVersion '24.0.3'

  packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
  }

  defaultConfig {
    applicationId "com.foo.app"
    minSdkVersion 19
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    ndk {
      abiFilters 'armeabi-v7a', 'x86'
    }
    manifestPlaceholders = [
      'appAuthRedirectScheme': 'com.foo.app'
    ]
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
  dexOptions {
    javaMaxHeapSize "8g"
  }
}

task exponentPrebuildStep(type: Exec) {
  workingDir '../../'

  if (System.getProperty('os.name').toLowerCase().contains('windows')) {
    commandLine 'cmd', '/c', '.\\.exponent-source\\android\\detach-scripts\\prepare-detached-build.bat'
  } else {
    commandLine './.exponent-source/android/detach-scripts/prepare-detached-build.sh'
  }
}
preBuild.dependsOn exponentPrebuildStep

repositories{
  flatDir{
    dirs 'libs'
  }
  mavenLocal()
  maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile project(':react-native-lock')
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:24.1.1'
  compile 'com.android.support:multidex:1.0.0'


  compile('host.exp.exponent:exponentview:13.0.0@aar') {
    exclude module: 'bolts-android'
    transitive = true;
  }


}

和react-native-lock

repositories {
    jcenter()
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion '24.0.3'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "0.4.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

ext.libraries = [
    testing: [
            dependencies.create('junit:junit:4.11') {
                exclude module: 'hamcrest-core'
            },
            'org.robolectric:robolectric:3.0-rc3',
            'com.google.guava:guava:18.0',
            'org.hamcrest:hamcrest-integration:1.3',
            'org.hamcrest:hamcrest-core:1.3',
            'org.hamcrest:hamcrest-library:1.3',
            'org.mockito:mockito-core:1.10.19',
            dependencies.create('com.squareup:fest-android:1.0.+') {
                exclude group: 'com.android.support', module: 'support-v4'
            },
            'org.powermock:powermock-api-mockito:1.6.3',
            'org.powermock:powermock-module-junit4-rule:1.6.3',
            'org.powermock:powermock-classloading-xstream:1.6.3'
        ]
]

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:support-v4:23.+'
    compile 'com.facebook.react:react-native:+'
    compile 'com.auth0.android:lock:1.17.+'
    compile 'com.auth0.android:lock-passwordless:1.17.+'
    testCompile libraries.testing
}

1 个答案:

答案 0 :(得分:3)

更改build.gradle
compile project(':react-native-lock') 

compile(project(':react-native-lock')) { exclude module: 'react-native' } 

正如此处记录的那样:https://docs.getexponent.com/versions/v14.0.0/guides/exponentkit.html#make-native-changes