Android gradle fails to resolve jitpack snapshot build dependency - android

I had a GitHub project forked and some fixes applied to it. Now would like to use it as dependency in a project of mine. Have followed the instructions provided at jitpack.io but gradle build fails to find it.
build.gradle (all projects)
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
build.gradle (module)
dependencies {
implementation 'com.github.user:repo:e91058a'
}
Have tried calling File->Sync in Android Studio and running gradlew build --refresh-dependencies. Also tried defining dev-SNAPSHOT as the version number instead of commit hash. But it always ends up with Failed to resolve error.
What am I missing here?

Check your repositority on jitpack.io, and verify that the snapshot was actually built. (Enter your repo url, select 'branches', you must see a green icon near your commit sha)
Also if your repository is private, you'd need to add access token in build.gradle (you can find it in ur account setting)

Related

How to implement implementations in android without error?

I want to add AdView to my activity and I click on download and then it automatically implements the necessary library. But then I get the following error:
Error 1
I get the same error when I try to add GridLayout to my library.
Here is my gradle file: gradle file
I already tried to set the Global Gradle settings to offline work but it doesn't help.
I have android studio 3.4.2
This is a problem that bothers me for a while now and there seems no solution to this. Is it possible that these things are not available for androidx yet? Thank you for your help!
From the documentation:
To make the Google Play services APIs available to your app:
Open the build.gradle file inside your application module directory.
Note: Android Studio projects contain a top-level build.gradle file and a build.gradle file for each module. Be sure to edit the file for your application module. See Building Your Project with Gradle for more information about Gradle.
Add a new build rule under dependencies for the latest version of play-services, using one of the APIs listed below.
Ensure that your top-level build.gradle contains a reference to the google() repo or to maven { url "https://maven.google.com" }.
Save the changes, and click Sync Project with Gradle Files in the toolbar.
You can now begin developing features with the Google Play services APIs.
This is often a common mistake. If you have multiple repositories in your gradle, make sure that maven google is at the top of the list.
eg.
repositories {
maven { url "https://maven.google.com" }
...
}
This package:
// https://mvnrepository.com/artifact/com.google.android.gms/play-services-ads
implementation "com.google.android.gms:play-services-ads:18.1.1"
is either available from repository google() or from repository mavenCentral():
repositories {
google()
mavenCentral()
...
}
see the quick-start.

Android Studio 3.2 - Could not find com.android.tools.build:aapt2:3.2.0-4818971

I was following a tutorial to develop icon pack for android and when I imported the project I got several errors and it was solved here - Gradle Version 4.6 - Absolute path are not supported when setting an output file name
After solving that error, the following error poped up.
Could not find com.android.tools.build:aapt2:3.2.0-4818971.
Searched in the following locations:
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
Required by:
project :licensing
I tried to open the URLs and I was able to download JAR (aapt2-3.2.0-4818971-windows.jar) and JSON (aapt2-3.2.0-4818971.pom.json) files from the first 2 URLs. Should I copy these files somewhere? What should I do to solve this error?
Most likely you do not have the Google repository in your project's build.gradle file. Add google() in BOTH locations as shown below:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I was able to solve the issue by adding google() in both locations:
File -> Project Structure -> Project -> *Now add ", google()" in
Android Plugin Repository
and
Default Library Repository
*
When you upgrade to 4.6 version of gradle. You need following upgrades too. Gradle Plugin Release page.
1. Android Studio 3.+
You need Android Studio version 3.+ to have 4.6 version of gradle. At the time of post latest release was 3.2.1. You can see latest release on this page.
2. Gradle Plugin 3.1.+
You need 3.1.+ gradle plugin for gradle-4.6 support. Check in project level build.gradle.
classpath 'com.android.tools.build:gradle:3.2.1'
At the time of post latest version was 3.2.1. You can see latest release here.
3. Add Google Maven Library
You need to add Google Maven library to project level build.gradle like below code.
buildscript {
repositories {
google()
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
...
}
}
allprojects {
repositories {
google()
...
}
}
see the dependencies of module :licensing and use com.android.tools.build:aapt2:3.2.0 (or even "com.android.tools.build:aapt2:3.2.0:windows") there, which is the final version ...that 4818971 version should ordinary come with an alpha prefix/suffix (the version number seems to be incorrect). maybe adding repository google() might be required, too. ordinary, that dependency should be present; removing that dependency might be another possible option.
For those people who still face exactly the same problem even after adding two google to BOTH positions in relevant gradle file.I would suggest you to check Android Studio -> Preferences -> HTTP Proxy page.
If you find it says some warnings like "...have set JVM proxy to 127.0.0.1".Then you should consider vpn-related issues which depends on your context.
If your desktop is MacOS, then go to Network setting page, advance->proxy tab,uncheck all the checkbox there.
Back to your IDE as following steps: Android Studio->File->Invalidate Caches/Restart.After that,go back to check Android Studio -> Preferences -> HTTP Proxy page again,previous warnings should be gone.Run again.
I solved my issue by upgrading my classpath from
'com.google.gms:google-services:4.0.0
to
'com.google.gms:google-services:4.2.0'
hope this helps

Android O Gradle build fails with travis ci

I'm trying to use Travis CI for my Android Project but my Builds constantly failing but works on local build. I am using Android Studio Preview 3 and gradle 3 alpha 3.
I am getting this error below.
Could not find com.android.tools.build:gradle:3.0.0-alpha3.
Here is my build log
My Travis Config file
My Project gradle file
I'm getting an Access denied error to your build log, and I didn't use it, but I'll try to answer you.
As announced here:
The Android Gradle Plugin 3.0.0-alpha3 was also released through
maven.google.com.
You can try to fix it by adding Google’s Maven Repository here like this:
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Make sure that the repositories section includes a maven section with
the "https://maven.google.com" endpoint. For example:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
As commented here, this version doesn't exist in Bintray JCenter:
com.android.tools.build.gradle
latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3
Also be sure to update build tools to the latest version as suggested in this related question:
Update your build tools from SDK manager
I add links to samples using the new sdkmanager command line here.
I would need a sample project reproducing the issue to check my suggestions.

JitPack: Failed to resolve subrepo

I'm using jitpack to in my gradle as follows:
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
And in my github repo I have a sub-module called authentication
I need to use only this module in my project, so I added this to my module's build.gradle as mentioned here:
compile 'com.github.MotassemJa.MoAuth:authentication:0.0.5'
But I keep getting
Error:(23, 13) Failed to resolve: com.github.MotassemJa.MoAuth:authentication:0.0.5
As you can see at https://jitpack.io/com/github/MotassemJa/MoAuth/0.0.5/build.log, 0.0.5 was built from commit ebb529c949bf7d40815c815d051d45407e8f7f71 which is 0.0.5~2 and there the module was named moauth2.0.
It seems you moved the tag and thus the release after it was compiled and cached by JitPack.
It is always a very bad idea to modify releases after they are done instead of releasing a new version.
I don't know whether you can make JitPack forget the cache and rebuild your application, but maybe it would be best to move the 0.0.5 release back to where it was and create a 0.0.6 release.
You might be able to make JitPack re-build your app if you log into jitpack.io with GitHub and delete the existing build. The FAQ are not too clear on that. It could be that this only works for failed builds.

Android Crashlytics plugin not installing library

When using the Crashlytics plugin in intellij I follow these steps.
Click plugin on toolbar.
Select App
Allow crashlytics to update AndroidManifest.xml as well has my first Activity.
Click "Next"
Try to build the App as the plugin instructs.
Then when i try to build i get this:
package com.crashlytics.android does not exist
I look in my dependencies and library and the jar is nowhere to be found.
What am I missing that would cause the library to not be loaded?
I solved this by following the maven instructions here https://crashlytics.com/downloads/maven and then just grabbing the jar from my .m2 and putting it in my libs folder. (This particular project was started as a maven project, then Maven was discarded and it has not yet been migrated to Gradle, so we're kind of in no-man's land). Anyway, I now have the jar.
The following configuration should work for Gradle-based projects:
buildscript {
repositories {
maven { url "http://download.crashlytics.com/maven" }
}
dependencies {
classpath "com.crashlytics.tools.gradle:crashlytics-gradle:1.+"
}
}
apply plugin: "crashlytics"
repositories {
maven { url "http://download.crashlytics.com/maven" }
}
dependencies {
compile "com.crashlytics.android:crashlytics:1.1.+"
}
Taken from https://crashlytics.com/downloads/gradle
After the automated setup from android studio, I was missing this line:
compile 'com.crashlytics.android:crashlytics:1.1.+'

Categories

Resources