- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
所以我想知道为什么我尝试在比 Lollipop 更早的 android 版本上运行我的应用程序时遇到 64k dex 方法限制,而它在较新的版本上运行得很好。
可能是因为在旧版本上运行时实际上引用了支持库?
这是我的毕业典礼:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
lintOptions {
checkReleaseBuilds true
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
defaultConfig {
applicationId "com.domain.myapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 27
versionName "1.2"
// Vector compat
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile files('libs/commons-io-2.4.jar')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/mail.jar')
compile project(':libraries:preferencefragment')
// Gmail API
compile('com.google.api-client:google-api-client-android:1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-gmail:v1-rev29-1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
// Play Services
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
// Support libraries
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.anjlab.android.iab.v3:library:1.0.20'
compile 'com.sothree.slidinguppanel:library:2.0.3'
compile 'com.commit451:PhotoView:1.2.5'
compile('com.github.afollestad.material-dialogs:core:0.8.5.7@aar') {
transitive = true
}
}
编辑:
澄清一下:当我尝试在运行的模拟器上运行应用程序时会发生这种情况。奇巧 API 19
来自 gradle 控制台的崩溃日志:
...
:App:generateDebugInstantRunAppInfo
:App:transformClassesWithDexForDebug
AGPBI: {"kind":"error","text":"The number of method references in a .dex file cannot exceed 64K.\nLearn how to resolve this issue at https://developer.android.com/tools/building/multidex.html","sources":[{}],"original":"UNEXPECTED TOP-LEVEL EXCEPTION:\ncom.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536\n\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484)\n\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261)\n\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473)\n\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161)\n\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:188)\n\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)\n\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)\n\tat com.android.dx.command.dexer.Main.run(Main.java:277)\n\tat com.android.dx.command.dexer.Main.main(Main.java:245)\n\tat com.android.dx.command.Main.main(Main.java:106)\n","tool":"Dex"}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':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: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
来自消息窗口的崩溃消息:
:App:transformClassesWithDexForDebug
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
Error:Execution failed for task ':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: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
最佳答案
回答您的具体问题是:
这就是它在旧设备上失败但在新设备上工作的原因。它与支持库无关。
为我的回答添加更多有用的内容:
但也许有些人可能想知道如何在旧设备上解决它,请注意我在上面的要点中使用了 native
这个词。这意味着,有一些变通方法可以让旧平台支持它,但您必须将这些变通方法编码到您的应用中。
此 Google 指南中详细说明了解决方法(甚至问题本身):http://developer.android.com/tools/building/multidex.html
它的基础是:
compile 'com.android.support:multidex:+'
multiDexEnabled true
MultidexApplication
android:name="android.support.multidex.MultiDexApplication"
或者,如果您需要子类 Application
为您自己的应用程序,让您的应用程序从它扩展。关于android - 比 Lollipop 更旧的 API 超过了 64k 限制,但不是更新的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36559835/
我使用工具栏是为了在我的应用程序中进行 Material 设计。一切正常,但除了更改菜单项文本颜色时,我完全无法接受该解决方案。我还张贴了我在申请中使用的文本和代码的屏幕截图,供您引用。我尝试了几种替
看起来 FloatingActionButton 在 Android 4.0 和 Lollipop 上无法正常工作。正如您在下图中看到的那样,在 Android Lollipo 上,阴影缺失,而在 A
SDK 升级到 Android 5 后,我无法使用 Intel 硬件加速执行管理器: $ android-sdk-macosx/tools/emulator -avd AVD_for_LowMemor
SDK升级到Android 5后,无法使用Intel Hardware Accelerated Execution Manager: $ android-sdk-macosx/tools/emulat
我有不同 draw9patch png 作为背景的按钮。目前按钮由 selector 控制,看起来像这样: 对于 Android Lollipop,他们有一个用于触摸效果的
我尝试在 Pre-Lollipop 设备上运行我的应用程序。但是这段代码向我显示了 Pre-Lolliop 和 Lollipop 设备的相同错误。 如果我将“android:”添加到样式中(如样式 2
我实现了一个自定义的 SurfaceView 来绘制相机预览,并在其上完成了所有捕获和手动对焦操作。它在 Pre-Lolipop 设备上运行良好,但问题是它在 Lollipop 设备上崩溃。 发生的最
风格 @color/my_primary_color @color/my_primary_dark_color @color/accent 布局
我想在 Lollipop 设备中显示较旧的时间选择器(如 Lollipop 设备之前的时间选择器)。可以 这是可能的。 最佳答案 您可以通过将 timePickerMode 属性设置为“spinner
嗨,所以我有点困惑,想知道是否有人能指出我正确的方向。 在 Lollipop 和 pre-lollipop 上使用 Google Play 商店 您会在 Lollipop 上看到可选择的 View 具
如果我们希望使用 Material Design 的应用同时支持 Lollipop 和 Lollipop 之前的设备,以下哪种方法是正确的? 单独使用 Android 支持库:仅对整个应用程序使用支持
我正在使用 appcompat/support-v7 中引入的新工具栏小部件。我想根据用户是否向上/向下滚动页面来隐藏/显示工具栏,就像在新的 Google Playstore 应用程序或 NewsS
我的数据库中有一个 .mhtml 文件作为字节数组。我写了下面的代码,它在 Lollipop 之前的设备上运行良好。但它不适用于 Lollipop 和棉花糖。 代码:- String p
根据标题,我能够在下面的 Lollipop 中成功读取/写入数据,但在 Lollipop 中多次读取/写入失败。 这就是我读/写数据的方式: boolean isRead= getmBluetooth
我刚刚在 Android Studio 上安装了 Android 5,并在模拟器上进行了第一次运行。我发现“API Demos”应用程序非常有趣,我想找到代码。我说的是这个应用程序: 有人知道我在哪里
我正在关注 this tutorial在 Android Material Design 中使用颜色(我的 ActionBar 和 StatusBar)。我确实按照教程进行操作,但没有反射(refle
在我的应用程序中,用户可以通过它调用任何号码,我正在启动蓝牙 audioManager.setBluetoothScoOn(true); audioManager.startBluetoothSco(
我正在我的 android 应用程序中实现 Google map API v2。该应用程序在所有设备上都可以正常工作,但在 Lollipop 设备上却不行。应用程序在 Lollipop 中崩溃。我确实
我正在开发一个项目,其中有一个日期选择器。我正在尝试为其设置最大日期和最短日期。最短日期是今天之后 1 天,最大日期是今天之后 11 天。但问题是在 Lollipop 设备中,最后一个最大日期显示为可
我正在使用嵌入式无线系统,它以定义的时间间隔生成数据包。目的是检测设备/系统何时重新启动。为此,我读到 Lollipop 序列编号是最适合此目的的编号方案。 “在此编号方案中,序列号从负值开始,增加直
我是一名优秀的程序员,十分优秀!