2016-10-27 106 views
0

我根據admob網站下載了所有需要的文件。 我一路上遇到了一些問題,但我找到了處理每個問題的方法。 但我無法通過這一個,我不知道爲什麼? 當我試圖編譯我的應用程序,它失敗,並在「消息」區域admob廣告錯誤,android-studio編譯器

Error:The number of method references in a .dex file cannot exceed 64K. 
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html 

我沒有任何想法如何讓過去這一點,如果有人可以幫助請不要表現出下面的代碼!

對不起,如果這個問題是嚴重問或什麼!

+0

http://stackoverflow.com/a/36786721/5212133檢查這個答案 –

+2

的可能的複製[在.DEX文件的方法的引用數不能超過64K API 17(HTTP://計算器。 com/questions/36785014/the-number-of-method-references-in-a-dex-file-can-exceed-64k-api-17) –

+0

因此,你有乾淨的錯誤,也是一個解決方案的鏈接。 ..也有很多關於64k方法限制的問題已經回答了...... – Beloo

回答

1

Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536—including Android framework methods, library methods, and methods in your own code. In the context of computer science, the term Kilo, K, denotes 1024 (or 2^10). Because 65,536 is equal to 64 X 1024, this limit is referred to as the '64K reference limit'.

Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration

更改您的搖籃構建配置,使multidex

android { 
    compileSdkVersion 21 
    buildToolsVersion "21.1.0" 

    defaultConfig { 
     ... 
     minSdkVersion 14 
     targetSdkVersion 21 
     ... 

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

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

在您的清單從multidex支持庫添加MultiDexApplication類應用元素。

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.android.multidex.myapplication"> 
    <application 
     ... 
     android:name="android.support.multidex.MultiDexApplication"> 
     ... 
    </application> 
</manifest> 
+0

謝謝,我添加了上面給出的代碼,但現在給了我很多錯誤,並以此結束:**錯誤:任務':app:transformClassesWithDexForDebug'的執行失敗。 > com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:org.gradle。 process.internal.ExecException:處理'命令'C:\ Program Files \ Java \ jdk1.8.0_91 \ bin \ java.exe''以非零退出值3結束** –

+0

謝謝,無論如何,我會去做整個admob的東西從一開始,看看我能不能把它這次:) –

+0

你在你的漸變添加'multiDexEnabled true'? –