简体   繁体   English

admob广告出现错误,android-studio编译器

[英]Error with admob ads, android-studio compiler

I downloaded all the files that were needed according to the admob website. 我根据admob网站下载了所需的所有文件。 I had some issues along the way, but i found ways to deal with each of them. 在此过程中,我遇到了一些问题,但是我找到了解决每个问题的方法。 But i cannot get past this one and i do not know why? 但是我无法超越这一步,我也不知道为什么? when I tried to compile my app, it failed and showed the following code in the "message" area 当我尝试编译我的应用程序时,它失败并在“消息”区域显示以下代码

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

I do not have ANY idea how to get past this, if ANYONE can help please do! 我不知道该如何解决这个问题,如果有人可以帮助您,请做!

sorry if this question is badly asked or something! 抱歉,如果有人提出这个问题,或者其他问题!

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. Android应用程序(APK)文件包含Dalvik可执行文件(DEX)文件形式的可执行字节码文件,其中包含用于运行您的应用程序的已编译代码。 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. Dalvik Executable规范将单个DEX文件中可引用的方法总数限制为65,536,其中包括Android框架方法,库方法和您自己代码中的方法。 In the context of computer science, the term Kilo, K, denotes 1024 (or 2^10). 在计算机科学的上下文中,术语Kilo K表示1024(或2 ^ 10)。 Because 65,536 is equal to 64 X 1024, this limit is referred to as the '64K reference limit'. 由于65,536等于64 X 1024,因此该限制称为“ 64K参考限制”。

Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration 超过此限制要求您将应用程序构建过程配置为生成多个DEX文件,称为multidex配置。

Change your Gradle build configuration to enable multidex 更改您的Gradle构建配置以启用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'
}

In your manifest add the MultiDexApplication class from the multidex support library to the application element. 在清单中,将来自Multidex支持库的MultiDexApplication类添加到application元素。

    <?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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM