我在編程時遇到了問題,但我遇到了一個問題,但我找不到答案。gradle 2.5 com.android.dx.cf.iface.ParseException:錯誤的類文件魔術(cafebabe)或版本(0034.0000)
我想在Android Stuido 1.3.2中編譯Superpowered SDK(superpowered.com)的一個修改示例。 最初的例子是用gradle 2.2.1編譯的,對於我來說,使用當前的NDK版本可以很好地工作。不過,我希望調試器爲本機代碼工作,並根據http://tools.android.com/tech-docs/new-build-system/gradle-experimental我需要gradle 2.5。
奇怪的是我得到的錯誤「com.android.dx.cf.iface.ParseException:糟糕的類文件魔術(cafebabe)或版本(0034.0000)」與gradle這個2.5編譯時,而它正常工作與舊版。根據其他類似的問題,由於JAVA中存在一些鏈接錯誤,如果有多個Java版本可用(v 1.8而不是v1.7),那麼我只會使用Java 8,並且這對於較舊的Gradle版。
任何人都可以幫助我解決這個問題嗎?
我gradle這個2.2.1的build.gradle代碼:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.superpowered.frequencydomain"
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = []
}
}
task ndkBuild(type: Exec) {
commandLine '/android/ndk/ndk-build', '-B', '-C', file('src/main/jni').absolutePath
// Windows users:
// commandLine 'C:\\Android\\ndk\\ndk-build.cmd', '-B', '-C', file('src/main/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
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:22.2.0'
}
我的搖籃2.5。代碼:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "com.superpowered.frequencydomain"
minSdkVersion.apiLevel = 10
targetSdkVersion.apiLevel = 23
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
proguardFiles += file('proguard-android.txt')
}
}
}
task ndkBuild(type: Exec) {
commandLine 'C:\\Users\\Dave\\AppData\\Local\\Android\\Sdk\\ndk-bundle\\ndk-build.cmd', '-B', '-C', file('src/main/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
}
其他的build.gradle文件說,對2.2.1:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
爲2.5。它的內容如下:
classpath 'com.android.tools.build:gradle-experimental:0.2.0'
在第6行。除此之外它是相同的。
在此先感謝您的幫助!