gpt4 book ai didi

java - 在android项目中使用Kotlogram库

转载 作者:行者123 更新时间:2023-12-01 06:09:44 25 4
gpt4 key购买 nike

我想使用Kotlogram library在我的 Android 项目中。

我正在使用 java 7 (jdk1.7.0_79)。但是当我想调试或运行项目时,发生了这个错误:

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

失败:构建因异常而失败。

出了什么问题: 任务“:app:transformClassesWithDexForDebug”执行失败。 com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe''以非完成零退出值1

应用程序build.gradel内容:

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'
}

项目build.gradel内容

// 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
}

最佳答案

最后我下载了存储库并将其模块手动添加到android项目中并找到了问题。

只有 java 8 才能正确编译和运行这些模型。它们使用了一些在java 8中定义但在java 7中没有定义的特殊方法。java 7无法编译它们。

通过查看此refrence ,android项目需要java 7来编译和运行。

看来在android项目中使用Kotlogram是不可能的。

关于java - 在android项目中使用Kotlogram库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37047202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com