changing MinSdk after launcing in Store for flutter App and error in install - flutter

I have launched a app this 2 month ago with signing and this properties:
defaultConfig {
minSdkVersion 18
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Now i added some new features like firebase messaging and firebase notification that require at least MinSdk 19 ;
So i changed MinSdk to => 19 and change version from
version: 1.0.0+6
to
version: 1.1.1+0
But when i release new version and try to update last version whit new version it make trouble whit error :
"Not Installed App : package appears to be corrupt"
(and i don't want to removing it from device because of logged users)
Could someone Help me about it?

Build number should be incremented every time you publish a new version to any app store. So it should be:
version: 1.1.1+7

Related

Share_plus plugin - Error: Call requires API level 22 (current min is 16): android.content.Intent#createChooser [NewApi]

My flutter version: Flutter 3.0.0
Gradle version: Gradle 7.2
when I run .../android$ ./gradlew clean and then .../android$ ./gradlew build -warning-mode all in terminal, I get the following error:
> Task :share_plus:lintDebug FAILED
Lint found 4 errors, 3 warnings. First failure:
/home/my-name/.pub-cache/hosted/pub.dartlang.org/share_plus-6.2.0/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt:68: Error: Call requires API level 22 (current min is 16): android.content.Intent#createChooser [NewApi]
Intent.createChooser(
I changed minSdkVersion like the following but it is still not working.
android/app/build.gradle:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.citymarker"
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
android/local.properties:
sdk.dir=/home/my-name/Android/Sdk
flutter.sdk=/home/thiago/development/flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.minSdkVersion=23
flutter.targetSdkVersion=33
flutter.compileSdkVersion=33
I tried everything I could, but nothing is working.
I solved using a lower version of share_plus plugin. Just add the below line in your pubspec.yaml under dependencies:
share_plus: 4.0.2
I don't know yet why the error was happening even after changing minSdkVersion to 23. If someone has an answer, please, share with us.
under External Libraries you can find all the libraries u r using including share_plus (these are the files generated when u run 'flutter pub get'). U need to update share_plus/android/build.gradle with minSdkVersion 23, and it should build.enter image description here

Could not determine the dependencies of task ':agora_rtc_engine:compileReleaseKotlin'

After upgrading to agora_rtc_engine 5.0.0 I'm experiencing the following build error:
Command: flutter build appbundle
Error message:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':agora_rtc_engine:compileReleaseKotlin'.
> Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
This is the setup in my build gradle:
defaultConfig {
applicationId "com.MyPackage"
minSdkVersion 24
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
I tried uninstalling and reinstalling build tools, upgrading gradle version, but no luck. Anyone experiencing the same issue?
In the meantime I'm downgrading to 4.2.1 as I'm not in need of any new feature, but eventually I'll need to update.
Try changing your targetSDKVersion to 31

Flutter Spotfy sdk authentication issue in release builds

I am facing an issue in flutter release build for spotify sdk authentication issue.it is working fine in debugging mode and connecting with spotify but in release mode its showing an error : [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(authenticationTokenError, Authentication went wrong, AUTHENTICATION_SERVICE_UNAVAILABLE, null).code: PlatformException(authenticationTokenError, Authentication went wrong, AUTHENTICATION_SERVICE_UNAVAILABLE, null).message
Check your debug console while debugging the debug apk and if there are exceptions caught, then fix those exceptions, your issue will be resolved
can you check the SH1 value of release buildType to be same as SH1 value that was given while creating the app in spotify dashboard.
What fixed it for me was to set the applicationId in the build.gradle file (android -> app -> build.gradle).
defaultConfig {
applicationId "com.example" // <-
minSdkVersion localProperties.getProperty('flutter.minSdkVersion')
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
The applicationId have to be the same as the Android Package name in you Spotify App config
Android Package

Flutter appbundle building using older version

I want to upload the second version of my Flutter app to the internal test channel on Google Play (I am just working with the Android version for now).
I could upload the first version 1.0.0+1 but when trying to upload the second version 1.0.1+2 Google Play Console is rejecting my appbundle with error message
You need to use a different version code for your APK because you already have one with version code 1.
I have already tried the sequence:
flutter clean to delete build and temp folders.
Modifying version line on pubspec.yaml from 1.0.0+1 to 1.0.1+2.
flutter pub get to rebuild flutter needed files.
flutter build appbundle to get the bundle built.
Since I have been already able to build and publish the first version of the app I assume that the rest of the build configuration is OK.
Most of the solutions aim to clean project, modify pubspec.yaml and then rebuild but this seems not to be working for me.
EDIT:
tried to modify build.gradle file using values flutterVersionName = '1.0.1' and flutterVersionCode = '2' and I am still getting an appbundle with versionCode 1.
Android app version code and version name are defined in android/app/build.gradle. Take a look at this file and check if these lines are included
...
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
...
defaultConfig {
applicationId "net.myapp"
minSdkVersion 18
targetSdkVersion 28
versionCode flutterVersionCode.toInteger() //<-this line defines versionCode
versionName flutterVersionName
...
If everything is ok, take a look at android/local.properties file. This file is updated when Flutter build the app. It should have these lines, generated from your pubspec.yaml data:
flutter.versionName=1.1.1
flutter.versionCode=9
If both files are ok, run a flutter build apk to regenerate local.properties data.
Found a workaround good enough and that is building the appbundle not using Flutter sdk, but using Android Studio.
In order to achieve that do the following:
Open Android Studio > Open android project (android folder in your Flutter project)
Then modify your app level build.gradle as follows:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "<YOUR_APP_ID>"
minSdkVersion 21
targetSdkVersion 28
versionCode 2 // Manually add your desired version code
versionName "1.0.1" // Manually add your desired version name
// versionCode flutterVersionCode.toInteger()
// versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Then go to Build > Generate Signed Bundle / APK... to generate your bundle or APK as if you were building a native app (further instructions to generate a signed app bundle can be found here
Please note that this does not fully solve the issue since the bundle still cannot be correctly generated using Flutter sdk.

flutter - use tools:overrideLibrary="io.flutter.plugins.camera"

While implementing camera in flutter I face this problem with manifest file
android\app\src\main\AndroidManifest.xml Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:camera] D:\My Files\flutter-apps\login\build\camera\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="io.flutter.plugins.camera" to force usage (may lead to runtime failures)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:camera] D:\My Files\flutter-apps\login\build\camera\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="io.flutter.plugins.camera" to force usage (may lead to runtime failures)**strong text**
If you want to use camera plugin you need to update your Flutter Android minSdkVersion to 21 in your android build.gradle file located here:
./android/app/build.gradle
This how it should be:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.my_flutter_app"
minSdkVersion 21
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
If you look at the plugin page, yuo can see they also tell you what to do.