今天当我更新我的安卓stdio时,我看到了以下错误,我无法理解这些错误的原因,但它给出了很多
truble .
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:Program FilesJavajdk1.8.0_45binjava.exe'' finished with non-zero exit value 2
而这些也是在以前的错误下,
Error:Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
AGPBI: {"kind":"simple","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","sources":[{}]}
AGPBI: {"kind":"simple","text":"com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.merge.DexMerger.merge(DexMerger.java:188)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.dexer.Main.run(Main.java:277)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.dexer.Main.main(Main.java:245)","sources":[{}]}
AGPBI: {"kind":"simple","text":"tat com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:Program FilesJavajdk1.8.0_45binjava.exe'' 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.
这些是我的 gradle 文件,
// Top-level build file where you can add configuration options common to all sub-projects/modules.
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是第二个build.gradle文件,
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.shubham.MeraIndore"
minSdkVersion 12
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.androidanimations:library:1.0.3@aar'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile project(':library')
}
请帮助我.
dependencies {
...
// add this since you are using minSdkVersion less than 21
compile 'com.android.support:multidex:1.0.1'
}
并在默认配置中将 multiDexEnabled 设置为 true,如下所示
defaultConfig {
applicationId "com.shubham.MeraIndore"
minSdkVersion 12
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
You also need to reference the MultiDexApplication class in your manifest by adding android:name="android.support.multidex.MultiDexApplication" to application tag.
注意:如果您的应用程序扩展了 Application 类,则可以覆盖 attachBaseContext(( 方法并调用 MultiDex.install(this( 来启用 multidex,如下所示。
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
总是发生,因为您仅为发布版本启用了 multiDex,而不是为调试版本启用了 multiDex。
试试这个:
defaultConfig {
multiDexEnabled true
}
添加到您的应用 gradle 依赖项中
compile 'com.android.support:multidex:1.0.1'
在默认配置中添加此内容
multiDexEnabled true
将此添加到您的应用格拉德尔
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
同步应用
最后将以下内容添加到清单文件中的应用程序
android:name="android.support.multidex.MultiDexApplication"
造成这种情况的原因之一是当您达到 65K 方法限制时。您可以通过删除未使用的代码/库来解决此问题。为此,您需要查看您的依赖项。列出可以执行的依赖项
gradlew -q dependencies app:dependencies --configuration compile
命令。
或者,如果没有要删除的代码/库,则可以使用multidex支持
。dependencies {
...
// add this since you are using minSdkVersion less than 21
compile 'com.android.support:multidex:1.0.1'
}
并在这样的defaultConfig
中将multiDexEnabled
设置为 true
defaultConfig {
applicationId "com.shubham.MeraIndore"
minSdkVersion 12
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
还需要通过在向应用程序标记添加android:name="android.support.multidex.MultiDexApplication"
来引用清单中的 MultiDexApplication
类。
注意:如果您的应用扩展了 Application
类,则可以重写 attachBaseContext()
方法并调用 MultiDex.install(this)
来启用 multidex,如下所示。
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
有关更多详细信息,请参阅此SO答案和此。
您似乎使用了不同版本的 Android 支持库(23.0.1 和 23.1.1(。也许您应该尝试使用相同的版本。
此外,如前所述,列出您的依赖项以检查它们是否使用与支持库相同的版本:
./gradlew app:dependencies --configuration compile