2016-10-27 53 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'? –