收到此错误KitKat和较低版本完美运行在 Lollipop 及以上版本
我已将所有必需的 jar 包含在 cradle 和 Firebase json 文件中以接收 GCM。
我的应用程序梯度
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId ""
minSdkVersion 13
targetSdkVersion 23
versionCode 6
versionName "1.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
multiDexEnabled true
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':httpmime-4.2.5')
compile project(':universal-image-loader-1.9.3')
compile project(':universal-image-loader-1.9.3')
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.3'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:9.0.0'
testCompile 'junit:junit:4.12'
}
此依赖项包括以下代码allGoogle Play 服务 API:
compile 'com.google.android.gms:play-services:9.0.0'
这很可能会导致您的应用程序超出 65K 方法引用限制,从而要求您使用 Multidex 在 Lollipop 之前的设备上运行。
你有两个选择。您可以仅包含您实际需要的 Play 服务 API。这清单在这里 https://developers.google.com/android/guides/setup在标题为有选择地将 API 编译到可执行文件中。或者您可以按照以下方式启用 Multidex此处说明 https://developer.android.com/studio/build/multidex.html#mdex-gradle。虽然你有multiDexEnabled true
在您的 build.gradle 文件中,这只是配置 Multidex 所需的三个步骤之一。您还需要将该库包含为依赖项并更新您的清单。
如果您使用的是 Android Studio 2.2.2,您可以使用以下命令查看应用程序中有多少方法引用:APK分析器 https://developer.android.com/studio/build/apk-analyzer.html。从菜单栏中选择构建 > 分析 APK。 APK 位于文件夹中.../app/build/outputs/apk
。选择 APK 文件,然后在出现的窗口中单击classes.dex
查看方法和方法引用的数量。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)