Downloading for too long time with gradle in IDEA - web

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/

Related

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
}

Import swagger-codegen project into existing Android project

Im trying to integrate a "module"-project generated by swagger-codegen, into my Android project.
Haven't worked that much with gradle before and the swagger-codegen creates a quite messy build.gradle from my point of view.
I have a hard time finding documentation on how to do this. And I feel a bit lost.
I used this method described in the FAQ
mvn clean package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l java --library=okhttp-gson \
-o /var/tmp/java/okhttp-gson/
So fare I tried to copy the source from the project that was generated by swagger-codegen and merge the two gradle build files. I removed the Junit tests because I couldn't get the Junit dependency working (Implementing Swagger-codegen project - Error:(23, 17) Failed to resolve: junit:junit:4.12). But then I got stuck with some conflict between the plugins?
The 'java' plugin has been applied, but it is not compatible with the Android plugins.
Here's the build.gradle:
import static jdk.nashorn.internal.runtime.regexp.joni.ApplyCaseFold.apply
apply plugin: 'idea'
apply plugin: 'eclipse'
group = 'io.swagger'
version = '1.0.0'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// classpath 'com.android.tools.build:gradle:1.5.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
repositories {
jcenter()
maven { url 'http://repo1.maven.org/maven2' }
}
if(hasProperty('target') && target == 'android') {
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "\u0024{project.name}- \u0024{variant.baseName}-\u0024{version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
dependencies {
provided 'javax.annotation:jsr250-api:1.0'
}
}
afterEvaluate {
android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
} else {
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
install {
repositories.mavenInstaller {
pom.artifactId = 'XxxxXxxx'
}
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
dependencies {
compile 'io.swagger:swagger-annotations:1.5.8'
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
compile 'com.google.code.gson:gson:2.6.2'
compile 'joda-time:joda-time:2.9.3'
// testCompile 'junit:junit:4.12'
}
Am I doing something complete wrong here? What is the correct way to implement swagger-codegen code into my project?
The swift way to import it was to compile the swagger generated project then copy the .jar file to my android project and add its as a library.
I have a hard time finding documentation on how to do this. And I feel a bit lost.
You could clone the Android swagger-codegen example.
(which does use Junit, so I'm not sure what error you got)
Unless that's what you mean by
So far I tried to copy the source and merge the two gradle build files
To which, I ask, what two Gradle files? It looks like you merged an Android Gradle file with a Java Gradle file, which seems to causing more issues because you are getting...
The 'java' plugin has been applied, but it is not compatible with the Android plugins.
Which seems pretty self explanatory when you have this line
apply plugin: 'java'
It's not too clear what you are trying to do here other than check the build target
if(hasProperty('target') && target == 'android')

Gradle sync issue with Android Studio 0.5.1

Since updating to AS 0.5.1, I have been unable to sync up my project. Gradle gives me the following warning:
No signature of method: static com.google.common.collect.ArrayListMultimap.create() is applicable for argument types: () values: []
Possible solutions: clear(), grep(), get(java.lang.Object), get(java.lang.Object), getAt(java.lang.String), isCase(java.lang.Object)
It does not point to anything in my build.gradle file that may be causing the issue, so I am rather lost as to where to begin.
Edit: When attempting to run gradle build, I subsequently get this issue when applying the Android plugin:
A problem occurred evaluating root project 'tve-android'.
> Could not create plugin of type 'AppPlugin'.
My build.gradle file:
buildscript {
repositories {
mavenLocal()
maven {
url "http://nexus.products/nexus/content/groups/public"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
apply plugin: 'pmd'
android {
compileSdkVersion 19
buildToolsVersion "19.0.2"
defaultConfig.minSdkVersion = 16
defaultConfig.targetSdkVersion = 19
defaultConfig.testInstrumentationRunner = 'android.test.InstrumentationTestRunner'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main.java.srcDirs = ['src/main/java']
main.resources.srcDirs = ['src/main/resources']
main.res.srcDirs = ['src/res']
main.assets.srcDirs = ['src/assets']
androidTest.java.srcDirs = ['src/test/java']
androidTest.resources.srcDirs = ['src/test/resources']
androidTest.res.srcDirs = ['src/res']
androidTest.assets.srcDirs = ['src/assets']
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.+'
compile 'commons-io:commons-io:2.+'
compile 'commons-lang:commons-lang:2.+'
compile 'com.loopj.android:android-async-http:1.4.+'
compile 'com.jakewharton:disklrucache:1.0.0'
compile 'net.jpountz.lz4:lz4:1.1.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.1'
androidTestCompile 'com.google.dexmaker:dexmaker:1.+'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.+'
androidTestCompile 'org.mockito:mockito-core:1.9.+'
}
Upgrading gradle to v1.10 is also needed.
I had the same issue and I quickly fix it just by re-import my gradle project.

Resources