Mav*_*.pe 134 android gradle asp.net-web-api build.gradle
我在执行我的Android应用程序时遇到此错误(我清理它然后构建它,但错误仍然存在)
错误:任务执行失败':app:dexDebug'.com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\ Program Files\Java\jdk1.7.0 _25\bin\java.exe''以非零退出值2结束
我的gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.rzr.rzevallosr.miappdepruebas"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// This library handles authentication and authorization
compile 'com.spotify.sdk:spotify-auth:1.0.0-beta9@aar'
// This library handles music playback
compile 'com.spotify.sdk:spotify-player:1.0.0-beta9@aar'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile files('libs/spotify-web-api-android-master-0.1.0.jar')
compile files('libs/okio-1.3.0.jar')
}
Run Code Online (Sandbox Code Playgroud)
编辑:我没有看到"编译fileTree(dir:'libs',包括:['*.jar'])"它正在编译两次我的库,所以我只是评论:
//compile 'com.squareup.retrofit:retrofit:1.9.0'
//compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
//compile 'com.squareup.okhttp:okhttp:2.2.0'
//compile files('libs/spotify-web-api-android-master-0.1.0.jar')
//compile files('libs/okio-1.3.0.jar')
Run Code Online (Sandbox Code Playgroud)
它工作正常.
min*_*zur 205
这个问题很可能是因为超过了Android强加的65K方法dex限制.这个问题可以通过清理项目,从build.gradle中的依赖项中删除一些未使用的库和方法来解决,或者通过添加multidex支持来解决.
因此,如果必须保留库和方法,则可以通过在gradle配置中声明它来启用多dex支持.
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
Run Code Online (Sandbox Code Playgroud)
您可以在此处阅读有关multidex支持和使用65K以上方法开发应用程序的更多信息.
Ami*_*kur 93
对我来说问题是,我在build.gradle中放了一个不必要的complie库代码
dependencies {
compile 'com.google.android.gms:play-services:7.5.0'
}
Run Code Online (Sandbox Code Playgroud)
导致超过65k的方法,所以删除它,gradle同步,清理项目,然后再次运行,然后停止此错误.我只需要地图和gcm,所以我把这些线和同步项目
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
Run Code Online (Sandbox Code Playgroud)
嗨,大家好我再次遇到这个问题,这次是因为改变了构建工具版本,它真的需要我启用multidex ..所以我添加了这些我的应用程序的build.gradle文件..
defaultConfig {
applicationId "com.am.android"
minSdkVersion 13
targetSdkVersion 23
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.1'
}
Run Code Online (Sandbox Code Playgroud)
并创建一个扩展Application类的类,并在类中包含此方法.
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Run Code Online (Sandbox Code Playgroud)
也包括在OnCreate方法中
@Override
public void onCreate() {
MultiDex.install(this);
super.onCreate();
}
Run Code Online (Sandbox Code Playgroud)
Vil*_*len 32
以防万一有人仍在努力解决这个问题并且不知道为什么会发生这种情况以及如何解决问题.实际上这个错误
错误:任务':app:dexDebug'的执行失败.> com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\ Program Files\Java\jdkx.x.x_xx\bin\java.exe''已完成非零退出值2
可以有很多理由发生,但肯定不会与你的JDK版本有关,所以不要把你的时间浪费在错误的方向上.这是造成这种情况的两个主要原因
第一种情况可以修复如下:找出您多次包含的依赖项.为了做到这一点,在android studio终端中运行以下命令
gradlew -q dependencies yourProjectName_usually_app:dependencies --configuration compile
Run Code Online (Sandbox Code Playgroud)
这将返回所有依赖项,但是您从lib文件夹中包含的jar文件试图摆脱标有星号(*)的重复,这并不总是可行,但在某些情况下您仍然可以这样做,在此尝试排除模块之后包含很多次,你可以这样做
compile ('com.facebook.android:facebook-android-sdk:4.0.1'){
exclude module: 'support-v4'
}
Run Code Online (Sandbox Code Playgroud)
对于第二种情况,当你超出方法限制建议是试图通过删除包含的库(注意听起来像第一个解决方案)来最小化它,如果无法做到这一点,将multiDexEnabled true添加到你的defaultConfig
defaultConfig {
...
...
multiDexEnabled true
}
Run Code Online (Sandbox Code Playgroud)
这增加了方法的限制,但它是不是因为可能的性能问题,最好的事情
重要仅添加multiDexEnabled true到defaultConfig是远远不够的,其实在所有设备上运行Android <5棒棒堂会导致意外的行为和NoClassDefFoundError.这里描述如何解决它
Mav*_*.pe 17
我不知道(那时)"编译fileTree(dir:'libs',包括:['*.jar'])"编译所有在libs文件夹上有jar扩展名的东西,所以我只是评论(或删除)这个线路:
//compile 'com.squareup.retrofit:retrofit:1.9.0'
//compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
//compile 'com.squareup.okhttp:okhttp:2.2.0'
//compile files('libs/spotify-web-api-android-master-0.1.0.jar')
//compile files('libs/okio-1.3.0.jar')
Run Code Online (Sandbox Code Playgroud)
它工作正常.不管怎么说,还是要谢谢你!我的错.
我有同样的问题,我修复了删除不必要的库
compile fileTree(dir: 'libs', include: ['*.jar'])
Run Code Online (Sandbox Code Playgroud)
我删除了该库,我可以毫无问题地运行该项目.
通过启用multiDex进行调试构建,我得到了解决.
defaultConfig {
multiDexEnabled true
}
Run Code Online (Sandbox Code Playgroud)
我拒绝嵌入式JDK(32位),因为嵌入式JDK是64位
右键单击您的项目 - > 打开模块设置 - > SDK位置 - >取消选中使用嵌入式JDk然后设置您的JDK路径,例如在Ubuntu / usr/lib/jvm/java-8-openjdk-i386中
| 归档时间: |
|
| 查看次数: |
131747 次 |
| 最近记录: |