kar*_*arl 42 android android-studio android-gradle-plugin
我正在将现有应用程序从Eclipse转换为Android Studio.但是,当我在运行4.x的设备上运行它时(我在模拟器上测试了几个版本),它会立即崩溃NoClassDefFoundError
.
我已经尝试评论了对它找不到的类的引用,但总会有另一个.据我所知,犯罪类总是如此
在5.0.1模拟器上一切正常(我没有要测试的设备).我的build.gradle
文件相当长,但看起来像这样:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = "2.7.1"
android {
compileSdkVersion 19
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.myapp.android"
minSdkVersion 8
targetSdkVersion 19
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
*snip*
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
repositories {
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName 'com.pact.android'
}
}
dependencies {
*snip compile project(':...') declarations
apt "com.googlecode.androidannotations:androidannotations:$AAVersion"
compile "com.googlecode.androidannotations:androidannotations-api:$AAVersion"
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:3.1.36'
*snip many more compile declarations*
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)
导致麻烦的类的一些示例:
Parcelable.CREATOR
在我的模型中实现出了什么问题,我该如何解决?
kar*_*arl 118
我没有完全实现MultiDex支持,所以我的一些类不在正确的dex文件中.要修复它,你必须做的不仅仅是multiDexEnabled = true
在defaultConfig
块中设置.你还必须:
compile 'com.android.support:multidex:1.0.1'
在您的依赖项中MultiDexApplication
而不仅仅是Application
.或者,你可以调用MultiDex.install()
在attachBaseContext()
您的应用程序.有关详细信息,请参阅https://developer.android.com/tools/building/multidex.html.
小智 10
1)添加multiDexEnabled = true
默认配置
2)com.android.support:multidex:1.0.0
在依赖项中添加编译
3)Application
类扩展MultiDexApplication
而不仅仅是Application
归档时间: |
|
查看次数: |
22082 次 |
最近记录: |