2017-09-06 44 views
1

我的Android /應用/的build.gradle(底部):火力地堡Onesignal多DEX文件定義LCOM /谷歌/安卓/ GMS /認證/ API /登入/ ZZC

dependencies { 
    compile project(':react-native-onesignal') 
    compile project(':react-native-youtube') 
    compile(project(":react-native-google-sign-in")) { 
     exclude group: "com.google.android.gms" 
    } 
    compile project(':react-native-svg') 
    compile project(':react-native-facebook-login') 
    compile project(':react-native-i18n') 
    compile fileTree(dir: "libs", include: ["*.jar"]) 
    compile "com.android.support:appcompat-v7:23.0.1" 
    compile "com.google.android.gms:play-services-auth:10.0.1" 
    compile "com.facebook.react:react-native:+" // From node_modules 
} 

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

我的Android /的build.gradle:

buildscript { 
    repositories { 
     jcenter() 
    } 
    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 
    } 
} 

錯誤:

Execution failed for task ':app:transformClassesWithDexForDebug'. 
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/zzc; 

我已經嘗試了各種解決方案,並沒有什麼作品:/ 似乎是某種版本misma的tch,但我不知道如何匹配它。

回答

0

只是使multidex如下:

android {  
    defaultConfig { 
    // Enabling multidex support. 
    multiDexEnabled true 
    } 
} 
    dependencies { 
    compile 'com.android.support:multidex:1.0.0' 
} 

創建一類像這樣

public class Multi_Dex extends Application { 
    @Override 
    protected void attachBaseContext(Context base) { 
    super.attachBaseContext(base); 
    MultiDex.install(this); 
    } 
} 

現在在manifiest文件中添加此

<application 
    android:name=".Multi_Dex" 
    android:allowBackup="true" 
    android:icon="@drawable/logo" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
+0

我創建了一個文件Multi_Dex.java,但現在我得到一個錯誤「Multi_Dex.java:6:error:can not find symbol」for「Context」和「MultiDex」 –

0

解決的問題是以下幾點:

我的build.gradle有這樣一行:

com.google.android.gms:play-services-auth:10.0.1 

所以我不得不改變/node_modules/react-native-onesignal/android/build.gradle像這個:

compile 'com.google.android.gms:play-services-gcm:10.0.1' 
compile 'com.google.android.gms:play-services-analytics:10.0.1' 
compile 'com.google.android.gms:play-services-location:10.0.1' 

這是我嘗試了所有其他在線搜索解決方案後唯一的工作。

相關問題