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
Related
I tried to integrate Appodeal into my Flutter Project using latest stack_appodeal_flutter 1.2.0 Package.
I followed their instruction still got this error. Appreciate any help.
this is my Android build gradle
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://artifactory.appodeal.com/appodeal" }
}
}
If you have added
dependencies {
...
implementation 'com.appodeal.ads:sdk:2.11.0.+'
...
}
this in your build.gradle (module: app), please remove that and run again. Their documentation in pub.dev is little misunderstanding.
it seems like a build or gradle setting error. Any thought of how to fix it?
[ +1 ms] e: Incompatible classes were found in dependencies. Remove
them from the classpath or use '-Xskip-metadata-version-check' to
suppress errors
This error will normally happen when the Kotlin version specified in your Android 'build.gradle' file is different from that bundled in Android Studio (or your preferred IDE in this case).
To solve it:
In Project Explorer of your Flutter project, navigate to android directory, and open build.gradle file.
NOTE: This is the overall 'build.gradle' file. Not the one inside the 'app' directory.
Your build.gradle file would look almost similar to the following snippet.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Your Kotlin version is marked by this line ext.kotlin_version = '1.3.50'.
This version needs to be same as the version of Kotlin bundled in the IDE. You can find the version of the bundled Kotlin by opening the 'Problems' tool window (can normally be found on the bottom left in Android Studio).
Update the version, and re-run the Flutter project.
Change kotlin version
buildscript {
ext.kotlin_version = "1.5.31"
check your kotlin version in warning section
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..!
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.
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...)