React Native App是具有超过65536种方法的多个dex

时间:2018-11-13 10:07:33

标签: android firebase react-native android-multidex react-native-firebase

我正在对Android上的本机应用程序进行编程。当我在android上运行时,它显示错误:超过65536个方法的多个dex。 这是android / app / build.gradle:

dependencies {
compile project(':react-native-device-info')
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile project(':react-native-fbsdk')
compile(project(':react-native-firebase')) {
    exclude group: "com.google.firebase"
}
compile project(':bugsnag-react-native')
compile(project(':react-native-push-notification')) {
}
compile project(':react-native-vector-icons')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.facebook.react:react-native:+'
// From node_modules
compile('com.google.firebase:firebase-core:10.2.6') {
    force = true;
}
compile('com.google.firebase:firebase-config:10.2.6') {
    force = true;
}
compile('com.google.firebase:firebase-auth:10.2.6') {
    force = true;
}
compile('com.google.firebase:firebase-database:10.2.6') {
    force = true;
}
compile('com.google.firebase:firebase-storage:10.2.6') {
    force = true;
}
compile('com.google.firebase:firebase-messaging:10.2.6') {
    force = true;
}
compile('com.google.firebase:firebase-crash:10.2.6') {
    force = true;
}
compile('com.google.android.gms:play-services-gcm:10.2.6') {
    force = true;
}
compile project(':react-native-onesignal')
compile project(':react-native-fast-image')
compile project(':react-native-camera')
compile project(':RNWebView')
compile project(':zpdk-production')

}

android / build.gradle

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.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
}

}

文件package.json

"dependencies": {
"async": "^2.5.0",
"bugsnag-react-native": "^2.2.0",
"he": "^1.1.1",
"moment": "^2.18.1",
"oauth-1.0a": "^2.1.0",
"prop-types": "^15.5.10",
"react": "16.0.0-alpha.12",
"react-native": "0.48.3",
"react-native-camera": "^0.13.0",
"react-native-datepicker": "^1.4.7",
"react-native-device-info": "^0.11.0",
"react-native-drawer": "^2.3.0",
"react-native-fast-image": "^1.0.0",
"react-native-fbsdk": "^0.6.1",
"react-native-firebase": "1.1.2",
"react-native-image-progress": "^1.0.1",
"react-native-keyboard-aware-scroll-view": "^0.2.7",
"react-native-modal-dropdown": "^0.4.2",
"react-native-navbar": "^1.5.0",
"react-native-onesignal": "^3.0.6",
"react-native-progress": "^3.4.0",
"react-native-push-notification": "^2.2.1",
"react-native-root-toast": "^1.0.3",
"react-native-router-flux": "^3.37.0",
"react-native-scrollable-tab-view": "^0.8.0",
"react-native-swiper": "^1.5.12",
"react-native-vector-icons": "^4.0.0",
"react-native-webview-android": "^1.1.17",
"react-navigation": "^1.0.0-beta.11",
"react-redux": "^5.0.3",
"redux": "^3.7.2",
"redux-logger": "^2.6.1",
"redux-persist": "^4.9.1",
"redux-thunk": "^2.1.0"

},

在react-native-firebase中,我仅使用解析来记录使用我的应用程序的用户的事件。 我不知道应该删除哪些依赖项。请帮我解决我的问题。

我尝试启用多个dex。但是当我运行应用程序->使用Facebook登录->应用程序崩溃时。

我的配置multidex。我认为我缺少一些配置。

android / app / build.gradle

 defaultConfig {
    applicationId "com.vannguyen.demotest"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 15
    versionName "1.1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }

    multiDexEnabled true
}

在MainApplication.java中:

public class MainApplication extends MultiDexApplication implements ReactApplication {

非常感谢您。

1 个答案:

答案 0 :(得分:0)

您应该在项目中启用multidex库:打开{project root}/android/app/build.gradle,然后添加以下几行:

android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
    }
}

并且(如果您的sdk低于21)

dependencies {
  ...
  compile 'com.android.support:multidex:1.0.0'
  ...
}

希望有帮助。您可以罚款here