gpt4 book ai didi

java - admob 广告、android-studio 编译器出错

转载 作者:行者123 更新时间:2023-12-01 09:19:08 30 4
gpt4 key购买 nike

我根据admob网站下载了所有需要的文件。一路上我遇到了一些问题,但我找到了解决每个问题的方法。但我无法克服这一点,我不知道为什么?当我尝试编译我的应用程序时,它失败并在“消息”区域中显示以下代码

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

我不知道如何克服这个问题,如果有人可以帮忙,请帮忙!

抱歉,如果这个问题问得不好或者什么!

最佳答案

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

更改 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'
}

在您的 list 中添加 MultiDexApplication类从 multidex 支持库到应用程序元素。

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

关于java - admob 广告、android-studio 编译器出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40285047/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com