rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.68k stars 1.18k forks source link

import not work #214

Closed shahinesi closed 7 years ago

shahinesi commented 7 years ago

Hi I am using the following method:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
    dependencies {
            compile 'com.github.rubenlagus.TelegramBots:Bots:2.4.4.5'
    }

But I encountered a problem and does not support the following import!

import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;

So https://github.com/rubenlagus/TelegramBots/releases/tag/2.4.4.5 Erorr 1.7 java

shahinesi commented 7 years ago

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies] Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android. Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.3 is ignored for debug as it may be conflicting with the internal version provided by Android. Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android. Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.3 is ignored for debug as it may be conflicting with the internal version provided by Android. Warning:WARNING: Dependency org.json:json:20160810 is ignored for release as it may be conflicting with the internal version provided by Android. 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. Warning:WARNING: Dependency org.json:json:20160810 is ignored for release as it may be conflicting with the internal version provided by Android. 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. Information:BUILD SUCCESSFUL Information:Total time: 1 mins 29.957 secs Information:0 errors Information:8 warnings Information:See complete output in console

shahinesi commented 7 years ago

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES File1: C:\Users\Shahin.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpmime\4.5.3\889fd6d061bb63b99dd5c6aba35a555ae863de52\httpmime-4.5.3.jar File2: C:\Users\Shahin.gradle\caches\modules-2\files-2.1\com.google.inject\guice\4.1.0\eeb69005da379a10071aa4948c48d89250febb07\guice-4.1.0.jar

rubenlagus commented 7 years ago

@shahinesi I doubt you can use this library in an Android project since this library uses Java8. Specially if you plan to target old android versions.

shahinesi commented 7 years ago

i used JDK.8.0.121.x64 sun.java.8.0.121.x64 Android Studio 2.3 (android-studio-bundle-162.3764568)

shahinesi commented 7 years ago

is work compile 'com.github.rubenlagus.TelegramBots:telegrambots:2.4.4.5'

rubenlagus commented 7 years ago

So, it does work in Android? Which android sdk is your app targeting?

shahinesi commented 7 years ago
C:\Windows\system32>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.shahi.myapplication"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    compile 'com.android.support:design:25.2.0'
    testCompile 'junit:junit:4.12'
    //compile 'com.github.rubenlagus.TelegramBots:Bots:2.4.4.5'
    compile 'com.github.rubenlagus.TelegramBots:telegrambots:2.4.4.5'

}
shahinesi commented 7 years ago

image

rubenlagus commented 7 years ago

That's what I meant. You can't use this library in Android I guess since it will need java 8.

Closing this since it is not a bug.

shahinesi commented 7 years ago

@rubenlagus I'm gonna 8! How can I fix this?

rubenlagus commented 7 years ago

https://developer.android.com/guide/platform/j8-jack.html#supported-features

Android doesn't support full java8, so I don't think there is any solution.

shahinesi commented 7 years ago

Tnx I will check

This was why the library with the following code? compile 'com.github.rubenlagus.TelegramBots:telegrambots:2.4.4.5' But the Code is not it? compile 'com.github.rubenlagus.TelegramBots:Bots:2.4.4.5'

shahinesi commented 7 years ago

image