Generate android App Bundle with x86 version - android

I use flutter to develop my app. However, to generate an app bundle and upload it to play console, I use Android Studio (Build -> Generate Signed Apk).
In flutter I have the option of generating three distinct apks for three architectures (arm, arm64 and x86(64?)) through flutter build commands. However when I generate signed app bundle from Android Studio and upload it play console, I only get two build variants or abi (arm64-v8a, armeabi-v7a). How do I make my app bundle include an x86 abi?
Additional: I only use Android Studio to generate App Bundle. I use VS Code to write these apps.
Edit: The module/App level build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.spayro.spayroshop"
minSdkVersion 21
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

The x86 architecture is not supported at this time.
https://flutter.dev/docs/deployment/android#what-are-the-supported-target-architectures

Please put this code in your gradle:
ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
example
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.test.test"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}

Related

"Exception: Gradle build failed" only for flutter project in AndroidStudio

My Flutter project works fine, I can build it as Android app with VisualStudio Code. With AndroidStudio I am able to build the Android app if I open only the android folder and build the Android app as android project.
But if I open the whole Flutter project in AndroidStudio and try to build it for Android (iOS works fine) I get this error:
Exception: Gradle build failed to produce an .apk file. It's likely that this file was generated under .../build, but the tool couldn't find it.
Seems like an IDE bug, is there anyone with a solution for me?
Android Studio version : Android Studio Electric Eel | 2022.1.1 (Build #AI-221.6008.13.2211.9477386, built on January 11, 2023)
Update:
app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
def flutterVersionName = localProperties.getProperty('flutter.versionName')
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
flavorDimensions "distribute"
productFlavors {
appCenter {
dimension "distribute"
}
googlePlay {
dimension "distribute"
}
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "myId"
minSdkVersion 21
targetSdkVersion 33
versionCode 3
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
You have no default flavor defined, so you need to specify flavor to build. From command line:
flutter run --flavor appCenter (or googlePlay)
In Android Studio, go to Run->Edit configurations and set flavor to build (in your case appCenter or googlePlay. You can also add new configuration to be able to swith between them to build different flavor.

Flutter App not installable from Google store for Android 12

I'am trying to start internal testing for my flutter App in the Google Play Console. It works for other devices except those with Android 12. On Android 12 I'm not able to install the App. But the App runs flawlessly on an Android 12 Emulator.
I've already followed the instructions at this question
Flutter App not installable from Google store for Android 12 despite being set to targetSDK 31. Because it didn't work either, I created a new clean Flutter project and uploaded it without changing anything. The result was the same: The app was downloadable on all devices except the ones with Android 12.
My build.gradle file:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 31
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "myAppId"
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Flutter doctor:
It worked now in Open testing after getting the app reviewed.
upgrade your projet to one of the most recents flutter versions, updgrade your dependancies and change all
<service></service>
tags in all your dependancies like below
<servive
....
android:exported="true">
</service>
in all AndroidManifest.xml files

Flutter App not installable from Google store for Android 12 despite being set to targetSDK 31

I have a Flutter App in the Playstore and if you have Android 12, it will just pop an Error Message:
"AppName cannot be installed"
My Flutter version is 2.5.0
I would expect the app to be installable on Android 12 because of my settings. Are there any òther reasons this could fail?
This is my build.grade:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '25'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
// apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "myAppID"
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
//signingConfig signingConfigs.debug
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//def multidex_version = "2.0.1"
//implementation 'androidx.multidex:multidex:$multidex_version'
implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
Flutter Doctor:
Installing this on an Android 12 Emulator, the install fails with this message:
After I did add this value as true to my appmanifest, I started it again and I have an endless install loading icon in visual studio code. I have the app on the device, but it will close immidiately after tapping on it
You have to set android:exported to any <activity>, <activity-alias>,<service>, or <receiver> components that have <intent-filter>s declared in the app’s AndroidManifest.xml file.
ALSO!!!!
You have to do the same for every package you use. I would advice NOT doing it manually as this could get modified by calling something like "Pub clear cache" and instead try to update your packages to the latest version.
https://medium.com/androiddevelopers/lets-be-explicit-about-our-intent-filters-c5dbe2dbdce0
When I was stuck for this issue, did not found anything helpful on the web: not many people seems to encountered this.
I tried creating fresh new flutter app, copying its /android folder to my old project; setting android:exported for in AndroidManifest.xml: none of helped for running my app on Android 12 device. (Also there were some Android 11 devices, all of them being SAMSUNG, that our app, of which target sdk was set to 31, could not be installed.
Finally setting targetSdkVersion as 30 and compileSdkVersion as 30, fixed the issue.
SDK version 30 and Android 12? Weird.
just follow steps :
1 set targetSdkVersion and compileSdkVersion 32
2 open AndroidManifest.xml , in application tag add this -
usesCleartextTraffic="true"
androidSupportRtl="true"
3 set android:exported="true" in activity

How to fix the error where in flutter when I open the app level build gradle, errors start to show up, now

I can't connect my app to Google Firebase and I need to see somethings in that build gradle file. When I open the app level build gradle, I get errors, I am trying to connect my app to Google Firebase but when I open my app normally, I see no errors at all and everything is going just fine and I can still run my app on the Android Emulator, but when I go ahead and open the file, errors start to pop up and I am unable to run my app, here is my app level build gradle for Android:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "co.appbrewery.flash_chat"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flut
ter {
source '../..'
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.0'
}
I am unable to understand the problem. Please help.
You can't edit the gradle files in the flutter project. You have to click on Tools --> Flutter --> Open Android Module in Android Studio. Then you can edit the graddle, run the app and come back to the flutter project with no errors.
works
Goto : Tools -> Flutter -> Open Flutter Module in Android Studio -> Make changes in build gradle

Build file 'D:\AndroidStudio\clone_flutter\android\app\build.gradle' line: 24

While connect my app with firebase generate SHA key app-level build.gradel shows an error in line 24 after adding google.json file I don't get where I am doing wrong line 24 starts from apply plugin. I upgrade flutter still I am getting this error -
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "mdhv.co.clone_flutter"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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'
}
apply plugin: 'com.google.gms.google-services'
After run Flutter doctor don't get any issue then where is the problem?
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.10.3-pre.54, on Microsoft Windows [Version 10.0.18362.356], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.5)
[√] Connected device (1 available)
• No issues found!
The error you've provided is complete, but build errors are usually caused by the added package not being installed correctly. Running flutter clean then flutter pub get should do the job. Also, depending on the Firebase products that you're using, you only need to use Firebase CLI and flutterfire_cli to setup Firebase in your Flutter project.

Categories

Resources