use*_*357 36 android runtimeexception android-studio
我正在将我的项目从eclipse转移到Android Studio.在运行我的应用程序时,我收到以下错误.无法找到任何解决方案.我也启用了multidex.
错误:任务':app:transformClassesWithDexForDebug'的执行失败.com.android.build.api.transform.TransformException:java.lang.RuntimeException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:进程'命令'C:\ Program Files\Java\jdk1.7.0_79\bin\java.exe''以非零退出值1结束
我的gradle文件也在下面
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 9
targetSdkVersion 21
multiDexEnabled true
}buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-support-v7-cardview.jar')
compile files('libs/android-support-v7-recyclerview.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.api-client:google-api-client-appengine:1.18.0-rc'
compile 'com.google.http-client:google-http-client:1.18.0-rc'
compile 'com.google.http-client:google-http-client-android:1.18.0-rc'
compile 'com.google.http-client:google-http-client-appengine:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc'
compile 'com.google.oauth-client:google-oauth-client-appengine:1.18.0-rc'
compile files('libs/google-api-client-gson-1.18.0-rc.jar')
compile files('libs/google-api-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-api-client-java6-1.18.0-rc.jar')
compile files('libs/google-api-client-servlet-1.18.0-rc.jar')
compile files('libs/google-http-client-jackson2-1.18.0-rc.jar')
compile files('libs/google-http-client-jdo-1.18.0-rc.jar')
compile files('libs/google-oauth-client-java6-1.18.0-rc.jar')
compile files('libs/google-oauth-client-jetty-1.18.0-rc.jar')
compile files('libs/google-oauth-client-servlet-1.18.0-rc.jar')
compile files('libs/GraphView-4.0.1.jar')
compile files('libs/httpclient-4.0.1.jar')
compile files('libs/httpcore-4.0.1.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jetty-6.1.26.jar')
compile files('libs/jetty-util-6.1.26.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/jxl.jar')
compile files('libs/mail.jar')
compile files('libs/transaction-api-1.1.jar')
}
Run Code Online (Sandbox Code Playgroud)
Har*_*iya 70
错误:任务':app:transformClassesWithDexForDebug'的执行失败.com.android.build.api.transform.TransformException:java.lang.RuntimeException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:进程'命令'C:\ Program Files\Java\jdk1.7.0_79\bin\java.exe''以非零退出值1结束
由于很多原因发生上部错误.所以我可以说明为什么会出现这个错误以及如何解决它.
原因1:类文件名重复
解决方案
当你将一些类文件重构为库项目时.那个时候你写了类文件的名字所以,仔细检查你没有任何重复的名字
原因2:当你有很多缓存时
解决方案
有时如果你有很多缓存,那么这个错误就会发生,所以解决它.去File/Invalidate caches / Restart
然后选择Invalidate and Restart
它会清除您的缓存.
原因3:当有内部错误或使用beta版本切换回稳定版本时.
解决方案
解决方案很简单,只需转到Build菜单,然后单击Clean Project
并单击清除后Rebuild Project
.
原因4:当您记忆系统配置不足时.
解决方案
打开任务管理器并停止当时不常用的其他应用程序,这样就可以释放空间并解决问题OutOfMemory
.
原因5:问题是你的方法计数超过了65K.
解决方案
打开你的项目build.gradle
文件添加
defaultConfig {
...
multiDexEnabled true
}
Run Code Online (Sandbox Code Playgroud)
并在依赖项中添加以下行.
dependencies
{
compile 'com.android.support:multidex:1.0.0'
}
Run Code Online (Sandbox Code Playgroud)
检查在依赖项下的build.gradle(应用程序级别)中是否启用了multidex.如下所示
dependecies{
multidexEnabled true
}
Run Code Online (Sandbox Code Playgroud)
检查你的gradle.properties(应用程序级别).如果你看到下面的代码
#org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Run Code Online (Sandbox Code Playgroud)
在行之前删除#,那么它应该是这样的
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Run Code Online (Sandbox Code Playgroud)
请将其添加到您的 gradle 文件中
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
Run Code Online (Sandbox Code Playgroud)
并且还在你的 gradle 中添加以下依赖项
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
Run Code Online (Sandbox Code Playgroud)
或者另一种选择是:在清单文件中的应用程序标记中添加来自 multidex 支持库的 MultiDexApplication 包。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
这可能是由于以下原因:
项目内的 jar 文件之一使用旧版本的 google play 服务。
用于multiDexEnabled true
defaultconfig
具体说明您在依赖项中添加的类。喜欢
编译 'com.google.android.gms:play-services-maps:8.4.0'
不像编译那样'com.google.android.gms:play-services:+'
归档时间: |
|
查看次数: |
97378 次 |
最近记录: |