Bypass Min SDK Version - or what else? - flutter

I am starting with flutter, and overall, I am getting an idea but have hit the wall with what I find to be one of the main reasons to consider migrating from HTML + JQueryMobile: speech to text implementation.
I have found the speech_to_text package (https://pub.dev/packages/speech_to_text#-installing-tab-), followed the instructions to :
1. update the pubspec.yaml file with the dependency &
2. instal the package from command line
3. import the package in the code
but have hit the wall with the minimum SDK requirements not being met by the package. Here is the error message:
C:\Users\TOTAL\FlutterPro\Flutter4\flutter4\android\app\src\debug\AndroidManifest.xml
Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 21
declared in library [:speech_to_text]
C:\Users\TOTAL\FlutterPro\Flutter4\flutter4\build\speech_to_text\intermediates\library_manifest\debug\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="com.csdcorp.speech_to_text" 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 [:speech_to_text]
C:\Users\TOTAL\FlutterPro\Flutter4\flutter4\build\speech_to_text\intermediates\library_manifest\debug\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="com.csdcorp.speech_to_text" to force usage (may lead to runtime failures)
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
BUILD FAILED in 11s Exception: Gradle task assembleDebug failed with
exit code 1
Strangely, I have managed to bypass this once but can not find the
relevant piece of code in the app folder now. Worse, the mentioned file
> C:\Users\TOTAL\FlutterPro\Flutter4\flutter4\android\app\src\debug\AndroidManifest.xml
does not contain any reference to SDK, only this:
< <manifest
<xmlns:android="http://schemas.android.com/apk/res/android"
< package="com.example.flutter4">
> <!-- Flutter needs it to communicate with the running application
> to allow setting breakpoints, to provide hot reload, etc.
> -->
> <uses-permission android:name="android.permission.INTERNET"/> </manifest>
As for the other mentioned file, which looks like this:
> <?xml version="1.0" encoding="utf-8"?> <manifest
> xmlns:android="http://schemas.android.com/apk/res/android"
> package="com.csdcorp.speech_to_text" >
>
> <uses-sdk android:minSdkVersion="21" />
>
> </manifest>
changing the 21 to 16 is reverted after the attempt to run this app.
How to handle this
1. technically, ie. what is the workaround for this minSDK limitation - one that is at least worth trying?
2. A step back, if there are version issues, how do you do to avoid them?
Thanks a lot

Edit the build.gradle file in app folder. Search defaultConfig, edit the minSdkVersion from 16 to 21.
File path.
android\app\build.gradle

Related

ERROR:AAPT: error: resource style/Theme.AppCompat.light.NoActionBar

I am encountering a problem on my project build.
I am using the techno flutter.
I am using Android-Studio on Windows 11.
The error is:
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
ERROR:AAPT: error: resource style/Theme.AppCompat.light.NoActionBar (aka com.example.nysos:style/Theme.AppCompat.light.NoActionBar) not found.
error: failed linking references.
I have already cleared my gradle cache, used flutter clean, File > Invalidate caches > Clear file system chache and Local History > Invalidate and restart.
Could you please help me fixing this error ?
In Android Studio:
CTRL+SHIFT+F
Enter in the search bar: AppCompat
Change Theme.AppCompat.light.NoActionBar to Theme.AppCompat.Light.NoActionBar
Verify your versions in your flutter/android/app/build.gradle and flutter/android/build.gradle and it should work.
i face this issue don't know why but error clearly says about its location so i change styles.xml file code.
in flutter project go to you android>app>src>main>values>styles.xml
in styles.xml file change the line no 4
<style name="LaunchTheme"parent="Theme.AppCompat.Light.NoActionBar">
to
<style name="LaunchTheme"parent="#android:style/Theme.Light.NoTitleBar">
and line no 15
<style name="NormalTheme"parent="Theme.MaterialComponents">
to
<style name="NormalTheme"parent="#android:style/Theme.Light.NoTitleBar">

Build Failed in Flutter, Couldn't understand the error

This is the error that I'm getting.
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:razorpay_flutter] D:\All Data\My Projects\Mine Created Flutter Projects\gym_work\build\razorpay_flutter\intermediates\library_manifest\debug\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 19,
or use tools:overrideLibrary="com.razorpay.razorpay_flutter" to force usage (may lead to runtime failures)
How do I solve it?
Just add
android{
defaultConfig{
minSdkVersion 19
}
}
to android/app/build.gradle in you project directory

How to remove "Unable to merge android manifest" error in unity-5

I am beginner to Unity and am trying to integrate Admob to my unity project. The problem is it gives error saying
Unable to merge Android manifests, see the console for more details, see the console for details
i have applied all the solutions like
changing the minSDKversion
changing the targetSDKversion
Deleting manifests
many more
but still got stuck with the bug.
Here is the error.
CommandInvokationFailure: Unable to merge android manifests. See the Console for more details.
C:/Program Files/Java/jdk1.8.0_144\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="D:/Android SDK installer\tools" -Dfile.encoding=UTF8 -jar "D:\Unity 5.6.1 Install\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -
stderr[
Error: [Temp\StagingArea\AndroidManifest-main.xml, D:\HR-PTech\Admob Test App\Temp\StagingArea\android-libraries\play-services-ads-lite-11.0.2\AndroidManifest.xml:10] Trying to merge incompatible /manifest/application/activity[#name=com.google.android.gms.ads.AdActivity] element:
<activity
-- #android:exported="false"
-- #android:name="com.google.android.gms.ads.AdActivity"
-- #android:theme="#android:style/Theme.Translucent">
<activity
++ #android:name="com.google.android.gms.ads.AdActivity"
++ #android:theme="#android:style/Theme.Translucent">
++</activity>
]
stdout[
Warning: [Temp\StagingArea\AndroidManifest-main.xml:2, D:\HR-PTech\Admob Test App\Temp\StagingArea\android-libraries\android.arch.lifecycle.runtime-1.0.0\AndroidManifest.xml:3] Main manifest has <uses-sdk android:targetSdkVersion='25'> but library uses targetSdkVersion='26'
[Temp\StagingArea\AndroidManifest-main.xml, D:\HorseRacing-PureTechGame\Admob Test App\Temp\StagingArea\android-libraries\com.android.support.support-compat-26.1.0\AndroidManifest.xml:6] Skipping identical /manifest/application/meta-data[#name=android.support.VERSION] element.

Google service version conflict

When I use these two plugins in ionic 1
cordova-plugin-fcm
cordova-plugin-googleplus
then this type of error occurs:
BUILD FAILED in 1s
11 actionable tasks: 1 executed, 10 up-to-date
Error: /home/idiosys/ionic/seeCheckFolder/SeeCheck/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
What went wrong:
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 9.0.0.
What can be the reason for these errors?
remove fcm, google plus
then install firebase plugin (https://ionicframework.com/docs/native/firebase/)
then install google plus.
remove and re-add android platform. it is work with me (ionic2).
Note: firebase contains notification functions , also with badge number : )
1 - Remove the entry from build.gradle:
// PLUGIN GRADLE EXTENSIONS START
apply from: "cordova-plugin-fcm/poc-FCMPlugin.gradle"
// PLUGIN GRADLE EXTENSIONS END
2 - specify proper versions for all other dependencies in project.properties file like:
cordova.system.library.1=com.google.firebase:firebase-core:10.2.0
cordova.system.library.2=com.google.firebase:firebase-messaging:10.2.0
cordova.system.library.3=com.google.android.gms:play-services-auth:10.2.0
cordova.system.library.4=com.google.android.gms:play-services-identity:10.2.0
3 - And bottom of build.gradle file add this line:
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
4 - Comment out all content of poc-fcmplugin.gradle file and instead of apply plugin: com.google.gms.googleservices.GoogleServicesPlugin use:
apply plugin: 'com.google.gms.google-services'
5 - Add classpath for google services in build.gradle classpath section like:
classpath 'com.google.gms:google-services:3.0.0'
Please refer to below mentioned app and make sure android dependencies are correct .
https://market.ionicframework.com/starters/ionic-google-plus-fcm-and-ad-banner
implementation "com.google.android.gms:play-services-auth:10.+"
implementation "com.google.android.gms:play-services-identity:10.+"
implementation "com.android.support:support-annotations:27.+"
implementation "com.google.firebase:firebase-core:10.+"
implementation "com.google.firebase:firebase-messaging:10.+"
implementation "com.google.android.gms:play-services-base:10.+"
implementation "com.google.android.gms:play-services-ads:10.+"

Cannot get Cordova project building in VS2015 with the facebook connect plugin

I've tried everything, but cannot seem to get it working. I've done the following:
1.Remove the plugins with the variables via the config designer.
2.Update to Cordova 5.0.0 via the config designer (Platforms > Cordova CLI)
3.From the command line: 1.Go to your project directory.
2.Type the following substituting the plugin name for the plugin you wish to add:
3.npm install -g cordova
4.cordova plugin add nl.x-services.plugins.launchmyapp --variable URL_SCHEME=myscheme
But I still cannot build. Here is the detailed output from MSBUILD :
http://pastebin.com/7enSzCxs
And a highlight of some of the errors I'm getting
1> BUILD FAILED
1> C:\Users\Adam\AppData\Local\Android\android-sdk\tools\ant\build.xml:601: The following error occurred while executing this line:
1> F:\GIT\CordovaFb\BlankCordovaApp1\fbtest\platforms\android\com.phonegap.plugins.facebookconnect\myapp2568ddfac877478fb806edc911cff37e-FacebookLib\custom_rules.xml:4: F:\GIT\CordovaFb\BlankCordovaApp1\fbtest\platforms\android\com.phonegap.plugins.facebookconnect\myapp2568ddfac877478fb806edc911cff37e-FacebookLib\ant-build does not exist.
And
1> BUILD FAILED
1> C:\Users\Adam\AppData\Local\Android\android-sdk\tools\ant\build.xml:470: The following error occurred while executing this line:
1> C:\Users\Adam\AppData\Local\Android\android-sdk\tools\ant\build.xml:441: Unable to delete directory F:\GIT\CordovaFb\BlankCordovaApp1\fbtest\platforms\android\com.phonegap.plugins.facebookconnect\myapp2568ddfac877478fb806edc911cff37e-FacebookLib\bin
And finally
1>
1> F:\GIT\CordovaFb\BlankCordovaApp1\fbtest\platforms\android\cordova\node_modules\q\q.js:126
1> throw e;
1> ^
1> Error code 1 for command: cmd with args: /s /c "ant debug -f F:\GIT\CordovaFb\BlankCordovaApp1\fbtest\platforms\android\build.xml"
1> Command finished with error code 8: F:\GIT\CordovaFb\BlankCordovaApp1\fbtest\platforms\android\cordova\build.bat --debug,--ant,
1>MDAVSCLI : error : F:\GIT\CordovaFb\BlankCordovaApp1\fbtest\platforms\android\cordova\build.bat: Command failed with exit code 8
1>Done executing task "MdaVsCli" -- FAILED.
1>Done building target "BuildMDA" in project "fbtest.jsproj" -- FAILED.
1>Build FAILED.
Any ideas at all? Using a fresh install of VS2015 with the tools for cordova, trying to build for android.
EDIT:
So after taking the advice of Kamil Pajdzik below, I used build.bat to compile it and found some issues with my path being waaay to long. I mapped a drive to cut down the length and it will now build AOK from the build.bat.
Still no dice in Visual studio though (I assume this is difference between build.bat using gradle and vs using ant).
My only error now is :
1> -code-gen:
1> [mergemanifest] Merging AndroidManifest files into one.
1> [mergemanifest] Manifest merger disabled. Using project manifest only.
1> [echo] Handling aidl files...
1> [aidl] No AIDL files to compile.
1> [echo] ----------
1> [echo] Handling RenderScript files...
1> [echo] ----------
1> [echo] Handling Resources...
1> [aapt] Generating resource IDs...
1> [aapt] Z:\fbtest\platforms\android\bin\AndroidManifest.xml:14: error: Error: No resource found that matches the given name (at 'value' with value '#string/fb_app_id').
1> [aapt]
1> [aapt] Z:\fbtest\platforms\android\bin\AndroidManifest.xml:15: error: Error: No resource found that matches the given name (at 'label' with value '#string/fb_app_name').
1> [aapt]
1>
1> BUILD FAILED
1> C:\Users\Adam\AppData\Local\Android\android-sdk\tools\ant\build.xml:653: The following error occurred while executing this line:
1> C:\Users\Adam\AppData\Local\Android\android-sdk\tools\ant\build.xml:698: null returned: 1
1>
Okay, this appears to be the issue. There are two problems. The first is a max path size issue on Windows. The issue is that it the plugin uses part of the the app's ID to create a folder, and VS by default uses a random identifier that is fairly long so this exacerbates the issue.
To resolve:
Update the ID for your project to something short (com.myproject.short)
Move the project to the root of your drive
Go to the project folder and re-add the android platform. From the command line:
cordova platform remove android
cordova platform add android
The second issue that then remains is an "Ant" build seems to be missing a folder which likely is a bug. If you add the "ant-build" folder in the location it complains about the build succeeds.
Also - Be sure plugins/fetch.json is included in your checkins since this is where your plugin variables are stored. If that file is deleted, you'll need to remove and re-add the plugin again. From your update it sounds like either VS is still set to use Cordova 4.3.0 and/or plugins/fetch.json does not contain your plugin variables. You should see something like this if the plugin was added using Cordova 5.0.0:
{
"com.phonegap.plugins.facebookconnect": {
"source": {
"type": "registry",
"id": "com.phonegap.plugins.facebookconnect"
},
"is_top_level": true,
"variables": {
"APP_ID": "123",
"APP_NAME": "nbaer"
}
}
}
The "variables" section is what may be missing.
Try running F:\GIT\CordovaFb\BlankCordovaApp1\fbtest\platforms\android\cordova\build.bat from a command line. It usually gives more information.
Cordova 5.0.0 requires Android SDK in version 22. You can check if you have that installed via SDK manager.
This particular plugin appears to have some challenges with Cordova 5.0.0. Android underwent significant changes in this release that may be causing issues.
https://github.com/Wizcorp/phonegap-facebook-plugin/issues/1010
I am seeing failures if you build either with Ant or Gradle using a pure Cordova command line interface project. Likely a plugin fix is required to resolve the issue. I reccomend adding comments to this defect to help the plugin author resolve the issue.
So thanks to Chucks help, I managed to get a build working. It was indeed a combination of path length exceeding 260 characters (which I solved by mapping my solution directory to a drive) and a couple of folders not being created.
They were in my case :
F:\Git\CordovaFb\FBTest\platforms\android\com.phonegap.plugins.facebookconnect\myapp7a29c6c80cee4b2aa0dc8a70dc57527d-FacebookLib\bin\classes
and
F:\Git\CordovaFb\FBTest\platforms\android\com.phonegap.plugins.facebookconnect\myapp7a29c6c80cee4b2aa0dc8a70dc57527d-FacebookLib\ant-build
I seem to have to manually recreate these from time to time as they get deleted on some builds...
So the full process is as follows (for others who have the same issue)
1) Create your solution in as short a path as possible (map a drive if you need to)
2) Add your cordova project to the solution, double click config.xml, goto platforms and change the CLI version to 5.0.0
3) Fire up a command prompt in the solutions root
4) Type the following cordova plugin add https://github.com/Wizcorp/phonegap-facebook-plugin.git --variable APP_ID="00000000" --variable APP_NAME="My App"
5) When its done you'll have the plugin in the plugins dir and the fetch.json file should contain the variables you entered for appid and appname
6) Do a full build and you'll get some errors (Exit code 8)
7) Manually create the following :
[Solution Route]\platforms\android\com.phonegap.plugins.facebookconnect\myapp7a29c6c80cee4b2aa0dc8a70dc57527d-FacebookLib\bin\classes`
and
[Solution Route]\platforms\android\com.phonegap.plugins.facebookconnect\myapp7a29c6c80cee4b2aa0dc8a70dc57527d-FacebookLib\bin\classes`
8) Your build should succeed! Check periodically if those paths still exist.
This should get you by until the next release of the cordova tools for VS (if they fix it)
platforms\android\AndroidManifest.xml
just change android:minSdkVersion="14" to android:minSdkVersion="15"