I'm just a hobbyist programmer trying to access Google Calendar. I'm using Android Studio. I've downloaded all the Google Services from the Android SDK manager and set the dependencies. I've also tried following all of Google's documentation of how to do this here: Google Developers: Calendar API Client Library for Java, by adding the client libraries manually in the libs folder of the project.
Any time I do any of this the sample scripts say to type:
import com.google.api.etc...
No matter which way I do it "api" always gets highlighted in red and says it cannot be resolved. I have access to drive, maps, and a bunch of other google stuff, just not calendar.
Has anyone else experienced this problem? If so, how did you fix it? If you need more information from me I'd be happy to supply it.
Thanks!
This is what my build.Gradle dependencies currently looks like:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:+'
}
Print here code of your files Gradle.
You need it likes here, and put it into file build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
UPDATE:
Easify method for adding library, then you can put it into file build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.apis:google-api-services-calendar:v3-rev84-1.18.0-rc'
}
Related
when i use this library :
compile 'co.ronash.android:pushe-base:1.4.0'
I get this error in gradle:
Failed to resolve: com.android.support:support-v4:26.0.2
I can't fix it.
There is a solution to be there library Ignored
'com.android.support:support-v4:26.0.2' from 'co.ronash.android:pushe-base:1.4.0' ?
Because I have already compiled a newer version of support-v4 library.
All my dependencies code in gradle :
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:support-v4:26.+' //--> its ok and no problem
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'co.ronash.android:pushe-base:1.4.0' //--->this code is error Failed to resolve: com.android.support:support-v4:26.0.2
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
testCompile 'junit:junit:4.12'
}
There are a few reasons which can cause this kind of problem.
Checkout these solution, I guess it might help you:
1. Remove Pushe and try adding support-v4 library with version of 26.0.2 to make sure it gets downloaded and cached to your system.
compile 'com.android.support:support-v4:26.0.2' // or implementation
If it still can't be resolved then you have a problem getting it from it's repository server. checkout build.gradle(project:your_prj) and make sure this block is valid.
allprojects {
repositories {
google() // or maven { url 'https://maven.google.com/' } for lower gradles
jcenter()
}
}
If your country is included in sanction you might need to use a VPN to be able to get them. You can also use a proxy like Fod(also donate if you can since it's opensource) or shecan.
Remember all support libraries better be 26.0.2 to avoid conflict and crashing. Your support libraries are 26.0.0-alpha1 which is lower.
After you successfully added and cached support-v4 then try to add Pushe to your dependencies again.
! And also remember that pushe has a support-v4 bundled in it and it's not really needed for you to add it yourself
And Make sure you have
<uses-sdk tools:overrideLibrary="co.ronash.pushe" />
in you manifest. Therefore you can override it's libraries and dependencies.
At the end keep your SDK update.
Edit:
Current version of Pushe is using android support libraries. If you attend to use AndroidX be sure to enable jettifier in order to do runtime conversion.
Good evening,
I'm triying to add OkHttp library to my Android project, which uses Estimote Android SDK. It seems that the Estimote Android SDK has included that library (an older version), but the problem is that other dependencies I have included to my app (like Picasso) can't access to that dependencies, just my own classes can. Picasso, to initialize the image caching system, needs to instantiate OkHttpClient object by his own and this class can be found in the OkHttp library. But, it seems that a dependency can't access to another dependencies' library. I don't really know how to explain it...
If I add the OkHttp dependency to my Gradle, after 7 minutes of building, the build fails with a "dexDebug" error. That means that the same library is included twice (one in the Estimote SDK and other in my Gradle).
Here you can see my Gradle's dependencies field:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
//compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'joda-time:joda-time:2.8.1'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile files('libs/FlurryAnalytics-5.6.0.jar')
compile(name: 'estimote-sdk', ext: 'aar') // This library has okhttp 2.2.0 included in it, but Picasso library can't access here...
}
Here you can see the piece of code that needs the Okhttp library.
Picasso.Builder builder = new Picasso.Builder(this);
OkHttpDownloader downloader = new OkHttpDownloader(this, Integer.MAX_VALUE);
// OkHttpDownloader is a Picasso's class, and then this needs OkHttpClient object from OkHttp library. But it seems that a library can't access to Estimote's library.
builder.downloader(downloader);
Picasso built = builder.build();
built.setIndicatorsEnabled(true);
built.setLoggingEnabled(true);
Picasso.setSingletonInstance(built);
Then, if the problem is solved, I want to change all my HttpRequest AsyncTasks to OkHttp requests.
Any ideas how to solve it? Maybe I can make something in the Gradle file, but I don't know what can I do...
Thank you very much.
Happy coding.
I am a newbee in Gradle. I have a simple project structure (shown bellow) having a main android app module, one android module (myandroidlibrary), and one pure java module (myjavalibrary). They have simple dependencies, app -> myjavalibary, and myjavalibary -> myandroidlibrary (pls see fig. below). Gradle files snapshots are also given below.
However, while sync the gradle it produces following error:
D:\MyTestCodes\MyTestApplication\app\build.gradle
Warning:Module version MyTestApplication:myjavalibrary:unspecified depends on libraries but is a jar
Pls help me out! I have spent this whole day to sort it out with no result!
MyProject
- app
- myjavalibrary (pure java library)
- myandroidlibrary (android library)
Now the dependency is as follows:
"app" depends on -> "myjavalibrary"
"myjavalibrary" depends on -> "myandroidlibrary"
Gradle files for each of the modules are as follows:
build.gradle for app:
apply plugin: 'com.android.application'
android {
// ommitting other detail
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile project(':myjavalibrary')
}
build.gradle for myjavalibrary:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':myandroidlibrary')
}
build.gradle for myandroidlibrary:
apply plugin: 'com.android.application'
android {
//ommiting other detail.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}
settings.gradle:
include ':app', ':myjavalibrary', ':myandroidlibrary'
Now while I sync the gradle files it shows the following error:
D:\MyTestCodes\MyTestApplication\app\build.gradle
Warning:Module version MyTestApplication:myjavalibrary:unspecified depends on libraries but is a jar
Warning is caused by pure-jave myjavalibrary module having a dependency on the myandroidlibrary one, which is an Android library.
Gradle warns you that a pure-java module doesn't know anything about Android specific stuff of myandroidlibrary (like Android resources, assets etc.). By having this dependency (pure-java to android library one) you might lose some stuff you expect to have.
A much cleaner dependency direction would be the one from a android library to a pure-java library. In this case Gradle won't give you any warnings.
If you want to create an Android app project from java code, use apply plugin: 'com.android.application'.
If you want to create a library project from java code, use apply plugin: 'com.android.library'.
If you want to use pre-built jar files, do not create any project for them. Just add them into the projects, into the libs folder, which depend on them. The compile fileTree(dir: 'libs', include: ['*.jar']) in the dependencies would take care of them.
Note: I am not very familiar with gradle
Several projects I've worked on with gradle have a dependencies section such as the following where I used the Sugar ORM:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.github.satyan:sugar:1.3'
}
I can compile the Sugar ORM project using:
'com.github.satyan:sugar:1.3'
I have a local server hosting a small library on GitLab which I want to include in my next gradle project.
I want to be able to do the following in my dependencies section for my new project:
dependencies {
compile 'git.devstuff.com:?:?'
}
http://git.devstuff.com/admin/broadcast_lib.git (local server) is the where my git project is, but I don't know how to fill in the question marks in the above code snippet.
The end result I would like is to include the library in a future project via the following in my build.gradle file:
dependencies {
compile 'git.devstuff.com:broadcast_lib:1.0'
}
I'll update the question if I'm lacking information.
First, this is not duplicate. I have browsed answers to "How to add library to project in Android Studio" but found no answer. I cant find src and libs folder. I want to add volley jar to project. Screenshot attached:
http://i.stack.imgur.com/2SyUp.png
For preferred way read bellow this answer:
If you need to add a library to the Android Studio project navigate to your project folder with default path at:
\YourProjectName\app\libs
You can paste your *.jar library there. Make sure your build.gradle contain this directive at dependencies part:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
To see the library at the Android Studio, switch to the "Project" view at the menu:
Preffered way:
Preferred way to import libraries to your project is by gradle dependency system.
To do so, open your build.gradle file and locate the dependencies part. To import the library you mentioned, Volley, your dependencies part should look somehow like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library:1.0.10'
}
You don't need to import the *.jar library manually any more. Gradle dependencies system will take care of it.
To find gradle dependency you need, you might use tools like:
http://gradleplease.appspot.com/
http://search.maven.org/