I created a project in Android Studio and added a few dependencies using Maven Central and when I try to compile, I run into this type of errors:
Error:Gradle: Attribute "titleTextStyle" has already been defined
Error:Gradle: Attribute "subtitleTextStyle" has already been defined
[...]
And so on... Here is my build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
}
}
dependencies {
// Support Libraries
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'com.android.support:support-v13:18.0.0'
// Third-Party Librairies
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'ch.acra:acra:4.5.0'
}
Sadly the Make Console doesn't speak as much as Eclipse's Console, so I have no idea of the problem's origin.
Does anyone have an idea of what causes these compile errors?
You should remove this line in your dependencies :
compile 'com.android.support:appcompat-v7:18.0.0'
The last version of Google Play Services now uses appcompat-v7, so u can't use it with actionbarsherlock. You have to use only appcompat-v7 or the previous version of play services:
compile 'com.google.android.gms:play-services:7.0.0'
Related
In my app, I am trying to use gcm services, but I cannot even get gradle to compile. I keep getting the message that I am missing 'firebase core' though I have no idea how to install this.
This is my top-level gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath "io.realm:realm-gradle-plugin:1.1.0"
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url "https://mint.splunk.com/gradle/"
}
}
}
And here is my module-level gradle file:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "roof.android"
minSdkVersion 17
targetSdkVersion 23
versionCode 11
versionName "0.0.4"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTIC E.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties'
exclude 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// "The Android Support Library package contains several libraries that can be included in your application" -- https://developer.android.com/topic/libraries/support-library/features.html
compile 'com.android.support:appcompat-v7:24.0.0'
// "Native android recycler view library" -- https://developer.android.com/topic/libraries/support-library/features.html
compile 'com.android.support:recyclerview-v7:24.0.0'
// "A powerful image downloading and caching library for Android" -- http://square.github.io/picasso/
compile 'com.squareup.picasso:picasso:2.5.2'
// "Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster" -- https://developer.android.com/training/volley/index.html
compile 'com.android.volley:volley:1.0.0'
// "JsonWebTokens in Auth0" -- https://auth0.com/docs/jwt
compile 'com.auth0:java-jwt:2.1.0'
// "Joda-Time provides a quality replacement for the Java date and time classes" -- http://www.joda.org/joda-time/
compile 'joda-time:joda-time:2.8.1'
// "Android loading or progress dialog widget library, provide efficient way to implement iOS like loading dialog and progress wheel" -- https://github.com/Cloudist/ACProgressLite
compile 'cc.cloudist.acplibrary:library:1.2.1'
// "A RecyclerView that is powered by Realm and lots more" -- https://github.com/thorbenprimke/realm-recyclerview
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.22'
// "A beautiful ripple animation for your app" -- https://github.com/skyfishjy/android-ripple-background
compile 'com.skyfishjy.ripplebackground:library:1.0.1'
// "A logger with a small, extensible API which provides utility on top of Android's normal Log class." -- http://jakewharton.github.io/timber/
compile 'com.jakewharton.timber:timber:4.1.2'
// "Field and method binding for Android views" -- http://jakewharton.github.io/butterknife/
compile 'com.jakewharton:butterknife:8.1.0'
apt 'com.jakewharton:butterknife-compiler:8.1.0'
// "An HTTP+HTTP/2 client for Android and Java applications." -- http://square.github.io/okhttp/
compile 'com.squareup.okhttp3:okhttp:3.3.1'
// "Android client for Sentry"
compile 'com.joshdholtz.sentry:sentry-android:1.4.1'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
}
In your module Gradle file (usually the app/build.gradle), add the apply plugin(apply plugin: 'com.google.gms.google-services') line at the bottom of the file to enable the Gradle plugin.
You should also add the dependencies for the Firebase com.google.firebase:firebase-core and com.google.firebase:firebase-messaging SDK's:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Make sure you have the latest version of 'Google Play services' and 'Google Repository' installed while using Firebase.
Please follow below steps to install:
Open Android studio
Go to the Menu bar > Tools > Android > SDK Manager
Click on Tab > SDK Tools
Check and install 'Google Play Services' and 'Google Repository'
Click on Apply and wait for the download
Finally, Sync and build your project again.
You want to add push notifications in your app ?
use firebase instead of GCM. it is enhanced version of GCM.
You need following dependencies for firebase push notifications.
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.google.android.gms:play-services-gcm:9.0.1'
for further info visit http://codingaffairs.blogspot.com/2016/06/firebase-cloud-messaging-push.html
I had the same problem with com.google.firebase:firebase-core:11.8.0 and it worked after moving the google() repository above jcenter().
In between I used Build -> Clean Project.
./build.gradle
buildscript {
repositories {
google() // <- now on top!
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google() // <- now on top!
jcenter()
}
}
If you want to add the firebase core, you can add
compile 'com.google.firebase:firebase-core:9.0.0'
under dependencies tag in your module-level gradle file.
If you still can't resolve it, maybe you need to update the SDK to get the Google Play Services rev 30 and Google Repository rev 26 first. See here for the detail.
In your android/build.gradle in your repositories section, try moving google() ABOVE jcenter().
Can't compile my android project because of this error.
/BaseGameUtils/src/main/java/com/google/example/games/basegameutils/GameHelper.java
Error:(32, 39) error: package com.google.android.gms.appstate does not exist
Error:(293, 28) error: cannot find symbol variable AppStateManager
Error:(294, 30) error: cannot find symbol variable AppStateManager
Error:Execution failed for task ':BaseGameUtils:compileReleaseJava'.
Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
My gradle..
apply plugin:
'android-library' repositories
{
mavenCentral()
}
buildscript
{
repositories
{
mavenCentral()
}
dependencies
{
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
dependencies
{
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:+'
}
android
{
compileSdkVersion 21
buildToolsVersion '21.0.0'
defaultConfig
{
minSdkVersion 14
targetSdkVersion 23
}
productFlavors { }
}
I see that you have not specified the goggle play services library.
Instead of this
compile 'com.google.android.gms:play-services:+'
Try this
compile 'com.google.android.gms:play-services:7.8.0'
Note: You might have a different version so instead of 7.8 enter that.
Bump, in my case I was using too high version:
compile "com.google.android.gms:play-services:10.2.1"
I changed it to:
compile "com.google.android.gms:play-services:7.+"
It worked but I have no idea why isn't appstate included in versions above 7
Firstly you should check that /extras/google/google_play_services/libproject/google-play-services_lib> is exist.
Secondly you add code in build.gradle
compile 'com.google.android.gms:play-services:5.+'
You are missing the com.google.android.gms.appstate package. you should add this to your app. for that add compile 'com.google.android.gms:play-services:5.+' to your build.gradle(Module:app).
Good day, i am following this tutorial http://ddewaele.github.io/GoogleMapsV2WithActionBarSherlock/part5 where you have to use HttpTransport but for some reason, android-studio does not seem to find it. I have imported the libraries (some even unnecessary) that are needed but no success. here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:4.+'
compile 'com.google.http-client:google-http-client-android3:1.9.0-beta#jar'
compile 'com.google.http-client:google-http-client:1.17.0-rc#jar'
compile 'com.google.http-client:google-http-client-android:1.17.0-rc#jar'
compile 'com.google.code.gson:gson:2.1#jar'
compile 'com.fasterxml.jackson.core:jackson-core:2.1.3#jar'
compile 'org.codehaus.jackson:jackson-core-asl:1.9.4#jar'
compile 'com.google.code.findbugs:jsr305:1.3.9#jar'
compile 'com.google.protobuf:protobuf-java:2.2.0#jar'
compile 'com.google.http-client:google-http-client:1.10.3-beta#jar'
compile 'com.google.http-client:google-http-client-android2:1.10.3-beta#jar'
compile 'com.google.http-client:google-http-client-android3:1.10.3-beta#jar'
compile 'com.google.http-client:google-http-client:1.10.3-beta#jar'
compile 'com.google.api-client:google-api-client:1.10.3-beta#jar'
compile 'com.google.api-client:google-api-client-android2:1.10.3-beta#jar'
compile 'com.google.oauth-client:google-oauth-client:1.11.0-beta#jar'
compile 'com.google.guava:guava:11.0.1#jar'
}
anything am not importing or what could be wrong?.. many Thanks in Advance.
Though late, still writing wondering if can help other developers...
The HttpTransport class resides in google-http-client jar. As you have added this dependency in the build.gradle file as shown above, I guess either you don't have network connectivity or your gradle settings is set to offline.
You can download the jar files form https://developers.google.com/api-client-library/java/google-http-java-client/download Unzip the zipped file. Copy the required jar files to the project libs directory & add them as library.
I'm trying to add a library as a dependency but it keeps giving me this error:
Class android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat.AccessibilityServiceInfoIcsImpl
has already been added to output. Please remove duplicate copies.
Execution failed for task ':BrooklynTech:dexDebug'.
Could not call IncrementalTask.taskAction() on task ':BrooklynTech:dexDebug'
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
dependencies {
compile files('libs/Simple-Rss2-Android.jar')
compile 'org.jsoup:jsoup:1.7.3'
compile 'uk.co.androidalliance:edgeeffectoverride:1.0.1'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile project(':libraries:calendar-card')
compile 'com.twotoasters.jazzylistview:library:1.0.0' }
the dependency I added was for jazzylistview - https://github.com/twotoasters/JazzyListView
How can I fix the error?
More than one of your dependencies is including the classes from the v4 support library; you'll need to track it down. You ought to be able to open up the jar files from the project viewer and find the culprit.
Ideally none of your dependencies ought to be bundling the support library; it's the responsibility of your app's build to make sure that gets finally linked in.
Not sure, but could you try the following snippet. Maybe the transitive libs are causing the trouble
dependencies{
...
compile ('com.twotoasters.jazzylistview:library:1.0.0'){
transitive = false
}
}
cheers,
René
I have two projects. DataModel and my application.
My application starts successfully but then fails with classnotfoundexception. Cant find DataModel project.I used to have the same problem before but I could fix it by updating gradle files although randomly android studio would screw them
DataModel build.gradle
apply plugin: 'java'
MyApplication build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'com.android.support:gridlayout-v7:18.0.0'
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.squareup.okhttp:okhttp:1.2.1'
compile 'com.squareup.retrofit:retrofit:1.2.2'
compile project(':DataModel')
}
MyApplication settings.gradle
include ':MyApplication ', ':DataModel'
Have you tried to clean the project? Build--> Clean
There is actually a known issue about something like that, maybe it's enough if you update to 0.3.6.
https://code.google.com/p/android/issues/detail?id=62011