I'm trying to add TwitterCore Kit to my android app. I used this in my project level build.gradle:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.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 this in app level build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.abhishek.cleartaxtask"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':volley')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile('com.twitter.sdk.android:twitter-core:1.6.6#aar') {
transitive = true;
}
}
When I sync gradle an error occurs buildToolsVersion is not specified. What am I doing wrong? How to add twitter sdk?
You have to remove these lines from your Build.Gradle (Project:cleartaxtask). You are using the Wrong Gradle to apply the plugins.
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
Also move these lines in your Build.Gradle (Module:app).
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
EDIT 1
For CrashLytics Error add this to your Dependencies.
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
For those who face same problem, add maven dependency at root(project) level build.gradle file.
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
} }
Related
When I open a this android project but when it wants to build a project it said this
The point is that I have never changed my gradle files.
I've invalidated caches and restart Android Studio.
But it didn't work.
I have no idea what caused this problem. Anyone here can help me?
here's the log:
org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:processDebugGoogleServices'.
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugGoogleServices'.
Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected ':' at line 1 column 11 path $.please
at com.google.gson.internal.Streams.parse(Streams.java:60)
at com.google.gson.JsonParser.parse(JsonParser.java:84)
at com.google.gson.JsonParser.parse(JsonParser.java:59)
at com.google.gms.googleservices.GoogleServicesTask.action(GoogleServicesTask.java:163)
Caused by: com.google.gson.stream.MalformedJsonException: Expected ':' at line 1 column 11 path $.please
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1568)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:530)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:700)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:723)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:698)
at com.google.gson.internal.Streams.parse(Streams.java:48)
gradle.build file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
//apply plugin: 'android-apt'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.st.jobportal"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha01'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.code.gson:gson:2.8.6'
}
apply plugin: 'com.google.gms.google-services'
Try this:
(Project Level)
buildscript {
repositories {
google() // Google's Maven repository
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
allprojects {
repositories {
google() // Google's Maven repository
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
(Module level)
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
//apply plugin: 'android-apt'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.st.jobportal"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha01'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.code.gson:gson:2.8.6'
}
apply plugin: 'com.google.gms.google-services'
I think you don't need Fabric because you don't use Crashlystics nor Fabric.
If it fails, then Invalid & Clean. If it's successful then, only the way you can try is
Just Remove all Fabric dependencies mean :
remove apply plugin: 'com.google.gms.google-services'
remove apply plugin: 'io.fabric'
3.remove
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
4.remove
repositories {
maven { url 'https://maven.fabric.io/public' }
}
After all, steps make the project and all things be fixed!
I'm trying to use Kotlin in a library module without using it in the app module. The app module only uses Java and does not use any Kotlin classes from the library. Gradle won't compile hoever:
Error:(2, 1) A problem occurred evaluating project ':<Library>'.
> Plugin with id 'kotlin-android' not found.
Changes I made to include Kotlin:
{library root} / build.gradle
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
}
allprojects {
repositories {
jcenter()
}
}
{library root} / {library module} / build.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
...
dependencies{
...
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
When I add the same to the app module, the project compiles without issue, but I'd like to avoid adding it in the app module because I'd like to use this library in multiple apps without making code changes to those apps
Gradle version used : 3.3
android gradle plugin version: 2.3.3
Edit: #Jushua's answer works, but it still requires to update the project root build.gradle. I was hoping for a solution where only the dependency on the library would have to be added to make the whole thing work.
I am able to do that without any problem.
build.gradle (Project)
buildscript {
ext.kotlin_version = "1.1.4"
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:2.3.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
build.gradle (app)
apply plugin: "com.android.application"
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
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 {
compile fileTree(dir: "libs", include: ["*.jar"])
androidTestCompile("com.android.support.test.espresso:espresso-core:2.2.2", {
exclude group: "com.android.support", module: "support-annotations"
})
compile "com.android.support:appcompat-v7:26.0.1"
testCompile "junit:junit:4.12"
compile project(path: ":library")
}
build.gradle (library)
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 17
targetSdkVersion 26
versionCode 13
versionName "1.1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
androidTestCompile("com.android.support.test.espresso:espresso-core:2.2.2", {
exclude group: "com.android.support", module: "support-annotations"
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "com.android.support:appcompat-v7:26.0.1"
testCompile "junit:junit:4.12"
}
You just need to add in your module build:
buildscript {
// (Optional) ext.kotlin_version = '1.1.4-3'
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
and you could either declare the kotlin_version variable in that specific build, or declaring it in the project root build file, since the kotlin version could be updated from other modules:
buildscript {
ext.kotlin_version = '1.1.4-3'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You can add buildscript section with kotlin plugins only in your library:
buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
And now you can include library to application, without modification of root build.gradle
compile project(path: ":library")
Right now I am trying to integrate Fabric with Crashlytics (https://docs.fabric.io/android/fabric/integration.html) into an existing android application.
Following the integration instructions provided by Fabric I add apply plugin: 'com.android.application' to the root directory of my "build.grade (Project.NumenuApp)" file. I click to Sync Gradle, it fails, and I receive this error Error:Cause: buildToolsVersion is not specified. Android studio states that my plugins should be declared at the Module not Project level.
I already have the buildTools set in the "build.grade (Module:app)" file. My question is why is this happening and what can I do to remedy it? I have posted my code below. Thanks in advance. - Adrian
build.grade (Project:NumenuApp)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
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
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.grade (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.numenu.numenuapp"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
You have to remove these lines from your build.gradle (Project:NumenuApp). You are using the wrong file to apply the plugins.
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
Also move these lines in your build.gradle (Module:app)
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
this is my build.gradle(Module:app) file and I have a working CrashLytics, and I have nothing related to fabrics in my project.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.ws.cs"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
packagingOptions {
exclude "/lib/arm64-v8a/librealm-jni.so"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.code.gson:gson:2.2.2'
compile 'io.realm:realm-android:0.82.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
}
Please check this line in your app.gradle present or not
buildToolsVersion "25.0.3"
Example
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "kc.care.task"
minSdkVersion 20
targetSdkVersion 25
versionCode 23
versionName "3.7"
multiDexEnabled = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
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'm trying to update the google play services lib from 6.5.87 to 7.5.0 but after change the android version at the build.gradle:
I'm getting the following error:
I had read that this error is related to appcompat but I'm not using or including this lib.
This is my complete build.gradle:
import java.util.regex.Pattern
buildscript {
repositories {
mavenCentral()
// Configuration for Fabric
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// 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'
apply plugin: 'io.fabric' // Fabric Gradle plugin, always after Android plugin
dependencies {
// 'jar' files in '/libs' folder
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.android.gms:play-services:6.5.87'
// Fabric
compile('com.crashlytics.sdk.android:crashlytics:2.+#aar') {
transitive = true;
}
}
repositories {
mavenCentral()
// Configuration for Fabric
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
Your mistake is u have changed Project label Gradle instead of App label.
Solution:
Put compile 'com.google.android.gms:play-services:6.5.87'
is App Label Gradel file put apply plugin: 'com.google.gms.google-services' as well.
Similarly
in Project label Gradle file put
classpath 'com.google.gms:google-services:1.3.0-beta1'
Example:
app Gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.appifiedtech.androidgoogleplusapi"
minSdkVersion 15
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.2.1'
compile 'com.google.android.gms:play-services:7.5.0'
}
Project Label Gradle:
// 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:1.2.3'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}