Gradle 无法使用库进行编译
Gradle can't compile with libs
我的项目无法使用这些库进行编译:
我的gradle代码:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com...."
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
错误:
**错误:任务“:app:preDexDebug”执行失败。
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1**
您的图书馆似乎有问题。尝试更新它并使用
compile 'com.android.support:appcompat-v7:22.0.0'
Android SDK Build Tools 21.1 及更高版本中可用的 Gradle 插件 Android 支持 multidex,因此您必须将 multiDexEnabled true
添加到 gradle 像这样的文件:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
..
当 app/libs 文件夹中的库文件尚未包含在 gradle 构建中时,Android Studio 似乎会出现此错误。 user1468102 的回答对我有用。我清空了我的 libs 文件夹,一切顺利
也请 link 将库添加到项目并使用 gradle
我的项目无法使用这些库进行编译:
我的gradle代码:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com...."
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
错误:
**错误:任务“:app:preDexDebug”执行失败。
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1**
您的图书馆似乎有问题。尝试更新它并使用
compile 'com.android.support:appcompat-v7:22.0.0'
Android SDK Build Tools 21.1 及更高版本中可用的 Gradle 插件 Android 支持 multidex,因此您必须将 multiDexEnabled true
添加到 gradle 像这样的文件:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
..
当 app/libs 文件夹中的库文件尚未包含在 gradle 构建中时,Android Studio 似乎会出现此错误。 user1468102 的回答对我有用。我清空了我的 libs 文件夹,一切顺利
也请 link 将库添加到项目并使用 gradle