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!
Related
I'm trying to connect firebase to my app for the cloud messaging services. I made all the changes needed in gradle files that docs mentioned.
here are my grade files:
Project Level:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
compose_version = '1.1.0-beta01'
}
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven {url "https://maven.google.com"}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31'
classpath 'com.google.gms:google-services:4.3.14'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
}
}
Module Level:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.codax.codax_app"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_9
targetCompatibility JavaVersion.VERSION_1_9
}
buildToolsVersion '32.1.0-rc1'
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'junit:junit:4.13.2'
implementation 'androidx.test.ext:junit:1.1.3'
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.google.firebase:firebase-messaging:23.1.1'
}
When I sync gradle files I get no error but when trying to import firebase like this:
import com.google.firebase.messaging.FirebaseMessagingService;
i get this error : Cannot resolve firebase
I tried cleaning and invalidating the cache(i use android studio) and resyncing gradle files but nothing helped.
and there is no other path that contains the firebase classes.
What am i doing wrong here? thanks in advance.
in my ionic react project android version build using capacitor, i followed the steps of removing all the fabric and replacing them with crashlytics
reference: https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android
the build command:
ionic cap copy android
ionic cap open android
now I am just getting the error when building:
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'io.fabric' not found.
here's my project build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply from: "variables.gradle"
ext {
var = '4.1.1'
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and here's my app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// firebaseCrashlytics {
// nativeSymbolUploadEnabled true
// }
}
}
}
repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
version reference:
android studio: 1.4
android gradle plugin version: 4.1.1
gradle version: 6.6
when installing firebase don't install "cordova-plugin-firebase" if you are using react with ionic, it will create this error! fixed after removed
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")
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' }
} }
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.+'
}
}