Android studio 1.2.2 gradle library - android

Adding a gradle project with compile has been working for me very well, but I noticed after updating the Android studio to 1.2.2, or maybe the version just before it, that adding a library is not working anymore.
So for example I tried to add this and I did the "Sync Now" and it was successful but the library doesn't seem to be recognized. When I try to use ProgressWheel in Java and I hit ctrl+Enter it doesn't find the library, anyone have an idea of what should I do?
dependencies {
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/universal-image-loader-1.9.3.jar')
compile 'com.romainpiel.shimmer:library:1.4.0#aar'
//the above libraries were added before the update, everything was
//working fine, the below isn't
compile 'com.pnikosis:materialish-progress:1.5'
}
Please note that I tried many other libraries and all had the same result.

The project README (front page of https://github.com/pnikosis/materialish-progress) says it's on Maven Central. Android Studio uses jCenter (by Bintray) by default. Add this in your module's build.gradle file:
repositories {
mavenCentral()
}

Related

Android recyclerview dependency display error

This is very default setting, first I create a dummy project, then click add recyclerview, then I click at recyclerview menu, the Android studio prompt to add the library, then I accept.
I click at okay, the dependency than update as following:
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:25.3.1'
and the error message as this
please be remind I use default android studio
you need to use the same version for support libraries.
either use 25.3.1 for both support libraries or use 26.0.0 for both support libraries.
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
hope this will help you.
Please make sure that all the support libraries you are using are of the same version and major version has to match compile SDK version.
As you yourself mentioned adding Google's Maven Repository solves the problem. For others,
The most recent versions of the following Android libraries are
available from Google's Maven repository:
Add them like this:
repositories {
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}

Failed to resolve: com.onesignal:OneSignal:3.4.3

I'm trying to setup OneSignal push notifocation in my Android app. I have changed my build.gradle to include the required dependencies (or so I think).
No matter what I do I keep getting
Failed to resolve: com.onesignal:OneSignal:3.4.3
or
Could not find com.onesignal:OneSignal:3.4.3
Can anyone give me a slight push please? Thanks in advance :-)
I should mention that I have checked the trouble shooting section on OneSignals home page. All is in order.
Here's the dependencies section of my gradle file:
dependencies {
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.firebase:firebase-analytics:9.6.0'
compile 'com.google.firebase:firebase-crash:9.6.0'
compile files('src/main/libs/simple-xml-2.7.jar')
compile files('src/main/libs/date4j.jar')
compile files('src/main/libs/picasso-2.5.2.jar')
compile 'com.onesignal:OneSignal:3.4.3#aar'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
}
The OneSignal SDK is hosted on Maven Central so I would first make sure you can access this from your system. Next double check the following as well.
Make sure you're using Android Studio version 1.4.0 or newer.
Go to File>Settings. Search for Offline work and uncheck that option.
Add the following to your .gradle file.
Root build.gradle
repositories {
mavenCentral()
}
4. Try restarting Android Studio and then going to Tool>Android>Sync Project again.
5.Try building OneSignal's example Android Studio project. If this works then the problems is related to your project.
Screenshots for some of these steps below.
https://documentation.onesignal.com/docs/troubleshooting-android
Well... what finally fixed this issue for me was to replace
mavenCentral()
with
jcenter()
go figure... :-)

How to compile from a github repository from Intellij in the build.gradle file?

Let's pretend that I have a github repository at github.com/myprojects/myrepo
Let's also pretend that I have a project in IntelliJ with a build.gradle file that contains the following:
dependencies {
// android
compile 'com.android.support:appcompat-v7:21.0.0'
// google play services
compile 'com.google.android.gms:play-services:6.1.71'
}
I want to add my github project via Gradle so I imagine that the dependencies need to add something like:
compile 'github.com:myprojects:myrepo'
This obviously isn't how it works though since I get "Failed to resolve com.github:myprojects:myrepo
Actual examples which work:
compile 'com.github.satyan:sugar:1.3'
compile 'com.github.castorflex.smoothprogressbar:library:x.x.x'
Since I don't want to clone the repository into a libs folder, how can I add a compile command in the dependencies portion of my build.gradle file to compile from github so that I can simply add something like the following:
compile 'com.github.myprojects:myrepo'
compile 'com.github.castorflex.smoothprogressbar:library:x.x.x'
It works because this library is published in Central Maven.
compile 'github.com:myprojects:myrepo'
This obviously isn't how it works though since I get "Failed to resolve >com.github:myprojects:myrepo
It is not enough to push on github.
You have to publish you artifact on Central Maven or JCenter or a local maven. You can find some guides to publish on jcenter, for example this.

add android-support-v13.jar in Android Studio

I have been trying to add android-support-v13 in Android Studio 1.0.2
I have followed the steps here but I still get a build fail. Has anyone successfully managed to add android-support-v13.jar into Android Studio 1.0.2?
Below is my code in my gradle file.
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile fileTree(dir: 'libs',include: '*.jar')
Edit: I have installed extra support library from SDK manager and I have placed the .jar in my libs folder.
according to docs at this time:
The Gradle build script dependency identifier for this library is as
follows:
com.android.support:support-v13:18.0.0
lets hope that the docs are updated.
for the latest you should use:
compile 'com.android.support:support-v13:21.0.+'
same problem android studio 1.0.2 i solve that below
compile 'com.android.support:appcompat-v7:21.0.1'
compile 'com.android.support:appcompat-v7:+'

Gradle Project Sync Failed - Unresolved dependencies

I've taken an Android project that was created in IntelliJ and imported it into AndroidStudio. After looking at Googles hopeless instructions for how to migrate a project to Gradle I pressed buttons at random and prayed to the gods of droid whilst sacrificing a small innocent child and somehow eventually ended up with a Gradle controlled project that synced, built and ran on my Android devices.
I then added some additional dependencies to my build.gradle file:
compile 'com.octo.android.robospice:robospice:1.4.12'
compile 'com.octo.android.robospice:robospice-spring-android:1.4.12'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.http-client:google-http-client-jackson:1.18.0-rc'
compile 'com.octo.android.robospice:robospice-google-http-client:1.4.12'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
Now when I try to sync Gradle I get the following message:
Gradle Project sync Failed. Basic functionality (e.g. editing, debugging) will not work properly.
In the Gradle Sync window I get the following messages:
Unresolved Dependencies:
Error:com.google.http-client:google-http-client-gson:1.18.0-rc
Error:com.octo.android.robospice:robospice-spring-android:1.4.12
...
and so on for each of the dependencies that I have listed.
How might I resolve this?
OK I've figured it out.
I added
allprojects {
repositories {
mavenCentral()
}
}
to the bottom of my build.gradle file.
It was obviously struggling to find a repository to load from.
The script already had
buildscript {
repositories {
mavenCentral()
}
This it would seem was insufficient.

Categories

Resources