Exception: Unsupported Android Plugin version: 4.1.2 - flutter

I know this might have been asked before, I have recently installed Solus Linux on my computer and I am trying to get Andoird Studio working on it for some time, so far I am not having any luck.
First Issue - I am not able to add Flutter to the PATH
Second Issue - I am getting this error when running the project
Could somebody here help me with both issues?

Maybe it can help future devs. I had similar problem with the exception
Unsupported Android Plugin version 4.1.3
In my case I had to specify build flavor for the app:
flutter run --flavor <flavor-name>
then it worked

I think at the moment, there is a problem of incompatible version.
Reference: from this thread
To fix it, I revert back Android Plugin from 4.1.2 to 4.1.0.
Modify the root build.gradle:
buildscript {
ext.kotlin_version = '1.4.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
}
}
Note: I, currently, use Gradle 6.7

Doing this solved my problem
Added dev as Build flavor
Added --debug as Additional build args

In my case, I had to edit my configuration settings:
go to "Edit configurations"
choose the config you're trying to run
fill in the "Build flavor" accordingly
Worked for me

if your are performing integration test in flutter with flavors then you should run this command to test
flutter drive --flavor dev \ --driver=test_driver/integration_driver.dart \ --target=integration_test/login_page/login_integration_test.dart

For me, it was about the flavor configuration. I have main, develop, and production flavors I haven't set up configuration for main so when main is selected this error is happened

In my case, I solved it by changing the "splits" property to enable = false, in the build.gradle. When we release to production that property is set to true, so i just forgot to set it on false again.
Should be something like this:
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable false
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include 'arm64-v8a', 'armeabi-v7a'
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}

Related

How to enable Multidex inside flutter which is added to existing android project as module

I have and android project, which I added flutter on it as module,
In my original android app, multidex is enabled, but this do not help me, when running the app in debug it's working normally, but when creating a release apk or even debug apk the FlutterFragment is appearing as white, like the engine did not attach.
Things I notice, 'flutter run --release' will ask me to support multidex, and will not run, updating the minSdkVersion to 21 and enabling multidex in .android/app/build.gradle then again 'flutter run --release' works perfect, but this have no effect on the host app because it's under .android which automatically build, and ignored by the host app.
Also I tried to search for how to update minSdkVersion to 21 instead of 16, but references lead to change in the .android which have no effect.
Hey you can do two thing
Update your flutter SDK version by running command
flutter upgrade
The new version of flutter(2.10) multidex support automatically.
simply pass the --multidex flag to flutter build appbundle or flutter build apk and your app will support multidex.
2.In your app folder inside android [project_folder]/app/build.gradle and add following lines.
defaultConfig {
...
multiDexEnabled true
}
and
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
After a lot of investigation, the reason was related to something in the entry point, which needed to add project name, referring to this link

No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi

I was working on a Flutter project and everything was working fine until I updated My Android Studio and some of the SDK tools. Then when I was trying to run my project, I was getting the Error below:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at [https://help.gradle.org](https://help.gradle.org)
BUILD FAILED in 1m 4s
Exception: Gradle task assembleDebug failed with exit code 1
So what have gone wrong? What should I do?
The main reason is that NDK 23 has different toolchain than the previous versions of NDK (22-), so the old version of AGP (Android Gradle Plugin) has not idea where to find the executables for different ABIs.
For me, simply update the AGP version in the build.gradle in your Android project root to 4.0+, such as
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
...
This will resolve the problem.
Note: You will need to set the environment variable ANDROID_NDK_HOME to your NDK 22- location, even Google's document does not require that or says it is deprecated.
If you want to stick to the current version of AGP, there is another work around, simply add this
android {
android.ndkVersion "21.4.7075529" // (or whichever NDK 22- version you have installed)
...
to your module's build.gradle (not the build.gradle of your project)
Some other ways to work around this can be found here, Configure the NDK for the Android Gradle plugin
Well I solved the issue in 2 different ways:
A. I downgraded my NDK from version 23.0.7123448 to 22.0.7026061 by simple steps below:
1.Open SDK Manager from tool bar of android studio or from settings menu (File --> Settings --> Appearance and Behavior --> System Settings --> Android SDK).
Select the SDK Tools tab and from the Bottom Right of the window check the Show package details. Then simply uncheck any version you want to delete and select Apply.
(For me removing version 23.0.7123448 and get to 22.0.7026061 solved the problem. But if you are still having the Error above try to lower the NDK version. The most stable NDK version is 20.1.5948944)
If you have done all the steps before, you will see the following window popping up. Hit OK and you are all set.
B. This approach might look simple but yet it does the trick. Simply create a new Flutter project and get all you work (lib folder, assets, etc) to the new project.
Environment
OS : Big Sur 11.1
npm 7.24.0
node v14.15.5
react-native-cli: 2.0.1
react-native: 0.63.4
Command
react-native run-android
Error
*What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
Fix
Checking Android SDK Tools, NDK (side-by-side):
In the android toolbar go to:
Tools >> SDK Manager
![Tools-SDK][1]
Then in the popup aside navigation go to:
Appearance & Behavior >> System Settings >> Android SDK

Click “SDK Tools”
Check the box next to show package details

Solution:
Downgrade
References
Idea for downgrade: Taba's solution
Here's what worked for me
I updated AGP to 4.1+ in my Android Project root build.gradle
dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
...
AGP 4.1+ supports only gradle version gradle-6.5 above
so I updated the distributionUrl in gradle-wrapper.properties file located in gradle/wrapper folder
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Get more info here
what worked for me was
I change my Gradle dependencies from 3.5.1 to 4.0.1
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
}
which is under build.gradle
The minimum Gradle support for Gradle dependencies(gradle:4.0.1) is gradle-6.1.1
if your gradle version for the project is below that you will have to change it by downloading a higher version or if you have it and you're using a wrapper, you will have to change the distribution to the one higher or same as the 6.1.1 version.
which is under >gradle >wrapple >gradle-wrapple.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
You might most likely need to add to your NDK
for Gradle-6.7 the supported NDK is NDK(side by side) version 21.0.6113669
which is under >tools >sdk manager(android SDK) >sdk tools >ndk side by side
click show package details click and download the appropriate one for you
I clean all SDK folders in c:\Users\User\AppData\Local\Android\Sdk\ndk\
Recent AppCenter android dependencies changes caused my android builds to fail with this error:
No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
Our solution was to upgrade the gradle version from 3.5.4 to 4.0.1 in the root build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
Additional answer for #gwang and #TillyJonesy:
When running Gradle command with --info(AGP 3.5.4 for me), you will see that when no NDK version was given, AGP will try to use the highest NDK version.
And from the docs of Android NDK guidance, AGP <= 3.5 has no default NDK version.
See: https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp
Solution for native android developers
Go to File->Settings->Appearance & Behaviour->System Settings->Android SDK-> then select SDK Tools and check 'Show Package Details' from bottom.
in Dropdown of NDK(Side by Side) ,check 22.1.7171670 and uncheck remaining then apply and click ok.

Flutter - Overridden dependencies

After running "flutter pub get", I got this error:
Warning: You are using these overridden dependencies:
! path 1.6.4
That's not an issue. That happens because you (or any other transitive dependency) may be overriding some dependency that you are already using. For example, if you are using path: 0.X.X and some other dependency use dependency_overrides to make sure that is using path: 1.6.4, it will present you that message.
Overall, you shouldn't have to worry with that and sometimes it is actually required in order to some dependencies work all together.
Please give more details so that i can answer it better. Attach your pubspec.yaml.
But now i can tell you some methods which should work..
first of all see if you are using the latest version of all dependencies or not then:
try:
restarting your ide
flutter clean
if these two don't work then at last try
flutter pub cache repair
I encountered the same error after cloning a flutter repository. I initially mistook the error for being a build issue when it's just a warning that won't stop your app from running.
I solved the build issue I was having with the freshly cloned project by running this command inside the app's root directory: flutter pub run build_runner build

after installing ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated my android built not working

Error: Execution failed for task ':processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.+.
i want ionic cordova plugin cordova-plugin-fcm-with-dependecy-updated for notification but build is crash after installed this plugin if i remove this plugin then my app is working
i try to use fcm plugin with android 8.0.0 with cordova-plugin-googleplus 7.0.0 and i try with android 7.4.1 and 6.4.0 with cordova-plugin-googleplus 5.2.1
try this!..
step 1 ionic cordova platform rm android
step 2 go to /plugins/cordova-plugin-fcm-with-dependecy-updated/src/android/FCMPlugin.gradle
change like this
buildscript {
repositories {
mavenCentral()
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.google.gms:google-services:3.1.+'
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'com.google.firebase:firebase-core:11.4.2'
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
step 3 ionic cordova platform add android
step 4 Goto /platforms/android/project.properties
Change like the numbers into 11.4.2
cordova.system.library.3=com.google.firebase:firebase-core:11.4.2
cordova.system.library.4=com.google.firebase:firebase-messaging:11.4.2
cordova.system.library.7=com.google.android.gms:play-services-auth:11.4.2
cordova.system.library.8=com.google.android.gms:play-services-identity:11.4.2
demo project.properties file
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-26
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-plugin-badge/mobile-badge.gradle
cordova.system.library.2=com.facebook.android:facebook-android-sdk:4.25.0
cordova.system.library.3=com.google.firebase:firebase-core:11.4.2
cordova.system.library.4=com.google.firebase:firebase-messaging:11.4.2
cordova.gradle.include.2=cordova-plugin-fcm-with-dependecy-updated/mobile-FCMPlugin.gradle
cordova.system.library.6=com.android.support:appcompat-v7:25.+
cordova.system.library.7=com.google.android.gms:play-services-auth:11.4.2
cordova.system.library.8=com.google.android.gms:play-services-identity:11.4.2
cordova.gradle.include.3=cordova-plugin-local-notification/mobile-localnotification.gradle
cordova.gradle.include.4=cordova-plugin-telerik-imagepicker/mobile-ignorelinterrors.gradle
cordova.gradle.include.5=cordova-plugin-telerik-imagepicker/mobile-androidtarget.gradle
cordova.gradle.include.6=phonegap-plugin-barcodescanner/mobile-barcodescanner.gradle
cordova.system.library.11=com.android.support:support-v4:27.+
cordova.gradle.include.7=twitter-connect-plugin/mobile-twitter.gradle
cordova.system.library.12=com.squareup.okhttp3:okhttp:3.12.0
step 5 ionic cordova build android
Note :: Don't forgot to add google-services.json file in root directory, main_project/google-services.json
We have the same issue and yesterday we solve this problem with this answer:
Answer:1
This is due to the firebase updates on April 05. Here https://firebase.google.com/support/release-notes/android#update_-_april_02_2019, I found the last working versions and adjusted my project.properties accordingly like so
cordova.system.library.4=com.google.firebase:firebase-core:16.0.8
cordova.system.library.5=com.google.firebase:firebase-messaging:17.5.0
cordova.system.library.6=com.google.firebase:firebase-config:16.4.1
cordova.system.library.7=com.google.firebase:firebase-perf:16.2.4
Here all dependencies are locked to the specific version (Update - April 02, 2019) instead of +, which would get you the latest version thus breaking the build process.
Now I can build successfully! I hope it helps!
Ref: page
Answer: 2
A wonderful person opened a pull request 31 in the cordova-firebase-plugin official repo and it works.
Steps I did:
1 - Remove cordova-firebase-plugin with ionic cordova plugin remove cordova-
firebase-plugin
2 - Install: ionic cordova plugin add https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue
3 - rm -rf node_modules/ plugins/ platforms/android package-lock.json
4 - ionic cordova platform add android && npm install
5 - In my case, I also use a firebase js library in an old version because the newest ones are not working for me. With that library I always need to reinstall it manually after all the previous steps, so also I did: npm install firebase#4.12.1.
And now it’s working.
ref: Page
I'm a Korean who develops with Cordova
I solved as below.
cordova-plugin-admob-free and
Library conflict with cordova-plugin-fcm-with-dependecy-updated.
I changed only the ads version and ran it as shown below.
I am not sure if the content will be delivered using Google Translate.
enter image description here
/platforms/android/project.properties
cordova.system.library.1=com.google.firebase:firebase-core:16.0.9
cordova.system.library.2=com.google.firebase:firebase-messaging:18.0.0
cordova.gradle.include.1=cordova-plugin-fcm-with-dependecy-updated/helloworld-FCMPlugin.gradle
cordova.system.library.3=com.google.android.gms:play-services-base:11.0.4
cordova.system.library.4=com.google.android.gms:play-services-ads:17.0.0

Not able to sync dependency in build.gradle in flutter

I want to use some native library. and I am using below dependnecy
implementation 'com.google.android.gms:play-services-vision:10.+'
in build.gradle in flutter project.
How I will sync that dependency. Please help me!
If you're using Android Studio for Flutter development, right click on the android folder in your Flutter project. Select "Flutter" -> "Open Android Module in Android Studio".
Or
Simply start Android Studio and open the Android (sub)project directly.
In any case, once the Android project is opened in Android Studio, you can make changes in your build.gradle. The editor will tell you to sync. Otherwise simply execute a build. Afterwards you will be able to import use your Android classes.
That is the problem with gradle sync of Android project, not with Flutter dependencies.
In your build.gradle of your module (for example android/app/build.gradle of your Flutter project) add:
implementation 'com.google.android.gms:play-services-vision:10.+'
in dependencies as bellow:
dependencies {
implementation 'com.google.android.gms:play-services-vision:10.+'
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'
}
Then open terminal, cd to android folder of your flutter project and run:
$./gradlew build
After that you will be able import com.google.android.gms... in your Java class.
Go to android folder of your flutter project and then
open it in terminal by right clicking on that folder
then try to run below command
gradlew build
i know i am late but let me suggest the way as per i done and it's working , if it helps to someone
Open android studio flutter project
Go to file
Click on setting
Search for "Flutter"
at bottom of that view there is an experiments section do check that both checkbox
after doing this add any dependencies in android gradle and go to file and click on "Sync with file system" and you are done , please check the below screenshot to do check the experiments item
I managed to sync the dependencies using "Run Configurations". Please follow next screenshots:
Open Gradle tab.
Select path to Build.Gradle file.
Double click to sync.
For me it was the kotlin version being specified in the build.gradle, which wasn't in sync with the IDE's version. Changed it from ext.kotlin_version = '1.4.32' to ext.kotlin_version = '1.5.20'. Now it is syncing the gradle script again.