我知道这个问题问了很多,但是找不到解决我问题的解决方案... 我收到此错误:
'yes' | 'no' | 'unknown'
在Mac上运行终端,使用react native时...
这是我的构建gradle文件: /app/build.gradle:
app:transformClassesWithMultidexlistForDebug FAILED
com.android.build.api.transform.TransformException: Error while generating the main dex list.
这是我的android / build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 28
buildToolsVersion "28.0.1"
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.X"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
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"
}
}
// 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 {
implementation project(':react-native-picker')
implementation project(':react-native-device-info-2')
implementation project(':react-native-device-info')
implementation project(':react-native-device-information')
implementation project(':react-native-fcm')
implementation project(':react-native-firebase')
implementation project(':react-native-svg')
implementation project(':react-native-vector-icons')
implementation project(':react-native-spinkit')
implementation project(':react-native-push-notification')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-config')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.google.android.gms:play-services-gcm:15.0.1"
implementation "com.android.support:appcompat-v7:28.0.0-rc02"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:design:27.1.0'
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
我一直在尝试许多见过的解决方案,但是它们都不起作用,我一直在使用buildTool和sdk的版本,但还没有解决方案。
我整天都在努力寻找解决方案... 非常感谢您的帮助!
添加stackTrace:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
//com.android.ddmlib.DdmPreferences.setTimeOut(50000)
allprojects {
repositories {
// Add jitpack repository (added by react-native-spinkit)
maven { url "https://jitpack.io" }
mavenLocal()
google()
jcenter()
maven{
url 'https://maven.google.com'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
//maybe this is unnecessary
}
}
ext {
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "28.0.2"
supportLibVersion = "28.0.0-rc02"
googlePlayServicesVersion = "15.0.1"
oreoEXPERIMENTAL = "yes"
}
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
}
}
}
}
答案 0 :(得分:2)
...的堆栈跟踪提示
CompilationError:程序类型已存在:com.learnium.RNDeviceInfo.BuildConfig
这意味着该类被两次引用-或由重复的依赖关系引起。我会怀疑task copyDownloadableDepsToLibs
和/或libs
目录的内容-因为依赖项本身根本没有提到该类。