I'm Getting this Error when I try to integrate Crashlytics with my Project.
I used the Crashlytics plugin to generate the code . But when I do a sync in Gradle it gives e the following error. I have also attavhed the build.gradle
Error:Unable to find method 'org.apache.http.conn.ssl.SSLConnectionSocketFactory.(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V'.
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I have tried Invalidating the cache and also Redownload dependencies and also stoping the Gradle build and starting it.
I'm also connected to the Internet.
The Build works fine if I remove the crashlytics dependency.
Can anyone tell e how to fix this.
build.gradle
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:support-v13:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:palette-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile files('libs/volley.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
}
Solved the Issue. This happened because I was using an older Version of java which has an Incompatable httpcomponents jar, after switching to the latest version the issue was resolved.
Related
Yesterday I tried building my app and everything worked fine.
Today, without any changes to the project... All of a sudden I'm greeted with this warning message telling me:
Error:Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:11.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-basement/11.0.1/play-services-basement-11.0.1.aar
Is anyone experiencing the same sort of issue?
If you follow the link where it's searching for the package it basically gets downloaded instantly through the browser. I suppose something has changed on the server side? Perhaps naming conventions?
It looks like it's looking for: play-services-basement.aar and fetches play-services-basement-11.0.1.aar instead?
Could this be a naming convention or gradle issue?
jcenter() has had mirrors of some libraries (I guess they are doing intentionally) that should originally available through google() or maven() repositories. When gradle build works, for any library that is used in the project the first place to look for is the repository that is listed first in repositories {.. When the jcenter() mirror does not have the release (e.g com.google.android.gms:play-services-ads:15.0.1 for my case) your gradle is looking for, the build fails with such error.
So, jcenter() should be listed at the last place in repositories {.. parts as below.
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}...
and
allprojects {
repositories {
google()
jcenter()
}
}
This is crazy!!! I faced the same issue. The builds were working fine and then suddenly started to fail with the same issue. I tried the suggestions above but it didn't work for me. Finally, this is what worked for me:
Update to latest firebase dependencies:
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-ads:17.0.0'
also, the ads services:
implementation 'com.google.android.gms:play-services-ads:17.0.0'
Note: with play-services-ads:17.0.0, it mandatory to add the following in the Manifest file, otherwise application crashes on opening.
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="[ADMOB_APP_ID]"/>
</application>
UPDATE #2 2018/05/29
The issue looks to be fixed gone now, and I'm still using the same gradle configs. But I did these steps a while ago I'm not sure if these did anything or if this is a server-side issue and it got fixed/updated recently. I just noticed the issue was gone after I did the following steps:
Add the following in project-level gradle.build's buildscript > repositories and allprojects > repositories.
google()
maven { url 'http://jcenter.bintray.com' }
Change the google-services classpath to classpath com.google.gms:google-services:4.0.1'
Sync Project with Gradle Files
UPDATE #1 2018/05/29
I got around the error by downgrading my firebase dependencies to ~12.0.0 in the app-level gradle. But this will severly impact the app, still looking around for more feasible workarounds.
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
...
compile 'com.google.firebase:firebase-core:12.0.0'
compile 'com.google.firebase:firebase-database:12.0.0'
compile 'com.google.firebase:firebase-storage:12.0.0'
compile 'com.google.firebase:firebase-auth:12.0.0'
compile 'com.google.firebase:firebase-crash:12.0.0'
...
Same here, I have experienced the same issue described by #SimbaClaws. Everything was compiling smoothly until I faced the same issue yesterday.
I have the following codes in my project-level build.gradle,
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
//classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'io.fabric.tools:gradle:1.25.1'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And the following codes for the app-level build.gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "my.secret.application"
minSdkVersion 16 // 19
targetSdkVersion 26
versionCode 1
versionName "5.0.204"
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.google.firebase:firebase-core:15.0.2'
compile 'com.google.firebase:firebase-database:15.0.0'
compile 'com.google.firebase:firebase-storage:15.0.2'
compile 'com.google.firebase:firebase-auth:15.1.0'
compile 'com.google.firebase:firebase-crash:15.0.2'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.android.support:palette-v7:26.+'
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'org.greenrobot:eventbus:3.1.1'
testCompile 'junit:junit:4.12'
compile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
}
apply plugin: 'com.google.gms.google-services'
Can anyone advise if I missed anything? I'm also still looking around for possible workarounds and answers. TIA!
Had same issue, for me none of the answers mentioned here worked. So I just updated dependencies in the gradle file and whichever dependency had com.google.gms: (kept them at same version example 16.0.0)
I have also experienced this issue. The root cause, I found out was that there inconsistent build Gradle version.
In the Gradle Scripts repository "if I can call it that " there are two build gradle modules. The build.gradle (Project: name of app) and the build.gradle (Module: app). Make sure that classpath 'com.android.tools.build:gradle:3.2.1' in dependencies is using the latest and same version of the tool. Inconsistencies result in issues with the build.
In my case just added www earlier url was like url "https://jitpack.io/" after this added www started working for me. In other repositories also try to add explicit URLs.
maven {
url "https://www.jitpack.io/"
}
Deploying one of my example JavaFX applications to an Android device via the gluon-mobile Eclipse plugin fails with an IllegalArgumentException in the retrolambda plugin. This is caused by an indirect dependency of my project on jaxb-api-2.3.0.jar which is a multi-release jar. Retrolambda obviously cannot handle the Java 9 parts in this file and instead of just ignoring them throws an exception. How can this be fixed or avoided?
A newer version of retrolambda (2.5.3 instead of 2.5.1) can handle the module-info.class already but not the part in the META-INF/versions/9/...
The problem could be cured by just deleting the META-INF stuff but when I do that manually it is always re-created by the gluon plugin.
Update 1:
Adding
packagingOptions {
exclude '/META-INF/versions/9/javax/xml/bind/ModuleUtil.class'
}
to the android section in the build file does not make any difference. The error message is still the same:
java.lang.IllegalArgumentException
at net.orfjackal.retrolambda.asm.ClassReader.<init>(ClassReader.java:185)
at net.orfjackal.retrolambda.asm.ClassReader.<init>(ClassReader.java:168)
at net.orfjackal.retrolambda.ClassAnalyzer.analyze(ClassAnalyzer.java:25)
at net.orfjackal.retrolambda.Retrolambda$1.visitClass(Retrolambda.java:71)
at net.orfjackal.retrolambda.files.ClasspathVisitor.visitFile(ClasspathVisitor.java:29)
at net.orfjackal.retrolambda.files.ClasspathVisitor.visitFile(ClasspathVisitor.java:11)
at java.nio.file.Files.walkFileTree(Files.java:2670)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at net.orfjackal.retrolambda.Retrolambda.visitFiles(Retrolambda.java:107)
at net.orfjackal.retrolambda.Retrolambda.run(Retrolambda.java:68)
at net.orfjackal.retrolambda.Main.main(Main.java:28)
This can also be verified easily by just running the command line version of retrlambda over the extracted classes of jaxb-api-2.3.0.jar
Update 2:
With Java 9 and the Gluon-VM it fails with:
Execution failed for task ':SingleViewProject - Gluon VMApp:apkDebug'.
> Duplicate files at the same path inside the APK: META-INF/LICENSE.txt
File 1: /Users/mpaus/.m2/repository/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar
File 2: /Users/mpaus/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
jaxb-api-2.3.0.jar is a multi-release jar and the current jfxmobile plugin 1.3.10 can't deal with it.
The plugin, that targets Java 7/8, uses retrolambda to port back to Java 6/7 a given dependency.
Even if you try to remove the module-info.class or the 9 versionMETA-INF.versions.9.javax.xml.bind`, these classes are processed by the retrolambda plugin, and this will lead to the exception posted in the question. Using the latest retrolambda version doesn't help either.
android {
retrolambdaVersion = "2.5.3"
manifest = 'src/android/AndroidManifest.xml'
packagingOptions {
exclude '/module-info.class'
exclude '/META-INF.versions.9.javax.xml.bind/ModuleUtil.class'
}
}
The only way to make it work under Java 8/jfxmobile 1.3.10 is by modifying the plugin, to add the following exception to JFXMobilePlugin:
copyClassesForRetrolambda.include '**/*.class'
copyClassesForRetrolambda.includeEmptyDirs = false
// exception for multi-release jars
copyClassesForRetrolambda.exclude 'META-INF/versions/**/*.class'
copyClassesForRetrolambda.exclude 'module-info.class'
and then build the plugin and use a local snapshot.
The good news is that using the jfxmobile plugin version 2.0.20 and Gluon VM, that targets Java 9+, the above is already included.
If you can switch to Java 9/10, modify your project to use this plugin, create a new project with the Gluon IDE plugin ('single view project with Gluon VM'), or follow this sample, but using the latest version (2.0.20 so far).
buildscript {
repositories {
jcenter()
google()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:2.0.20'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = '...'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile 'com.gluonhq:charm:5.0.0-jdk9'
androidRuntime 'com.gluonhq:charm:5.0.0'
compile 'javax.xml.bind:jaxb-api:2.3.0'
}
I'd like to learn how to use Android Studio at the best, but I still have limited experience especially in building with Gradle.
Executing tasks: [clean]
Relying on packaging to define the extension of the main artifact has
been deprecated and is scheduled to be removed in Gradle 2.0
:app:clean UP-TO-DATE
BUILD SUCCESSFUL
Even if everything works I would like to avoid using deprecated methods;
I state that I see this question and tried to understand the deprecation message but fairly the focus for me now is understanding building APK on Android Studio and how to put hands in a project created by this IDE.
Is it possible to fix-it by changing something (configuration files or artifacts) in the project?
PS: I'm on "Android Studio (preview) 0.4.3 build 133" and in the project there is two build.gradle:
1) ~/AndroidStudioProjects/MyAppProject/app/build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
2) ~/AndroidStudioProjects/MyAppProject/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
and one settings.gradle
~/AndroidStudioProjects/MyAppProject/settings.gradle
include ':app'
This appears to be a bug in the Android Gradle plugin and not something you're doing wrong; I see it coming up any time you include a dependency in one of your modules even if it's specified correctly. This warning isn't anything to worry about.
I've filed https://code.google.com/p/android/issues/detail?id=65501 about this.
I'm trying to get to know the Android Studio / Gradle build system, having come from Eclipse and Ant. In particular, I don't understand how the dependencies block in my build.gradle file works.
My current project has the following structure:
In my project I am using both the android support library (v4), and the jxl spreadsheet library. My build.gradle (the one inside the sub-module, not the root level one) currently looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
}
dependencies {
compile 'net.sourceforge.jexcelapi:jxl:2.6.+'
compile 'com.android.support:support-v4:13.0.+'
//compile fileTree(dir: 'libs', include: '*.jar')
}
On the second last line, you can see I've tried using the local copies of android-support-v4.jar and jxl.jar. I've also tried using the lines
compile files('libs/android-support-v4.jar')
compile files('libs/jxl.jar')
However, whenever I try to use the local .jar files, my build fails, saying that the Android support and jxl libraries cannot be found. I've seen lots of posts saying that you can simply use local .jars like this, however I cannot get this to work. If possible, I would like to be able to use my locally stored .jar files so I can work offline, when Maven isn't available.
Can anyone tell me why using the local .jar files doesn't work?
EDIT: I've also tried restarting the Android Studio IDE, and cleaning and re-building my project after adding the local jar dependency lines.
It's not finding the libs directory because it needs to be located at your module root instead of inside src/main. The paths in build.gradle are relative to the location of the build.gradle file, which lives in your module root.
For the Android support library, I'd recommend using the Maven dependency (e.g. compile 'com.android.support:support-v4:13.0.+') instead of including the jar file. With the support library, the Android Gradle plugin actually looks for it in your SDK instead of going out to the network for it; you have to have the support repository installed via the SDK manager. This is actually a little confusing and trips up a lot of users since it's not well-documented. But if you access it this way instead of just including the JAR, then the build system can be smarter about not trying to include duplicate copies of it and causing errors if you include other library projects that depend on it.
I have a library project. I want to use Android's new build system. Currently I'm encountering a quite annoying scenario.
I have my dependencies defined on gradle.build but they never appear under External Libraries in Android Studio. Hence all the references to those libraries are marked as errors.
When I run gradle dependencies on the command line it shows the full dependencies tree and compiles successfully. The problem clearly is with Android Studio.
I tried to restart the IDE/OS but nothing.
This is my gradle.build
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.1'
}
}
apply plugin: 'android-library'
apply plugin: 'idea'
repositories {
mavenCentral()
}
dependencies {
compile 'junit:junit:4.11'
compile 'org.robolectric:robolectric:2.1:jar-with-dependencies'
compile 'com.google.android:android:4.1.1.4'
compile 'com.google.android:support-v4:r7'
compile 'info.cukes:cucumber-java:1.1.3'
compile 'info.cukes:cucumber-junit:1.1.3'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
versionCode 1
versionName "0.3-SNAPSHOT"
minSdkVersion 15
targetSdkVersion 17
}
}
UPDATE
This issue seems to be fixed on latest Android Studio version (0.2.5)
You can use 'Tools->Android->Sync project with Gradle files'. It will resolve the dependencies, download, and add them to external libraries.
Unfortunately, in the current version of Android Studio, the IDE is not completely integrated with the build system (gradle). You have to add the library once in gradle.build for compilation, and once via the GUI for code completion.
Right click on your project, select "Open Module Settings". Acknowledge the warning. Select "Libraries", "+", and add the library you are using. You can search for libraries on Maven in the dialog that appears. You should select your libs dir for the jar. Finally, add the library to your code's module. If your app is MyApp, you probably have MyApp and MyAppProject. You need to add it to MyApp. (You can probably also directly add it from the "Modules" page.)
To additionally get gradle to add the jar to your apk, make the following changes to your grade file. Replace:
compile 'org.jsoup:jsoup:1.6.1'
and similar with
compile files('libs/jsoup-1.6.1.jar')
Now it should all work.
I commented following line from build.gradle file and it started working.
//compile files('libs/android-support-v4.jar')
Previously dry build operation would succeed but when I would try to run on device there would be error
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;