2

So I have built an Android app where am using Signal R.

I have imported both signalr-client-sdk-android and signalr-client-sdk found at Github repo

The gradle for each file builds successfully but when I am trying to compile the code in whole i get the message below :

Error converting bytecode to dex

After a small research I did I found out that apparently the libs i downloaded from the repo are compiled by using jdk 1.7 while my Android studio setup is using 1.8.

Any ideas how can I resolve this?

Below you can find my Gradle files :

My apps Gradle :

buildscript {
    repositories {
        maven {
            url 'https://maven.fabric.io/public'
        }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'

    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

repositories {
    maven {
        url 'https://maven.fabric.io/public'
    }
    maven {
        url 'https://clojars.org/repo'
    }
}

android {
    compileSdkVersion 25
    buildToolsVersion "23.0.2"

    sourceSets.main {
        jni.srcDirs = []
        jniLibs.srcDir 'src/main/libs'
    }

    defaultConfig {
        applicationId "com.pushdr.application"
        minSdkVersion 17
        targetSdkVersion 17

        ndk {
            moduleName "ndkVidyoSample"
        }
    }

    repositories {
        jcenter()
        maven {
            url "https://jitpack.io"
        }
        mavenCentral()
        maven {
            url 'https://github.com/FireZenk/maven-repo/raw/master/'
        }

    }

    allprojects {
        repositories {
            mavenCentral()
        }
    }

    buildTypes {
        release {
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    productFlavors {
        armv7a {
            ndk {
                abiFilter "armeabi-v7a"

            }
        }
        fat ///This build contain multi architecture binary
    }
}

dependencies {

    //facebook SDK

    //Used for Signal R + Chat

    //Used for PIN entry
    compile project(':pinentry')
        //Menu Drawer
    compile project(':materialTabs')
        //Credit Card Payment Libraries
    compile project(':creditcarddesign')
        //Audio waves
    compile project(':audiowaves')

    compile project(':signalr-client-sdk')
    compile project(':signalr-client-sdk-android')

    compile('com.crashlytics.sdk.android:crashlytics:2.6.4@aar') {
        transitive = true;
    }
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.google.firebase:firebase-core:9.2.0'
    compile 'com.roger.gifloadinglibrary:gifloadinglibrary:1.0.0'
    compile 'com.wdullaer:materialdatetimepicker:2.5.0'
    compile 'com.synnapps:carouselview:0.0.9'
    compile 'com.ragnarok.rxcamera:lib:0.0.4'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
    compile 'com.stripe:stripe-android:2.0.2'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.github.2359media:EasyAndroidAnimations:0.8'
    compile 'com.mikepenz:crossfader:1.3.7@aar'
    compile 'com.mikepenz:crossfadedrawerlayout:0.3.4@aar'
    compile 'com.mikepenz:itemanimators:0.2.4@aar'
    compile 'com.mikepenz:google-material-typeface:2.2.0.1@aar'
    compile 'com.mikepenz:fontawesome-typeface:4.4.0.1@aar'
    compile 'com.mikepenz:octicons-typeface:3.0.0.1@aar'
    compile 'com.github.amlcurran.showcaseview:library:5.4.3'
    compile 'com.jzxiang.pickerview:TimePickerDialog:1.0.1'
    compile 'com.google.code.gson:gson:2.8.0'

}

signalr - client - sdk - android: gradle

apply plugin: 'com.android.library'

repositories {
    maven {
        url 'https://clojars.org/repo'
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {}
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile project(':signalr-client-sdk')
}

signalr - client - sdk: gradle

apply plugin: 'java'

repositories {
    maven {
        url 'https://clojars.org/repo'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.code.gson:gson:2.3'
    compile 'org.java-websocket:java-websocket:1.3.1'
}
Quintin Balsdon
  • 5,484
  • 10
  • 54
  • 95
AndroidKrayze
  • 349
  • 2
  • 5
  • 21

1 Answers1

0

You can use Java8. When you run javac, you must give it the arguments '-target 1.7 -source 1.7' so that it produces code that is compatible with Java7. You do this indirectly for your own source code by correctly configuring your gradle build scripts.

However, I don't think that is your problem. The android gradle tools will automatically run javac correctly on your source code. I expect the problem is with third-party libraries that you are including in your project.

You need to make sure that every library you use is compiled for Java7. Somewhere on your classpath you have a .class file that was compiled with '-target 1.8'.

dsh
  • 12,037
  • 3
  • 33
  • 51
  • I have added : targetCompability = '1.7' & sourceCompability = '1.7' to my gradle file but i get the same error. Can you be more specific of the location? – AndroidKrayze Jan 23 '17 at 09:21
  • Since I don't have your entire project, I don't know which class files (and in which jars) you have that were compiled for Java8. You'll need to look through all of your class files to find them. This answer can help you with that: http://stackoverflow.com/a/1096159/1172714 – dsh Jan 23 '17 at 22:09