android adding a java library causes errors in runtime?

时间:2017-06-12 17:08:16

标签: android android-studio telegram-bot

i'm tring to add this library to an android app in android studio. when i add it by jar it will not give me errors, and it will try to build but never finishes. when i try to adding it by the gradle compile "org.telegram:telegrambots:3.0.1" it will build but gives me some runtime err:

AGPBI: {"kind":"error","text":"Lambda coming from jar file need their 
interfaces on the classpath to be compiled, unknown interfaces are 
java.util.function.Predicate","sources":
[{"file":"C:\\Users\\soshiant\\AndroidStudioProjects\\Glassbutton3\\ 
DefaultBotSession.java","position":{"startLine":215,"endLine":216}}]} AGPBI:     
{"kind":"error","text":"Lambda coming from jar file need their interfaces on 
the classpath to be compiled, unknown interfaces are 
java.util.function.Function","sources":
[{"file":"C:\\Users\\soshiant\\AndroidStudioProjects\\Glassbutton3\\ 
DefaultBotSession.java","position":{"startLine":216,"endLine":217}}]} AGPBI: 
{"kind":"error","text":"Lambda coming from jar file need their interfaces on 
the classpath to be compiled, unknown interfaces are 
java.util.Comparator","sources":
[{"file":"C:\\Users\\soshiant\\AndroidStudioProjects\\Glassbutton3\\ 
DefaultBotSession.java","position":{"startLine":217,"endLine":218}}]}

i dont know if its relevant but building it gives warnings like this :

WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.3 is 
ignored for release as it may be conflicting with the internal version 
provided by Android. In case of problem, please repackage it with jarjar to 
change the class packages WARNING: WARNING: Dependency org.json:json:20160810 
is ignored for release as it may be conflicting with the internal version 
provided by Android. In case of problem, please repackage it with jarjar to 
change the class packages

the project is an empty activity and doesn't have any code in it just the lib is added. I have previously worked with this library in a Java program and it works flawlessly. i dont know what i'm doing wrong in adding this library.i've tried it with multiple combination of sdkbuild versions and targetsdk's to no avail.

i've tried different versions of this library too it gives me similar errors.

1 个答案:

答案 0 :(得分:0)

TelegramBots需要java 8。

Android支持java 8但不完全支持。您可以在此处查看支持的内容以及如何启用java8支持:https://developer.android.com/studio/preview/features/java8-support.html

即使Android支持TelegramBots目前存在的所有功能,你也不知道将来是否会添加任何不支持的功能,所以我不会在android项目中使用这个库。