2017-04-24 38 views
-1

當我編譯代碼時,我得到 錯誤:任務':app:transformClassesWithDexForDebug'的執行失敗。Android manifest.xml意圖過濾器錯誤

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536.

這是我的代碼:

<?xml version="1.0" encoding="utf-8"?> 

<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 




<application 
    android:allowBackup="true" 
    android:icon="@drawable/police" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 

    <meta-data android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version"/> 
    <activity 
     android:name="com.google.android.gms.ads.AdActivity" 
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> 


    <activity 
     android:name=".MainActivity"> 

     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

+0

http://stackoverflow.com/questions/15209831/unable-to-execute-dex-method-id-not-in-0-0xffff-65536 – CommonsWare

+1

可能重複的[錯誤:執行失敗的任務':應用程序:transformClassesWithDexForDebug'](http://stackoverflow.com/questions/33717886/errorexecution-failed-for-task-apptransformclasseswithdexfordebug) – sziraqui

+0

Probabaly內存問題。增加Android Manifest android:name =「android.support.multidex.MultiDexApplication」中的內存或增加build.gradle中的堆大小javaMaxHeapSize「4g」 – sivaprakash

回答

-1

添加這些播放服務趨於介紹DEX錯誤。首先嚐試通過你的IDE清洗你的應用程序,

如果不工作添加此建立.gradle

defaultConfig { 
    multiDexEnabled true 
} 
+0

請詳細解釋如何解決開發人員遇到的'DexIndexOverflowException'錯誤越來越。另外,一個''不需要*'元素,儘管它可以有一個元素。 – CommonsWare

+0

我的錯誤,刪除該位 –

0

嘗試加入這個在你搖籃

android { 

    defaultConfig { 
     ... 

     // Enabling multidex support. 
     multiDexEnabled true 
    } 
    ... 
} 

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

不幸的兄弟:( –

0

您沒有使用整個Google Play Services API,所以不要編譯build.gradle文件中的整個軟件包,而是嘗試編譯您項目所需的單個服務。 從版本6.5開始,您可以選擇性地將Google Play服務API編譯到您的應用中。 例如,只包括谷歌飛度和Android Wear的API,替換您的build.gradle文件中的以下行:

compile 'com.google.android.gms:play-services:9.0.0' 

這些行:

compile 'com.google.android.gms:play-services-fitness:9.0.0' 
compile 'com.google.android.gms:play-services-wearable:9.0.0' 

您需要檢查哪些服務你將要求並相應地編譯它們。