我正在做一个示例项目,我同时使用 google play 服务和 FireBase 来实现位置和 FCM。
我正在使用 android studio 2.1.1 和 gradle:2.1.0
所以我得到的原始问题是:
java.lang.NoClassDefFoundError:解析失败:Lcom/android/tools/fd/runtime/AppInfo;
在 com.android.tools.fd.runtime.BootstrapApplication.(BootstrapApplication.java:126)
为此,我找到了禁用即时运行的解决方案,所以我做到了。现在我得到了DexOverflowException
,所以我从依赖项中排除了几个模块,一切都很好。但是现在我的 Application 类中的代码将不起作用。应用程序类onCreate()
方法不会被调用。
如果有人想知道我是否在清单中放置了应用程序类引用,我做到了。
<application
android:name=".HHApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
这是我的项目 build.gradle
:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
这是应用程序 build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "xxxxxxxxxxx"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile ('com.google.android.gms:play-services-location:9.0.2') {
exclude module: 'support-v4'
exclude module: 'support-annotations'
exclude module: 'firebase-common'
}
compile ('com.google.firebase:firebase-messaging:9.0.0') {
exclude module: 'play-services-base'
exclude module: 'play-services-basement'
exclude module: 'play-services-task'
exclude module: 'support-v4'
exclude module: 'support-annotations'
}
compile files('libs/android-query.0.26.7.jar')
}
apply plugin: 'com.google.gms.google-services'