Creating a Firebase Push Notification application in android studio. i did everything and searched everywhere but i could not get any solution. i am getting this same error again and again. Let me post my Gradle files code. please i desperately need help.
Program type already present: com.google.android.gms.common.AccountPicker
and some times
Program type already present: com.google.android.gms.maps.CameraUpdate
here is my app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.Package.Myapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile("com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion"
compile "com.google.firebase:firebase-messaging:$rootProject.ext.gmsVersion"
compile "com.google.android.gms:play-services-vision:$rootProject.ext.gmsVersion"
compile "com.google.android.gms:play-services-maps:$rootProject.ext.gmsVersion"
testCompile "junit:junit:$rootProject.ext.junitVersion"
}
apply plugin: 'com.google.gms.google-services'
And here is my project gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
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()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext{
// Sdk and tools
minSdkVersion = 15
targetSdkVersion = 26
compileSdkVersion = 26
buildToolsVersion = '26.0.2'
// App dependencies
gmsVersion = "11.0.0"
supportLibraryVersion = '27.0.2'
guavaVersion = '18.0'
junitVersion = '4.12'
mockitoVersion = '1.10.19'
powerMockito = '1.6.2'
hamcrestVersion = '1.3'
runnerVersion = '0.5'
rulesVersion = '0.5'
espressoVersion = '2.2.2'
constraintLayoutVersion = "1.0.2"
}
its a simple webview wrapper application. and i am trying to implement Firebase push notification service on it.
On your project gradle file try replace this line
classpath 'com.google.gms:google-services:3.0.0'
with this:
classpath 'com.google.gms:google-services:3.2.0'
Also you may try to update these versions:
buildToolsVersion = '27.0.3'
supportLibraryVersion = '27.1.1'
I have next issue during the project building process: build process just stuck on app:kaptDebugKotlin task.
My root project build.gradle:
apply plugin: "kotlin"
buildscript {
ext.kotlin_version = '1.1.2-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
ext {
buildToolsVersion = '25.0.2'
supportLibVersion = '25.3.1'
runnerVersion = '0.5'
rulesVersion = '0.5'
espressoVersion = '2.2.2'
archLifecycleVersion = '1.0.0-alpha1'
archRoomVersion = '1.0.0-alpha1'
}
and the app build.gradle itself:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 25
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.test.roomtest"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile "io.reactivex.rxjava2:rxandroid:2.0.1"
compile "android.arch.persistence.room:runtime:${rootProject.archRoomVersion}"
compile "android.arch.persistence.room:rxjava2:${rootProject.archRoomVersion}"
kapt "android.arch.persistence.room:compiler:${rootProject.archRoomVersion}"
}
repositories {
mavenCentral()
}
I tried to use different plugin versions but it didn't help. As for using Room seems it's not a problem because this example builds without problems. Will be very appreciate for any help.
Is this still an issue?
The same problem for me was resolved by just using the newest kotlin - 1.3.60.
I use this library and want to increase targetSdkVersion to 24 and want to make this change by adding to top level build.gradle file how can I do this?
I changed build.gradle file to this, but it gives me: cannot find AndroidManifest
// 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.2.2'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.2'
defaultConfig {
minSdkVersion 9
targetSdkVersion 24
versionCode 1411005
versionName "14.1.1-RC-5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
}
}
allprojects {
repositories {
jcenter()
}
}
Add Top-level build file where you can add configuration options common to all sub-projects/modules.
Add following in build.gradle(project root) file.
ext {
configuration = [
appName : "app_Name",
applicationId : "com.xx.xxx.app",
minSdkVersion : 14,
targetSdkVersion : 24,
compileSdkVersion: 24,
versionCode : 6,
versionName : "1.3.6",
buildToolsVersion: "23.0.3",
]
libraries = [
supportVersion: "24.2.1"
]
}
In modules
def appConfig = rootProject.ext.configuration;
def libs = rootProject.ext.libraries;
dependencies {
compile project(':multiselect')
compile "com.android.support:appcompat-v7:${libs.supportVersion}"
}
For example
Root gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
configuration = [
appName : "app name",
applicationId : "com.xx.xx.app",
minSdkVersion : 14,
targetSdkVersion : 24,
compileSdkVersion: 24,
versionCode : 6,
versionName : "1.3.6",
buildToolsVersion: "23.0.3",
]
libraries = [
supportVersion: "24.2.1"
]
}
buildscript {
repositories {
jcenter() // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
task checkstyle(type: Checkstyle) {
showViolations = true
configFile file("../config/checkstyle/checkstyle.xml")
source 'src/main/java'
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
// empty classpath
classpath = files()
}
}
task clean(type: Delete) {
delete(rootProject.buildDir)
}
App Gradle
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
def appConfig = rootProject.ext.configuration;
def libs = rootProject.ext.libraries;
android {
compileSdkVersion appConfig.compileSdkVersion
buildToolsVersion appConfig.buildToolsVersion
defaultConfig {
applicationId appConfig.applicationId
minSdkVersion appConfig.minSdkVersion
targetSdkVersion appConfig.targetSdkVersion
versionCode appConfig.versionCode
versionName appConfig.versionName
signingConfig signingConfigs.config
}
buildTypes {
release {
}
debug {
}
}
productFlavors {
}
}
dependencies {
compile project(':multiselect')
compile "com.android.support:appcompat-v7:${libs.supportVersion}"
compile "com.android.support:cardview-v7:${libs.supportVersion}"
compile "com.android.support:recyclerview-v7:${libs.supportVersion}"
compile "com.android.support:design:${libs.supportVersion}"
}
Module Gradle
apply plugin: 'com.android.library'
def appConfig = rootProject.ext.configuration;
def libs = rootProject.ext.libraries;
android {
compileSdkVersion appConfig.compileSdkVersion
buildToolsVersion appConfig.buildToolsVersion
defaultConfig {
minSdkVersion appConfig.minSdkVersion
targetSdkVersion appConfig.targetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile "com.android.support:appcompat-v7:${libs.supportVersion}"
compile "com.android.support:design:${libs.supportVersion}"
}
For more about Configure Your Build
You can also try this.
TOP level build gradle
ext {
androidCompileSdkVersion = 25
androidBuildToolsVersion = '25.0.1'
androidMinSdkVersion = 14
androidTargetSdkVersion = 25 }
ext {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
supportLibraryVersion = '25.0.1'
retrofitVersion = '2.3.0'
okhttpVersion = '3.6.0'
parcelerApiVersion = '1.1.9'
daggerVersion = '2.5'
butterknifeVersion = '8.7.0'
dependencies = [
appCompat : "com.android.support:appcompat-v7:$supportLibraryVersion",
recyclerView : "com.android.support:recyclerview-v7:$supportLibraryVersion",
cardView : "com.android.support:cardview-v7:$supportLibraryVersion",
designSupport: "com.android.support:design:$supportLibraryVersion",
support : "com.android.support:support-v4:$supportLibraryVersion",
retrofit :
"com.squareup.retrofit2:retrofit:$retrofitVersion",
retrofitConverterGson: "com.squareup.retrofit2:converter-gson:$retrofitVersion",
retrofitAdapterRxJava: "com.squareup.retrofit2:adapter-rxjava:$retrofitVersion",
retrofitLogging : "com.squareup.okhttp3:logging-interceptor:$okhttpVersion",
rxAndroid : 'io.reactivex.rxjava2:rxandroid:2.0.1',
rxJava : 'io.reactivex.rxjava2:rxjava:2.1.0',
rxBinding : 'com.jakewharton.rxbinding:rxbinding:0.4.0',
butterknife : "com.jakewharton:butterknife:$butterknifeVersion",
butterknifecompiler : "com.jakewharton:butterknife-compiler:$butterknifeVersion",
] }
APP level build gradle
android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
buildToolsVersion rootProject.ext.androidBuildToolsVersion
defaultConfig {
applicationId "com.developerandroid"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
Map<String, String> dependencies = rootProject.ext.dependencies
//support
compile dependencies.appCompat
compile dependencies.recyclerView
compile dependencies.cardView
compile dependencies.designSupport
compile dependencies.support
// retrofit
compile dependencies.retrofit
compile dependencies.retrofitConverterGson
compile dependencies.retrofitLogging
compile dependencies.retrofitAdapterRxJava
// rx
compile dependencies.rxJava
compile dependencies.rxAndroid
compile dependencies.rxBinding
}
I'm trying to implement NDK in Android Studio and I have some problem with implementation:
I'm using Android Studio 2.0 Preview 3b, this is gradle file
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "lala.lala"
minSdkVersion = 16
targetSdkVersion = 23
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
}
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:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.google.android.gms:play-services-appindexing:8.3.0'
}
And this:
// 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.3.0'
classpath 'com.android.tools.build:gradle-experimental:0.3.0-alpha5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have problem with Gradle:
Error:Unable to load class'com.android.build.gradle.managed.ProductFlavor_Impl'.
I have tried to resolve this error but unsuccessfully.
SOLUTION:
I have solved this problem, this two lines are problematic:
minSdkVersion.apiLevel = 16
targetSdkVersion.apiLevel = 23
And I have change this lines to this two:
minSdkVersion.apiLevel = 16
targetSdkVersion.apiLevel = 23
And this problem was resolved but there is some additionial problem which I resolve by adding: multiDexEnabled = true
in defaultConfig
I have the problem:
Error:(19, 0) Gradle DSL method not found: 'android()'
-The project 'x' may be using a version of gradle thet does not contais the method
Open gradle wrapper file
-The build file may be missing a gradle plugin
Apply gradle plugin
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()
}
}
android {
buildToolsVersion '23.0.0'
}
dependencies {
}
app.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
compileOptions {
encoding "UTF-8"
}
defaultConfig {
applicationId "es.albertoramos.pfcalbertoramos"
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'
}
How fix this problem?
Delete:
android {
buildToolsVersion '23.0.0'
}
dependencies {
}
from your top-level build.gradle.