I have a problem with Twitter Kit SDK for Android, I need to import Twitter Kit SDK to a library (module) within my project (I'm using Android Studio). I am using Fabric Studio Plugin for Android, to support the implementation, but when implement as shown in the link https://dev.twitter.com/fabric/android/integrating in the library (module), the Gradle not finds and returns me the message "Could not find com.twitter.sdk.android:twitter:1.4.0", then when I implement in my app (module), the import is successful, I can not import through the gradle for a library?
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
}
compileSdkVersion 21
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile('com.twitter.sdk.android:twitter:1.4.0#aar') {
transitive = true;
}
compile project(':httplib')
}
I created a re-usable twitter component usig fabric
My working gradle look like below
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile('com.twitter.sdk.android:twitter:1.3.2#aar') {
transitive = true;
}
}
Once you updated your gradle make sure to sync gradle and finally rebuild the project.Worked well for me.
Related
I can't setup the updated version of firebase on android studio.
I've created json file of the project on the site firebase and copied it into the project and after coping lines in gradle:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
compile 'com.google.firebase:firebase-core:9.0.1'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
I get the following error:
failed to resolve: compile 'com.google.firebase:firebase-core:9.0.0'
How can I fix it?
I had the same problem. If you are using Android studio, you should then update google repository in SDK Manager.
Following is my build.grade(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "package name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.firebase:firebase-core:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
And this is my build.grade(project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Firebase is working based on Google Play Services. So please make sure you have the following sdk tools and they are updated to sync against the library versions of firebase that you are using.
SDK Tools installed for this project
Project level build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Module Level build.gradle file
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.devdeeds.firebaseauth"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
}
apply plugin: 'com.google.gms.google-services'
NOTE: This is a followup of my last question that still remained unsolved.
I'm using a fully updated AndroidStudio with the default gradle support.
Android Studio can self update (thus sees Internet for sure).
I have no reason to beleive that Gradle can't reach the internet nor any error that could imply that, and I verified that it's not on offline mode.
Here's my Here's my top-level build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
and here's my app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.domain.app"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.github.jitpack:android-example:1.0.4'
}
Here I'm trying to pull the jitpack.io sample, and still getting:
Error:(31, 13) Failed to resolve: com.github.jitpack:android-example:1.0.4
without any additional information.
try this :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Then in your app/build.gradle :
apply plugin: 'com.android.application'
repositories {
maven { url "https://jitpack.io" }
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.domain.app"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.github.jitpack:android-example:1.0.4'
}
Its not the problem of android studio, To inform you
Neither
compile 'com.github.jitpack:android-example:1.0.4'
Nor
compile 'com.github.User:Repo:Tag'
Both doesn't compile now, Because it's no longer available in the The Central Repository. You don't have any ways rather than seeing the codes inside.
I am trying to integrate Twitter Login in my app, according to Twitter Fabric docs I am to add
compile('com.twitter.sdk.android:twitter-core:1.6.0#aar') {
transitive = true;
}
to my code to be able to compile but the Gradle is failing to resolve the Library I am getting the
Error:(25, 13) Failed to resolve: com.twitter.sdk.android:twitter-core:1.6.0
Show in FileShow in Project Structure dialog
and here is my full gradle file
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "xxxx.xxxx.xxxx.xxxxx"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('com.twitter.sdk.android:twitter-core:1.6.0#aar') {
transitive = true;
}
}
I fixed it by modifying my build.gradle
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
// The Fabric Gradle plugin uses an open ended version to
// react quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
and ofcourse adding the
compile ('com.twitter.sdk.android:twitter:1.6.0#aar'){
transitive = true;
}
}
in my top level gradle file
I've got a project in Android Studio and I can't quite seem to figure out this gradle issue. My app structure is as follows:
app (module) relies on crashlib (module), crashlib relies on an AAR from an external repository which I have listed in crashlib's gradle file.
The problem is that when I go to compile the app the default repository (https://jcenter.bintray.com/) is used instead of the one defined in crashlib, so the build fails. If I add the repository definition from crashib to the app module then it builds successfully, but it's not ideal. I can also build crashlib successfully on its own.
Here is the crashlib build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.3#aar')
}
Any ideas how to get the repository to be used when building the app?
In your buildscript block you should use somenthing like this:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}
I am recently started to work on the Android Studio. When I am doing sync with gradle then it is giving me a error .
Error : Cause: android.compileSdkVersion is missing!
Guys what could be reason for this, I already have same compileSDKVersion and build tool installed. I see many threads that saying to confirm that you have same sdk version installed in your system but in my case it is already installed.
build.gradle
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}
I met this problem too, but I don't know whether my solution suit for you.
I just change the position of this script: apply from: 'maven_push.gradle' to the bottom in build.gradle file, and BUILD SUCCESSFUL!
I post my answer here, you can try it.: Building Android Studio project on Jenkins? android.compileSdkVersion is missing
I did this. It works on Android Studio 0.4.6:
/android_common.gradle
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:+'
}
allprojects {
apply plugin: 'idea'
repositories {
mavenCentral()
mavenLocal()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
}
def langLevel = 1.7
idea {
project {
jdkName = langLevel
languageLevel = langLevel
}
}
/app/build.gradle
apply plugin: 'android'
apply from: "${rootDir}/android_common.gradle"
android {
defaultConfig {
versionCode 1
versionName "1.0"
packageName "your.app.package.name"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
compile 'com.squareup.dagger:dagger:1.2.1'
compile 'com.squareup.dagger:dagger-compiler:1.2.1'
compile 'com.j256.ormlite:ormlite-android:4.+'
compile 'joda-time:joda-time:2.+'
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}
apply plugin: 'android-unit-test'
dependencies {
instrumentTestCompile 'junit:junit:4.+'
instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
testCompile 'junit:junit:4.+'
testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
}
If something is missing, and you have clearly declared it, it means that it was queried before it was defined. Move the query (code that requires that variable) somewhere lower, or to a later position in the sequence and it will be fixed.
try this :
apply plugin: 'android'
apply from: "${rootDir}/android_common.gradle"
move your apply from: "${rootDir}/android_common.gradle"
to last lines