Closed The28AWG closed 6 years ago
first change build.gradle in you app
android { compileSdkVersion 26 buildToolsVersion "26.0.1" // i used latest build tool version defaultConfig { applicationId "my.app.id" minSdkVersion 24 // my android device api level targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" jackOptions { enabled true // enable jack!!!!!!!!!!!! its option enabled Java 8 language support } multiDexEnabled true // enable multidex. its really need. } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { javaMaxHeapSize "4g" // use max heap size. jack very sloow work } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 // java 8 =) targetCompatibility JavaVersion.VERSION_1_8 } packagingOptions { // exclude all duplicate files exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } }
Create 2 java library module in you project "telegrambots" and "telegrambots-meta". NOT android library! telegrambots-meta/build.gradle:
apply plugin: 'java' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile group: 'com.google.inject', name: 'guice', version: '4.1.0', classifier: 'no_aop' compile (group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.7', { exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations' }) compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.0' compile group: 'org.json', name: 'json', version: '20160810' } sourceCompatibility = "1.8" targetCompatibility = "1.8"
telegrambots/build.gradle:
apply plugin: 'java' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':telegrambots-meta') compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version:'2.8.0' compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version:'2.8.7' compile(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.8.7') { exclude(module: 'jackson-annotations') } compile(group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version:'2.25.1') { exclude(module: 'jackson-annotations') exclude(module: 'jackson-jaxrs-json-provider') exclude(module: 'jackson-jaxrs-base') } compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-grizzly2-http', version:'2.25.1' compile group: 'org.glassfish.jersey.core', name: 'jersey-server', version:'2.25.1' compile group: 'org.json', name: 'json', version:'20160810' compile group: 'commons-io', name: 'commons-io', version:'2.5' testCompile group: 'org.glassfish.jersey.test-framework', name: 'jersey-test-framework-core', version:'2.25.1' testCompile group: 'org.glassfish.jersey.test-framework.providers', name: 'jersey-test-framework-provider-grizzly2', version:'2.25.1' testCompile group: 'org.mockito', name: 'mockito-all', version:'2.0.2-beta' compile "cz.msebera.android:httpclient:4.4.1.2" } sourceCompatibility = "1.8" targetCompatibility = "1.8"
copy source from repository. replace all org.apache.http to cz.msebera.android.httpclient
org.apache.http
cz.msebera.android.httpclient
again open build.gradle you app and add
compile project(':telegrambots')
you dependencies. Open AndroidManifest.xml and add
<uses-permission android:name="android.permission.INTERNET"/>
Run bot in background thread! Done
boredom? interest? experiment? Because I can!
@memerioo @no-nevis Anyone can decide to run the code wherever they want, that's not of concern here. If he is able to adapt the code, it is a great usage.
first change build.gradle in you app
Create 2 java library module in you project "telegrambots" and "telegrambots-meta". NOT android library! telegrambots-meta/build.gradle:
telegrambots/build.gradle:
copy source from repository. replace all
org.apache.http
tocz.msebera.android.httpclient
again open build.gradle you app and add
you dependencies. Open AndroidManifest.xml and add
Run bot in background thread! Done