在Android Studio里面,您在运行的时候,有可能会报这样的错误的时候,如下图
我试图编译Android Stuido 1.3.2修改实例的SDK(超超。com)。原始示例编译工具是2.2.1和它对我来说很不错,与目前的NDK。然而,我希望调试器为本地代码的工作,根据http://tools.android.com/tech-docs/new-build-system/gradle-experimental我需要的工具2.5。
奇怪的是我得到的错误”com.android.dx.cf.iface.parseexception:坏的类文件的魔法(cafebabe)或版本(34)“当编译工具2.5,它工作正常的版本。根据其他类似的问题,这一切发生的时候,由于一些链接错误,java,如果超过一个java版本是可用的(V 1.8。相反,然而,V1.7。)我只有java 8这是老版本的工作工具。
谁能帮我解决这个问题?
我的摇篮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 { 库{ jcenter() } { 依赖 classpath的COM。Android工具建立:摇篮:1.3.0的 / /注:不要把你的应用程序依赖这里;他们属于 / /在单个模块build.gradle文件 } } { {一个项目 库 jcenter() } } 这样的问题的解决在于,有可能是因为你
所以,应该这样子改,就可以 添加
compileoptions
设置在模块的我build.gradle解决问题:模型{ Android { compilesdkversion = 23 buildtoolsversion =“23.0.1” / /… } compileoptions.with { sourcecompatibility = javaversion.version_1_7 targetcompatibility = javaversion.version_1_7 }