Flutter:flutter app doesn't work after build apk - flutter

Hello finally I finished developing my app using flutter it's was Depends on API data when I developing I was using my mobile to running it's doing good but when I need to output apk using communed
flutter build apk i'ts display but when make login to app using data from API i'ts not working but when do run app everything working good … what the problem ???
massages showing me when do build apk
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'... Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\path_provider-1.6.5\android\src\main\java\io\flutter\plugins\pathprovider\PathProviderPlugin.java uses or overrides a deprecated A
PI.
Note: Recompile with -Xlint:deprecation for details.
Removed unused resources: Binary resource data reduced from 46KB to 37KB: Removed 20%
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 413.1s (!)
√ Built build\app\outputs\apk\release\app-release.apk (19.3MB).

add on android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />

Related

choose flutter build apk release?(abi)

i need upload my release apk generated by flutter to the Google play store. When i run "flutter build apk --release" the response is and apk but the size is 21MB(Based in the documentation is a FAT apk that includes all abi's apk).
javier.hospital#COBOADM-UD-P01 Flutter-APP-BODYTECH % flutter build apk --release
Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 20,5s
✓ Built build/app/outputs/flutter-apk/app-release.apk (21.9MB).
I found out othe command "flutter build apk --split-per-abi", this commands generate 3 apks with 8mb size. I think that is a good option beacause i need that the size of my application are small.
javier.hospital#COBOADM-UD-P01 Flutter-APP-BODYTECH % flutter build apk --split-per-abi
Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 12,7s
✓ Built build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk (8.4MB).
The problem is when i try sign any of this 3 apks, it's not possible to sign an the code error is "jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 5654 but got 5205 bytes)".
My question is that when i upload the first apk (21MB) to google play, the user download only 8mb apk?. or is neccesary upload 3 abi apks for the user to download only 8 mb?
In which case it is so, what way is there to sign an apk generated only for a specific abi?.
Thanks for your help!
Uploading the App bundle is the recommended method by Google.
I always use the App bundle to upload my Apps to the playstore.
My question is that when i upload the first apk (21MB) to google play,
the user download only 8mb apk?
Yes the user only has to download an 8MB file
Read More about App bundle here https://developer.android.com/platform/technology/app-bundle

Getting "Failed to transform libs.jar to match attributes" error when building a release APK

I am getting an error stating that it "Failed to transform libs.jar to match attributes" because "Transform's input file does not exist". This happened while building a release APK in Flutter.
How do I fix this?
mianumararshad#Mians-MacBook-Pro driverSide % flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Running Gradle task 'assembleRelease'... Note: /Users/mianumararshad/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.13.7/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/mianumararshad/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator-5.3.2+2/android/src/main/java/com/baseflow/geolocator/tasks/LocationUpdatesUsingLocationManagerTask.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:profileRuntimeClasspath'.
> Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: /Users/mianumararshad/Downloads/flutter project/roudy/driverSide/build/app/intermediates/flutter/profile/libs.jar.
> Transform's input file does not exist: /Users/mianumararshad/Downloads/flutter project/roudy/driverSide/build/app/intermediates/flutter/profile/libs.jar. (See https://issuetracker.google.com/issues/158753935)
* 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 6m 25s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 387.5s (!)
Step 1. flutter build apk --debug
Step 2. flutter build apk --profile
Step 3. flutter build apk --release
I have upgraded my gradle build tools 3.5.0 -> 4.0.1. After that I was not able to make release apk. Looks like upgrading gradle build tools broke some lints.
Below solution worked for me
Go in android folder->app->open build.gradle fine Search for lintOptions and add checkReleaseBuilds false example:
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false //Insert this line
}
}

I am building a release apk in flutter but at the end it show me this error

flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to
use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle...
1.2s Resolving dependencies... 3.7s registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask
is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use
registerGeneratedResFolders(FileCollection) Running Gradle task
'assembleRelease'...
Running Gradle task 'assembleRelease'... Done
140.3s (!)
Gradle task assembleRelease failed with exit code 1
Try this:
flutter build apk --split-per-abi
Read document for more information
Over time, android has spread throughout the world and runs on more than 2 billion devices. Because of android running on multiple platforms and foam-factors, it is very important to make sure an optimised app is installed on each platform.
For eg., a phone which doesn't have a high-resolution screen, should not get high-res images and thus reduce the size of the APK.
To make sure your app is optimized for each platform, android provides 2 methods:
You can split your app into multiple APKs optimized for each platform.
flutter build apk --split-per-abi
Create an app-bundle and deploy it to play store, this way when a user downloads your app, play store automatically extracts and provides the APK which is optimized for that device.
flutter build appbundle --target-platform android-arm,android-arm64
Best way I found
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi

Unable to build apk, firebase_admob making Error

I am trying to build apk but firebase admob is making problem, if I run without firebase_admob then apk works perfectly and built without any error how to resolve that issue?
I am getting this error :
Execution failed for task ':firebase_admob:verifyReleaseResources' in this case.
I am using firebase_admob: ^0.5.2 this version of it I even try some latest versions but the problem is still there.
C:\Users\Waqas\AndroidStudioProjects\gtvsports1>flutter build apk
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle... 1.3s
Resolving dependencies... 4.7s
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_admob:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\Waqas\AndroidStudioProjects\gtvsports1\build\firebase_admob\intermediates\res\merged\release\values\values.xml:304: error: resource android:attr/fontVariationSettings not foun
d.
C:\Users\Waqas\AndroidStudioProjects\gtvsports1\build\firebase_admob\intermediates\res\merged\release\values\values.xml:305: error: resource android:attr/ttcIndex not found.
error: failed linking references.
* 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 3m 10s
Running Gradle task 'assembleRelease'... 190.9s (!)
Gradle task assembleRelease failed with exit code 1
I was facing similar error. but I would like to suggest you to make appbundle which is the best option to upload app. Run flutter build appbundle sign it with google play store signing enrollment and upload. I resolve it with this.
Seems like you haven't migrated your project to AndroidX, all you need to do is, in your IDE use
Refactor > Migrate to AndroidX
After this
File > Invalidate Caches and Restart
Did you add the dependencies in Android/app/build.gradle?
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
api 'com.google.firebase:firebase-core:16.0.9'
api 'com.google.firebase:firebase-ads:16.0.1'
}

Ionic 2 Android Production Build loads very slow

I have finished my Ionic 2 App for Android.
For testing I generated my builds with:
cordova build android
These APKs work but the device ready event takes quite a while to fire. No problem.
No I build the productions APK:
cordova build --release android
And the device ready event still happens only after a few seconds. I hoped that this would not be the case in the production version.
ionic run android --prod
This creates a build for debugging and in this build the device ready events fire very fast. But the build is called app-debug.apk.
How can I build a production build that loads fast?
For production (the --prod uses aot which makes load time faster). Also make sure to use ionic middleware instead of cordova
ionic build --release --prod android
To debug in aot:
ionic run android --aot