Cannot resolve jitpack dependencies in android studio in the last gradle version - android-studio

I get Failed to resolve: com.github.dogecoin:libdohj:v0.15.9 error and I don't know why. I also tried other jitpack dependencies. It works fine in my previous projects.
buildscript {
ext {
compose_version = '1.0.2'
}
repositories {
google()
maven { url "https://jitpack.io" }
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

I added the maven { url "https://jitpack.io" } to the settings.gradle and it fixed the issue.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url "https://jitpack.io" }
}
}
rootProject.name = "Crypto World"
include ':app'

In the new version (7.2) of Gradle some parts is changed, so you need to do like this:
1-Check your gradle version
2- Open the build.gradle(project:---)
3- If like the below code, go to next
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
4- Open stting.gradle(---)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
5- Sync Now and finish

Related

How to apply JaCoCo to build.gradle?

I wanted to add JaCoCo to an existing Android Studio Project. In my settings.gradle I edited:
pluginManagement {
gradle.ext.kotlin_version = "1.6.0"
repositories {
google()
mavenCentral()
}
def versionsProp = new Properties()
versionsProp["myapp.version.level"] = "7.1.0-beta05"
def versionsPropFile = file("local.properties")
if (versionsPropFile.canRead()) {
versionsProp.load(new FileInputStream(versionsPropFile))
}
def levelVersion = versionsProp["myapp.version.level"]
plugins {
id("com.android.application") version "$levelVersion"
id("com.android.library") version "$levelVersion"
id("org.jetbrains.dokka") version "1.4.30"
id("org.jetbrains.kotlin.android") version "$gradle.ext.kotlin_version"
id("org.jacoco.core") version "0.8.7"
} }
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
mavenLocal()
} }
rootProject.name = "TestApp"
include ":app"
include ":mylib_1"
include ":mylib_2"
include ":docs"
Especially I added JaCoCo in plugins section. According to this medium article :
Now inside each module’s build.gradle file apply the newly created
jacoco.gradle as such: apply from: "$project.rootDir/jacoco.gradle"
But in my app modules build gradle (I've shortened away stuff commented there) I have follwing structure:
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
compileSdkVersion = 31
buildToolsVersion = "31.0.0"
defaultConfig {
applicationId = "org.example.myapp"
// minSdkVersion(21), targetSdkVersion(31) ..
}
// buildTypes, flavorOptions, compose options
// compile options, kotlinOptions, buildFeatures, packagingOptions, lintOptions
}
dependencies {
implementation(fileTree(include: ["*.jar"], dir: "libs"))
implementation("androidx.activity:activity-compose:$compose_activity_version")
implementation("androidx.appcompat:appcompat:$appcompat_version")
testImplementation("junit:junit:4.13.2")
implementation(project(":org_mylib_1"))
implementation(project(":org_mylib_2"))
}
So where or how am I supposed to add the apply from: "$project.rootDir/jacoco.gradle"?

Downloading kotlin-stdlib and kotest runner taking almost infinity time

In my android project when I hit the sync button downloading kotlin-sdklib and kotest-runner-junit taking very long time.
It took 16 minutes. And this is going every time when gradle changes. Other projects working fine, problem only with this project.
The problem was I've added
maven { url "https://dl.bintray.com/terrakok/terramaven" }
in my project build.gradle allprojects -> repositories. I've removed it and added mavenCentral() and jcenter() instead.
before:
allprojects {
repositories {
google()
maven { url "https://dl.bintray.com/terrakok/terramaven" }
maven { url 'https://jitpack.io' }
}
}
after:
allprojects {
repositories {
google()
maven { url 'https://jitpack.io' }
mavenCentral()
jcenter()
}
}

implementing the com.amulyakhare library in android studio

Hello i am trying to import a library called amulyakhare from github into my android studio project but i keep getting the following error after syncing:
Failed to resolve: com.amulyakhare:com.amulyakhare.textdrawable:1.0.1
Show in Project Structure dialog
Affected Modules: app
You can find the github page of the library here :
#github/amulyakhare
This is the code in the build.gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.example.androidnewchatapp"
minSdkVersion 28
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:27.1.0')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//Firebase UI
implementation 'com.firebaseui:firebase-ui-auth:7.1.1'
implementation 'com.firebaseui:firebase-ui-database:7.1.1'
//viewPager 2
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
//ButterKnife
implementation 'com.jakewharton:butterknife:10.2.3'
annotationProcessor'com.jakewharton:butterknife-compiler:10.2.3'
//Dexter
implementation 'com.karumi:dexter:6.1.2'
//TextDrawable (The amulyakhare Library)
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
//EventBus
implementation 'org.greenrobot:eventbus:3.2.0'
//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor'com.github.bumptech.glide:compiler:4.11.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.firebase:firebase-analytics'
}
i dont know if there is something wrong wih the library or there is something missing in my code. Thank you in adnvance to those who can help out
Add this to your settings.gradle
jcenter()
maven {
url 'https://jitpack.io'
}
if you're using android studio bumblebee settings.gradle should be like this
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
maven {
url 'https://jitpack.io'
}
}
}
rootProject.name = "You App Name"
include ':app'
If not work, try to import jar file, download from this
I figured it out
1)In your project level gradle add jcenter()
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
JCenter Maven repository is no longer receiving updates: newer library versions may be available elsewhere
so You need to find same library somewhere else. or you can fork yourself and upload to jitpack
OR
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.alvinhkh:TextDrawable:f9f516c43b'
}
https://jitpack.io/#alvinhkh/TextDrawable/f9f516c43b
ADD these Simple Lines In Build.Gradle
buildscript {
repositories {
google()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
maven { url "https://www.jitpack.io" }
jcenter()
maven {
url 'http://dl.bintray.com/amulyakhare/maven'
}
}
dependencies {
//Your dependencies here
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
maven { url "https://www.jitpack.io" }
maven { url 'https://jitpack.io' }
mavenCentral()
}
}
And in Build.Gradle (App)
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
Will work 100%

Error:Failed to resolve: runtime

so my project was working fine yesterday and I tried to open it today and it gives me that error , help would be much appreciated
I tried to search for a long time about whats going wrong but it seems all answers not working with me
Error:Failed to resolve: runtime
Open File
here is build.gradle(Project) file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and here is build app profile
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.android.writer"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.android.support:design:26.1.0'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.firebase:firebase-client-android:2.5.2+'
}
apply plugin: 'com.google.gms.google-services'
Based on the answer in Android Studio 3.1.2 : Failed to resolve: runtime, try changing the order of imports in build.gradle project file as
allprojects {
repositories {
google()
maven {
url "https://maven.google.com" // Google's Maven repository
}
jcenter()
}
}
This worked for me.
This is very weird and took me almost 4-5 hours to fix. But, it turns out you need to put google() at the top and jcenter() at the bottom of repositories in build files for all modules. Maven can go in between and it'll be fixed.
allprojects {
repositories {
google()
maven {
url "https://maven.google.com" // Google's Maven repository
}
jcenter()
}
}
You must place google() as the 1st line. Reminder First line. I hope it will help you.
This worked for me
repositories {
google()`Goolge repo`
jcenter()
maven {
url 'https://maven.google.com/ `Google maven repo`
name 'Google'
}
}

Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found

apply plugin: 'kotlin-android-extensions'.
When i add this extensions in android studio preview, give me this error
"Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found.".
My build gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.mohamed_elbaz.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
The build.gradle snippet you posted looks like the config inside your app module. What does the build.gradle in your project's root directory look like? To add the kotlin plugin dependencies it should look something like this:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The important part being the line classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"which adds the kotlin plugins.
To use the plugin, you have to add it in your root build.gradle file
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
In Android Studio we can fix it in following ways:_
Using the plugins Domain Specific Language (DSL) in App Level Graddle:
plugins {
id "org.jetbrains.kotlin.android.extensions" version "1.4.21"
}
That's all to fix it.
But if you're using legacy plugin application, then add the following in App Level Gradle:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21"
}
}
apply plugin: "org.jetbrains.kotlin.android.extensions"
Hopefully, it'll be helpful!
put the below lines in build.gradle app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
and also do changes in build gradle by adding kotlin extension and path
//put the ext above the dependency line//
ext.kotlin_version = '1.4.31'
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

Resources