I have a problem with android studio.
I have added the .jar file of okhttp from this link : https://github.com/square/okhttp to my libs directory on my android studio. and when I try to add this line : compile 'com.squareup.okhttp3:okhttp:3.2.0' in the dependencies in build.gradle(Module:app), after trying to syncing it I get error 28, 13. Actually after researching I found out that I can't compile anything in dependencies and sync it remember that I have checked my "android SDK build tool" is installed.
hear is the whole of my code in build.gradle(app) directory:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.kasra.stormy"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'], )
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile files('libs/okhttp-3.2.0.jar')
compile 'com.squareup.okhttp3:okhttp:3.2.0'
}
I'll be very glad and thankful if someone help me fix this problem.
Thank you very much:)
Either your internet is bad and you can't download that file from JCenter, or you are just missing a repositories
section in your gradle file.
apply plugin: 'com.android.application'
repositories {
jcenter()
}
Also, if you are going to be compiling using gradle instead of a JAR file, then delete the file libs/okhttp-3.2.0.jar
and remove the line that says compile files('libs/okhttp-3.2.0.jar')
.
It is also worth mentioning that you don't need any lines that start with compile files('libs/
because compile fileTree(dir: 'libs', include: ['*.jar'], )
already includes all JAR files within the libs/
folder.
It may help someone. In my case after update com.squareup.okhttp3
to the latest version, I got this error in Android Java libaray. Then I update the Java version to 1.8 which solved my problem.
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With