1
votes

I want to use Kotlogram library in my android project.

Im using java 7 (jdk1.7.0_79). but when I want to debug or run the project, this error is happened:

UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.RuntimeException: Exception parsing classes at com.android.dx.command.dexer.Main.processClass(Main.java:752) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718) at com.android.dx.command.dexer.Main.access$1200(Main.java:85) at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:672) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311) at com.android.dx.command.dexer.Main.run(Main.java:277) at com.android.dx.command.dexer.Main.main(Main.java:245) at com.android.dx.command.Main.main(Main.java:106) Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472) at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406) at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388) at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251) at com.android.dx.command.dexer.Main.parseClass(Main.java:764) at com.android.dx.command.dexer.Main.access$1500(Main.java:85) at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684) at com.android.dx.command.dexer.Main.processClass(Main.java:749) ... 12 more 1 error; aborting FAILED

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

app build.gradel content:

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "api.telegram.learn.kotlogram"
    minSdkVersion 12
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),   
       'proguard-rules.pro'
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {

}
}


dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.github.badoualy:kotlogram:0.0.6'
}

project build.gradel content

// Top-level build file where you can add configuration options common to all sub-projects/modules.

apply plugin: 'java'

sourceCompatibility = 1.7
targetCompatibility = 1.7

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
1
add this in your gradle and clean and rebuild your project.. above the dependence sectioin. <br> repositories { maven { url "jitpack.io" } }Muhammad Waleed
Possible duplicate of Bad class file magic or versionAiuspaktyn
I show my app build.gradel content in this post. i forget to show the project build.gradel too. ofcourse I have added this repository. I have added this repository in the project build.gradel. I dont have compile error. this error happen when i want to debug or run the projectMotahare Sehati
i saw this link "Bad class file magic or version ". but it does not help meMotahare Sehati
can anyone help me? I must solve this errorMotahare Sehati

1 Answers

-1
votes

finally i download the repository and add its module manually to the android project and find the problem.

only java 8 can compile and run these moudels correctly. they use some special method that are defined in java 8 but not in java 7. java 7 can not compile them.

by looking at this refrence, android project need java 7 for compiling and running.

it seem that using Kotlogram in android project is impossible.