Downloading kotlin-stdlib and kotest runner taking almost infinity time - android-studio

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()
}
}

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"?

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

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

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'
}
}

Downloading for too long time with gradle in IDEA

When I start a new project,it take me too long time to download the whole jar libs(for more than 5 hours),how can I deal with it?
This is the code in my build.gradle file:
import com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile 'javax:javaee-api:7.0'
compile 'mysql:mysql-connector-java:5.1.39'
compile 'jstl:jstl:1.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile 'org.mybatis:mybatis:3.4.1'
compile 'commons-fileupload:commons-fileupload:1.3.1'
compile 'org.springframework:spring-context:4.3.4.RELEASE'
compile 'org.springframework:spring-jdbc:4.3.4.RELEASE'
compile 'org.springframework:spring-webmvc:4.3.4.RELEASE'
compile 'org.springframework:spring-context-support:4.3.4.RELEASE'
compile 'org.projectlombok:lombok:1.16.6'
compile 'org.mybatis:mybatis-spring:1.3.0'
compile 'org.freemarker:freemarker:2.3.23'
compile 'org.jasypt:jasypt:1.9.2'
}
you can use the nearest maven repositories for gradle;
add the repositories into builde.gradle:
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
in builde.gradle:
buildscript {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url "https://repo.spring.io/plugins-release" }
}
dependencies {
classpath("org.springframework.build.gradle:propdeps-plugin:0.0.7")
classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.3")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.5-2"
classpath("io.spring.gradle:docbook-reference-plugin:0.3.1")
}
}
details: https://pingcai.me/2016/12/16/Maven-Gradle-Resolve-Dependencies-%E9%80%9F%E5%BA%A6%E5%A5%87%E6%85%A2%E6%97%A0%E6%AF%94/

Resources