When I create a new project in android studio, at first every thing is o.k and it runs on my mobile phone. But if I press the sync button then a terrible error(which I afraid of and hate it) is appeared: "Plugin with id 'com.android.application' not found". I search and read all answers related to this error and do every thing. But my problem is also remained.
Here is my build.gradle(module.app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.masood.pietest"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
and here is my build.gradle(project):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha09'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Really, I don't know what I need to do...
Could anyone help me?
After 3 days of trying to solve my above problem and searching and examining very solutions, I found that the problem raised from my "Android Plugin" version. So, if this problem occurs for every one especially for those who are new to android studio, before all, try to use from an appropriate version of "Android Plugin" which adjust with "Gradle version". To do this it's enough to look at this address: https://developer.android.com/studio/releases/gradle-plugin.html#updating-plugin and https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle.
For example, my Gradle version is "gradle-4.4" which requires at least to Plugin version "gradle:3.1.0". My Plugin version (when I had the above problem was gradle:3.1.0-alpha09) and the Sync process was encountering with error. So I change it to : "gradle:3.1.0" and now it works very well.
Notice:For checking your "gradle version" please go to the below directory on your application:
Gradle Scripts -> gradle-wrapper.properties
and for "plugin version" go to: Gradle Scripts -> build.gradle(Project:...) (NOT: build.gradle(app:...))
I hope this answer be useful for every one who have the same problem.
Related
I have a mobile app written using Ionic Angular. My Ionic version is 5. I build it with Capacitor.
I have added Admob Free plugin to my app and the ad implementation is working fine. Later I wanted to integrate push notifications into my app, so that I decided to go with FCM plugin.
Now when I open the android platform of the project in Android Studio, I get the below error in build console. Note that I have placed the google-services.json file in the correct place.
Cannot add extension with name 'googleServices', as there is an
extension already registered with that name.
app -> build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "my.app.id"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url "https://dl.bintray.com/ionic-team/capacitor"
}
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation project(':capacitor-android')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':capacitor-cordova-android-plugins')
}
apply from: 'capacitor.build.gradle'
apply plugin: 'com.google.gms.google-services'
Project level -> build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
As I think, Admob plugin internally uses the google services plugin and when FCM plugin tries to add the same plugin this error occurs. Correct me if I am wrong.
Anyway, can someone please help me to resolve the issue.
Thank you..!
i try to implementation an android external library in flutter plugin let's called myPlugin. But i have no idea how to build build.gradle which has implementation of external library. i tried run main project that depend on myplugin. but still i cannot call any api of external library here's myplugin build.gradle :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
implementation 'com.android.support:support-v4:26.1.0'
}
when i try to import android.support.v4...ActivityCompat, it's called cannot resolve symbol. please tell me how to do the right way. thanks
There are 2 build.gradle files.
The one in your android folder is the project-level build.gradle. You usually do not edit it.
The one in your android/app folder is the app/module-level build.gradle. Place your dependencies in this file.
Thanks. i solve it .
Open in android studio Project/android
and wrapping with gradle.
thanks
I am building an application that uses the google maps api.The first activity of the application is a maps activity, which refuses to run based on the error I stated in the title.
I have heavily modified my build.gradle trying to fix the problem; based on other solutions I found on this website.
But I think I may have made it worse: This is what my build.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.navigation.dixongardens.ben.bensgardens"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
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')
compile 'com.android.support:appcompat-v7:28.0.0-alpha1'
compile 'com.google.android.gms:play-services-maps:11.6.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
// androidTestImplementation 'com.android.support.test:runner:1.0.1'
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.maps.android:android-maps-utils:+'
compile 'com.google.android.gms:play-services:11.8.+'
compile 'com.android.support:design:26.0.0-alpha1'
}
Can someone help guide me as to what is wrong with my build.gradle? I am confused as to which dependencies are required for google services to work properly.
It's not an issue with your app, but an issue with your emulator. You need to update the emulator you are running / download a new system image and create an emulator from that.
The exception is telling you that Google Maps expects a newer version of Google Play Services than what is currently running on your device. Sometimes it will have a link to update google play services under the notification. (in the app on the google map view)
You don't need to do anything, only you need to click notification showing above message. Then google play service will be updated automatically. Easy
I'm not able to import com.google.android.gms.iid.InstanceID into my code is it a library problem or should i need to update the library, since instanceID is available and many have implemented using the same.
I had this issue as well, and it ended up being that I had an older version of the android sdk tools. Getting the newest version from the developer website and installing the Google Play Services library again solved the issue.
I too had the same issue. Got it resolved by compiling with the latest sdk tool versions.(Play services,build tools etc). Sample build.gradle is shown below for reference.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.abc.bcd"
minSdkVersion 14
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'])
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:23.0.1'
}
enter code here
I have the latest Android Studio running and I also made it to run my first app without any problem.
Then I wanted to add gson library to use in my project but I must have done something wrong because since then my ap does not work any longer since this import fails:
import android.support.v7.app.ActionBarActivity;
I have also added this now for gson in my gradle file:
dependencies {
compile 'com.google.code.gson:gson:2.3.1'
...
I did:
Invalidate cache and restart
delete my .gradle folder
But nothing works.
Do you have any idea what I might have mixed up?
Thanx for your help!!!
These are the files:
Build.gradle project:
// 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.0.0-rc4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "xxxxx"
minSdkVersion 10
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.code.gson:gson:2.3.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:support-v4:21.0.2'
}
The error that comes is "Cannot resolve symbol 'ActionBarActivity'"
After a gradle sync it looks fine but when I then try to run my project, that ActionBarActivity s again not recognized ... but it was before...
#
Now I have deleted the .iml file and the .idea folder and re-imported my project.
It looks good but now Android Studio is unable to install the .apk on my device when I want to run it:
Failure [INSTALL_FAILED_INVALID_APK]
(so I opened a new question...)