I'm trying to create a signed APK in Flutter with Android Studio, in theory I already have all the steps ready to create the signed APK "https://flutter.dev/docs/deployment/android" but an error always pops up that prevents the apk from being created.
C:\Users\CryptoBrain\Desktop\app-Flutter\my_app>flutter 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'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':clipboard_manager:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> 1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\CryptoBrain\.gradle\caches\transforms-2\files-2.1\6c261a14fef7a6c9650e745991e1078b\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVar
iationSettings not found.
C:\Users\CryptoBrain\.gradle\caches\transforms-2\files-2.1\6c261a14fef7a6c9650e745991e1078b\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcInde
x not found.
* 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 10m 59s
Running Gradle task 'assembleRelease'... 665,6s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin clipboard_manager...
Running Gradle task 'assembleAarRelease'... 59,7s
√ Built build\app\outputs\repo.
Building plugin majascan...
Running Gradle task 'assembleAarRelease'... 36,6s
√ Built build\app\outputs\repo.
Building plugin shared_preferences...
Running Gradle task 'assembleAarRelease'... 1,4s
Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:34)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:25)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
The plugin shared_preferences could not be built due to the issue above.
C:\Users\CryptoBrain\Desktop\app-Flutter\my_app>
I already tried using the different versions of clipboard_manager there are 4 but they all give the same error.
Also change the com.android.tools.build:gradle:3.5.0 to com.android.tools.build:gradle:3.6.1 and the distributionUrl I have it in: https://services.gradle.org/distributions/gradle-5.6.4-all.zip
Here is the code I am using:
pubspec.yaml
name: app_name
description: my flutter app
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
flutter_screenutil: ^0.5.3
carousel_pro: ^0.0.13
flutter_sparkline: ^0.1.0
font_awesome_flutter: ^8.4.0
shimmer: ^0.0.6
rxdart: ^0.21.0
bmnav: ^0.3.4
carousel_slider: ^1.3.0
percent_indicator: ^1.0.15
flutter_spinkit: ^4.1.1+1
http: 0.12.0+4
shared_preferences: ^0.5.12+4
pin_code_fields: ^3.0.0
url_launcher: ^5.4.5
provider: ^4.0.1
clipboard_manager: ^0.0.4
aes_crypt: ^0.1.1
mvc_pattern: ^5.1.1
encrypt: any
majascan: ^0.3.7
flutter_launcher_icons: ^0.7.5
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
flutter_icons:
image_path: "assets/image/logo.png"
ios: true
android: true
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
fonts:
- family: gainers
fonts:
- asset: assets/icon/ic_gainers.ttf
- family: message
fonts:
- asset: assets/icon/ic_message.ttf
- family: tab
fonts:
- asset: assets/icon/ic_tab.ttf
- family: wallet
fonts:
- asset: assets/icon/ic_wallet.ttf
- family: tab1
fonts:
- asset: assets/icon/ic_tab1.ttf
- family: tab2
fonts:
- asset: assets/icon/ic_tab2.ttf
- family: tab3
fonts:
- asset: assets/icon/ic_tab3.ttf
- family: tab4
fonts:
- asset: assets/icon/ic_tab4.ttf
- family: tab5
fonts:
- asset: assets/icon/ic_tab5.ttf
- family: loser
fonts:
- asset: assets/icon/ic_loser.ttf
- family: Sans
fonts:
- asset: assets/font/OpenSans-Bold.ttf
weight: 800
- asset: assets/font/OpenSans-Semibold.ttf
weight: 600
- asset: assets/font/OpenSans-Regular.ttf
weight: 400
- asset: assets/font/OpenSans-Light.ttf
weight: 200
- family : Popins
fonts:
- asset: assets/font/Poppins-Regular.ttf
weight: 400
- asset: assets/font/Poppins-SemiBold.ttf
weight : 600
- family : Berlin
fonts:
- asset: assets/font/BRLNSDB.TTF
weight: 700
- family : Lemon
fonts:
- asset: assets/font/Lemon-Regular.ttf
weight: 400
- family : Gotik
fonts:
- asset: assets/font/GOTHIC.TTF
weight: 400
- asset: assets/font/GOTHICB.TTF
weight : 600
- family : Pragmatica
fonts:
- asset: assets/font/pragmatica_bold.ttf
weight: 500
assets:
- assets/font/BRLNSDB.TTF
- assets/font/GOTHIC.TTF
- assets/font/GOTHICB.TTF
- assets/font/Lemon-Regular.ttf
- assets/font/OpenSans-Bold.ttf
- assets/font/OpenSans-Light.ttf
- assets/font/OpenSans-Regular.ttf
- assets/font/OpenSans-Semibold.ttf
- assets/font/Poppins-Regular.ttf
- assets/font/Poppins-SemiBold.ttf
- assets/font/pragmatica-bold.ttf
- assets/font/pragmatica.ttf
- assets/font/pragmatica_bold.ttf
- assets/icon/ic_gainers.ttf
- assets/icon/ic_loser.ttf
- assets/icon/ic_message.ttf
- assets/icon/ic_tab.ttf
- assets/icon/ic_tab1.ttf
- assets/icon/ic_tab2.ttf
- assets/icon/ic_tab3.ttf
- assets/icon/ic_tab4.ttf
- assets/icon/ic_tab5.ttf
- assets/icon/ic_wallet.ttf
- assets/image/
- assets/image/market/
- assets/image/logo.png
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
file 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 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"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
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.flutter.app"
minSdkVersion 16
targetSdkVersion 28
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 {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
File android/build.gradle
buildscript {
ext.kotlin_version = '1.4.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
How can I fix this?
I was also getting that kind of error but instead, I KNOW ANOTHER WAY.
Step 01: Open your flutter Android app in another android studio. If you don't know how? Just open build.gradle in the android section of the flutter app. Then at the top corner, you will find Open for Editing in Android Studio.
Step 02: Once a new Window of Android Studio opens. Let the Gradle Build complete. Once it's done go to the Build tab at the top of Android Studio
Step 03: It will open a dialog box and you will figure out what to do next. It's really convenient and easy way.
Inside the android/app/build.gradle under configuration, to resolve the issue
android{
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
}
Related
I've followed all instruction in this page: https://flutter.dev/docs/get-started/install/windows
but when I'm trying to run the "first_app" I get an error:
Android Studio - run first_app
main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
ERROR
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
> Failed to transform artifact 'x86_debug.jar (io.flutter:x86_debug:1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c)' to match attributes {artifactType=android-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: C:\Users\m-err\.gradle\caches\modules-2\files-2.1\io.flutter\x86_debug\1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c\e05f5680b1bbc2a38b625423c4ab890a526847cc\x86_debug-1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c.jar.
> Failed to transform 'C:\Users\m-err\.gradle\caches\modules-2\files-2.1\io.flutter\x86_debug\1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c\e05f5680b1bbc2a38b625423c4ab890a526847cc\x86_debug-1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c.jar' using Jetifier. Reason: invalid stored block lengths. (Run with --stacktrace for more details.)
> Failed to transform artifact 'x86_64_debug.jar (io.flutter:x86_64_debug:1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c)' to match attributes {artifactType=android-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: C:\Users\m-err\.gradle\caches\modules-2\files-2.1\io.flutter\x86_64_debug\1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c\35b1d03b15670cc489efdcf317faf29bfd904402\x86_64_debug-1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c.jar.
> Failed to transform 'C:\Users\m-err\.gradle\caches\modules-2\files-2.1\io.flutter\x86_64_debug\1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c\35b1d03b15670cc489efdcf317faf29bfd904402\x86_64_debug-1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c.jar' using Jetifier. Reason: invalid stored block lengths. (Run with --stacktrace for more details.)
* 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 3s
Finished with error: Gradle task assembleDebug failed with exit code 1
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Versione 10.0.18362.720], locale it-IT)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Android Studio (version 3.6)
build.gradle (android)*
buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (app/src)
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 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.example.first_app"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.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 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
gradle-wrapper.properties
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
TESTS
updated kotlin version
flutter clean --> D:\Development\flutter\first_app
recreate the project after updates
LOGFILE
2020-04-01 15:38:00,597 [ 96871] INFO - rationStore.ComponentStoreImpl - Saving Project 'D:\Development\flutter\first_app' first_appKotlin2JvmCompilerArguments took 11 ms
2020-04-01 15:38:43,068 [ 139342] INFO - .flutter.run.daemon.FlutterApp - RunApp first_app (Run)
2020-04-01 15:38:43,068 [ 139342] INFO - .flutter.run.daemon.FlutterApp - D:\Programs\flutter\bin\flutter.bat [--no-color, run, --machine, --track-widget-creation, --device-id=emulator-5554, lib\main.dart]
2020-04-01 15:38:58,491 [ 154765] INFO - .FlutterAppDaemonEventListener - app shutdown took longer than 100ms
2020-04-01 15:38:58,516 [ 154790] INFO - .flutter.run.daemon.FlutterApp - StopApp first_app (Run)
2020-04-01 15:38:58,958 [ 155232] INFO - pl.ProjectRootManagerComponent - project roots have changed
2020-04-01 15:38:59,037 [ 155311] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 2ms; general responsiveness: ok; EDT responsiveness: ok
2020-04-01 15:38:59,073 [ 155347] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 36ms; general responsiveness: ok; EDT responsiveness: ok
2020-04-01 15:38:59,073 [ 155347] INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 3 files to update
2020-04-01 15:38:59,112 [ 155386] INFO - .diagnostic.PerformanceWatcher - Unindexed files update took 39ms; general responsiveness: ok; EDT responsiveness: ok
2020-04-01 15:39:48,894 [ 205168] WARN - n.process.BaseOSProcessHandler - Process hasn't generated any output for a long time.
If it's a long-running mostly idle daemon process, consider overriding OSProcessHandler#readerOptions with 'BaseOutputReader.Options.forMostlySilentProcess()' to reduce CPU usage.
Command line: D:\Programs\Android\emulator\emulator.exe -netdelay none -netspeed full -avd Pixel_2_API_29
java.lang.Throwable: Process creation:
at com.intellij.execution.process.BaseOSProcessHandler.<init>(BaseOSProcessHandler.java:33)
at com.android.tools.idea.avdmanager.EmulatorProcessHandler.<init>(EmulatorProcessHandler.java:45)
at com.android.tools.idea.avdmanager.EmulatorRunner.start(EmulatorRunner.java:57)
at com.android.tools.idea.avdmanager.AvdManagerConnection.startAvd(AvdManagerConnection.java:419)
at com.android.tools.idea.avdmanager.AvdManagerConnection.startAvd(AvdManagerConnection.java:358)
at com.android.tools.idea.avdmanager.RunAvdAction.actionPerformed(RunAvdAction.java:36)
at com.android.tools.idea.avdmanager.AvdUiAction.hyperlinkUpdate(AvdUiAction.java:127)
at com.intellij.ui.HyperlinkLabel.fireHyperlinkEvent(HyperlinkLabel.java:218)
at com.intellij.ui.HyperlinkLabel.processMouseEvent(HyperlinkLabel.java:141)
at java.awt.Component.processEvent(Component.java:6315)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4899)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4721)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4721)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:766)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:739)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:736)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:878)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:823)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:466)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:704)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:465)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2020-04-01 15:58:25,798 [1322072] WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in 'Project' content in TODO tool window to avoid focus-related problems.
2020-04-01 15:58:25,799 [1322073] WARN - j.openapi.wm.impl.IdeFrameImpl - Project tool window - parent container is hidden
2020-04-01 15:58:45,410 [1341684] WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in '' content in Dart Analysis tool window to avoid focus-related problems.
2020-04-01 15:58:45,410 [1341684] WARN - j.openapi.wm.impl.IdeFrameImpl - tool window - parent container is hidden
2020-04-01 15:58:47,751 [1344025] WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in '' content in Logcat tool window to avoid focus-related problems.
2020-04-01 15:58:47,751 [1344025] WARN - j.openapi.wm.impl.IdeFrameImpl - tool window - parent container is hidden
2020-04-01 15:58:47,837 [1344111] INFO - AndroidLogcatToolWindowFactory - Successfully obtained debug bridge
2020-04-01 15:58:59,615 [1355889] INFO - m.pty4j.windows.WindowsVersion - Windows version: 10.0.18362
2020-04-01 15:59:04,985 [1361259] WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in 'Project' content in TODO tool window to avoid focus-related problems.
2020-04-01 15:59:04,986 [1361260] WARN - j.openapi.wm.impl.IdeFrameImpl - Project tool window - parent container is hidden
2020-04-01 15:59:05,402 [1361676] WARN - j.openapi.wm.impl.IdeFrameImpl - Set preferredFocusableComponent in 'main.dart' content in Run tool window to avoid focus-related problems.
2020-04-01 15:59:05,402 [1361676] WARN - j.openapi.wm.impl.IdeFrameImpl - main.dart tool window - parent container is hidden
2020-04-01 15:59:12,685 [1368959] WARN - com.intellij.util.xmlb.Binding - no accessors for class org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptInputsWatcher$Storage
2020-04-01 15:59:12,693 [1368967] WARN - com.intellij.util.xmlb.Binding - no accessors for class org.jetbrains.kotlin.idea.core.script.configuration.utils.ScriptClassRootsStorage
2020-04-01 15:59:13,373 [1369647] INFO - mponents.impl.stores.StoreUtil - saveProjectsAndApp took 734 ms
2020-04-01 16:00:37,197 [1453471] INFO - .flutter.run.daemon.FlutterApp - RunApp first_app (Run)
2020-04-01 16:00:37,197 [1453471] INFO - .flutter.run.daemon.FlutterApp - D:\Programs\flutter\bin\flutter.bat [--no-color, run, --machine, --track-widget-creation, --device-id=emulator-5554, lib\main.dart]
2020-04-01 16:00:43,092 [1459366] INFO - .FlutterAppDaemonEventListener - app shutdown took longer than 100ms
2020-04-01 16:00:43,121 [1459395] INFO - .flutter.run.daemon.FlutterApp - StopApp first_app (Run)
Please help me, I'm following a course but I cannot continue if I don't solve that.
\TIA
I'd suspect this to be the result of a broken download or an interrupted transform, because the error message invalid stored block lengths clearly hints for a corrupt ZIP/JAR file. Try to empty directory C:\Users\m-err\.gradle\caches and then rebuild the application.
And do not disable Lint checks, so that it would complain about eventual invalid packages:
lintOptions {
// disable 'InvalidPackage'
}
Also, when only using androidx dependencies, you don't need to use the Jetifier.
I want to build APK Flutter with android studio. I also use firestore in this application. When i try to build, i get this error
Exception in thread "ForkJoinPool.commonPool-worker-0" java.lang.IllegalStateException: AAPT Process manager cannot be shut down while daemons are in use
at com.android.builder.internal.aapt.v2.Aapt2DaemonManager.shutdown(Aapt2DaemonManager.kt:96)
at com.android.build.gradle.internal.res.namespaced.RegisteredAaptService.shutdown(Aapt2DaemonManagerService.kt:61)
at com.android.build.gradle.internal.workeractions.WorkerActionServiceRegistry$shutdownAllRegisteredServices$1$1.run(WorkerActionServiceRegistry.kt:96)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
Output: D:\Compile\ttpproject\android\app\src\main\res\mipmap-hdpi\book.png: error: failed to read PNG signature: file does not start with PNG signature.
Command: C:\Users\hunterpama\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\d657dbace268bb20677284d59b1f0de8\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
D:\Compile\ttpproject\build\app\intermediates\res\merged\release \
D:\Compile\ttpproject\android\app\src\main\res\mipmap-hdpi\book.png
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
* 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 1m 28s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 89.1s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
here my file for: android\app\build.gradle
and on application id i not left empty. I just do not want to display it here
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"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
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 ""
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// 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'
i just wonder is there any confusion in sync with flutter and android. During debug, it works fine. NO error popup
i have know the reason of it. it because of image size. but i do not have proper image size for build.
Migrate your project to AndroidX.
If you have AndroidStudio 3.2 or greater you can refactor
It looks like you might have tried to build your Flutter APK using Android Studio. You need to go to your Flutter console, navigate to your project, and type this is the command line: flutter build apk --split-per-abi
after upgrading android studio to 3.4.1 it force my gradle to be upgraded to 5.1.1 but everytime i try to deploy artifactory it shows ok like this:
02:45:06: Executing task ':uimodule_utils:artifactoryPublish'...
Executing tasks: [:uimodule_utils:artifactoryPublish]
> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :crashreport_utils
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :env_utils
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :gcmmodule2
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :netowrk_module
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Configure project :uimodule_utils
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
> Task :uimodule_utils:artifactoryPublish
> Task :artifactoryDeploy
BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 executed
02:45:07: Task execution finished ':uimodule_utils:artifactoryPublish'.
but it shows nothing in my artifactory, the artifact should be shown as 1.0.36
this is my root project gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:3.1.0'
classpath "io.realm:realm-gradle-plugin:3.1.4"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.6"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
maven {
url "https://jitpack.io"
}
}
repositories {
maven { url 'https://dl.bintray.com/netguru/maven/' }
}
apply plugin: "com.jfrog.artifactory"
apply plugin: 'maven-publish'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and my app gradle is :
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding{
enabled true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:26.1.0'
implementation 'com.github.ozodrukh:CircularReveal:2.0.1'
implementation ('com.takisoft.fix:datetimepicker:1.0.6'){
exclude group: 'com.android.support', module: 'appcompat-v7'
}
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
compile 'com.google.dagger:dagger:2.10'
// Dagger Android dependencies
annotationProcessor 'com.google.dagger:dagger-android-processor:2.10'
compile 'com.google.dagger:dagger-android-support:2.10'
implementation project(':app')
}
def libraryGroupId = '<<mygroup>>'
def libraryArtifactId = '<<myid>>'
def libraryVersion = '1.0.36'
publishing {
publications {
aar(MavenPublication) {
groupId libraryGroupId
version libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/outputs/aar/${artifactId}-erelease.aar")
}
}
}
artifactory {
contextUrl = 'http://<<myserver>>:8081/artifactory'
publish {
repository {
repoKey = 'develop-local-libs'
username = artifactory_username
password = artifactory_password
}
defaults {
publications('aar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
publishPom = true
}
}
}
please help i cant even upload my library to my server, and it works fine in previous android studio
are you sure it doesn't exists in directory {apps dir}/outputs/aar/${artifactId}-erelease.aar . The file name should <your_artifact_id>-erelease.aar inside /aar directory.
can you show me the changes code on build.gradle, specially on Publishing.publication part?
I have some problems while running flutter in android studio
This is my error
Launching lib\main.dart on Moto C Plus in debug mode...
Initializing gradle...
Resolving dependencies...
Finished with error: Please review your Gradle project setup in the android/ folder.
* Error running Gradle:
Exit code 1 from: D:\FlutterPrograms\app\android\gradlew.bat app:properties:
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to E:\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where:
Build file 'D:\FlutterPrograms\app\android\app\build.gradle' line: 25
What went wrong:
A problem occurred evaluating project ':app'.
Could not resolve all artifacts for configuration 'classpath'.
Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
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 1s
This is my buid.gradle file
buildscript {
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my gradle 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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.shanmukh.app"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
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 {
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'
}
There were lots of similar issues raised the past days, that could be solved by adding the google() repository in first position in the repositories block of the build scripts.
See detailed explanation in the following answers:
couldn't locate lint-gradle-api-26.1.2.jar for flutter project
Could not find play-services-basement.aar
https://stackoverflow.com/a/52982816/6899896
Could not find com.android.tools.build:aapt2:3.2.0
The root cause , related to missing libraries in Jcenter, is explained in detail here : https://stackoverflow.com/a/50885939/6899896
Open the root flutter folder in your computer, and open the gradle folder in that root folder (For example C:\flutter\package\flutter_tool\gradle) and add 'google()' to the buildscript. It fixed the issue for me.
Flutter root folder:
Add 'google()' to the buildscript:
I found a solution!
Go to your flutter folder. After you need to find flutter.gradle. On my PC:
C:\src\flutter\packages\flutter_tools\gradle
Open flutter.gradle with note or notepad and change
buildscript from this:
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
to this:
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
I have a problem with Android Studio 0.3.0 and my project folder containing a plain old java library project, two Android library projects, and three Android apps. It's all built with Gradle.
The problem is that the initial import into Android Studio works fine (using Android Studio's Import Project..., then choosing my settings.gradle file), but when I press the refresh button in the Gradle sidebar, I get the message "The modules below are not backed by Gradle anymore. Check those to be removed from the ide project too:", and then it lists ALL my modules for removal. Everything builds fine from the terminal.
Output of gradle projects is (with edited names):
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'root'
+--- Project ':android-lib1'
+--- Project ':android-app1'
+--- Project ':android-app2'
+--- Project ':android-app3'
+--- Project ':android-lib2'
\--- Project ':java-lib'
In the root folder, I have settings.gradle:
include ':java-lib'
include ':android-lib1'
include ':android-lib2'
include ':android-app1'
include ':android-app2'
include ':android-app3'
My build.gradle in the root folder:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
allprojects {
repositories {
mavenCentral()
ivy {
name 'repo'
artifactPattern 'http://repo.example.com:8081/artifactory/libs-release-local/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]'
credentials {
username 'example'
password 'example'
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}
build.gradle for java-lib:
apply plugin: 'java'
apply plugin: 'eclipse'
compileJava.options.encoding = 'UTF-8'
group 'example'
version '0.1.0'
status 'release'
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
dependencies {
compile 'com.google.protobuf:protobuf-java:2.5.0'
compile 'com.google.guava:guava:15.0'
compile 'org.slf4j:slf4j-api:1.7.5'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
uploadArchives {
repositories {
add project.repositories.repo
}
}
build.gradle for the two Android libs (they are the same apart from dependencies and version numbers:
apply plugin: 'android-library'
dependencies {
compile project(':java-lib')
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
versionCode 1
versionName '0.1.0'
minSdkVersion 9
targetSdkVersion 18
}
}
And finally, build.gradle for the Android apps (again, almost identical):
apply plugin: 'android'
dependencies {
compile project(':android-lib1')
compile project(':android-lib2')
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
versionCode 1
versionName '0.1.0'
}
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
if (project.hasProperty('storeFile')) {
android.signingConfigs.release.storeFile = file(storeFile)
}
if (project.hasProperty('storePassword')) {
android.signingConfigs.release.storePassword = storePassword
}
if (project.hasProperty('keyAlias')) {
android.signingConfigs.release.keyAlias = keyAlias
}
if (project.hasProperty('keyPassword')) {
android.signingConfigs.release.keyPassword = keyPassword
}
Perhaps it's a bug in Android Studio 0.3.0? I didn't experience it in earlier versions, but I want to make sure it's not just something in my build files.
Thanks a bunch for reading!
This was a bug which has now been fixed (working for me since Android Studio 0.3.5): https://code.google.com/p/android/issues/detail?id=61453
Also got this or very similar error (don't know if I did refresh) I see you posted bug at code.google.com and agree it must be their bug. My work around fix was just to cancel out of "not backed by Gradle" message and then I ran gradle build from command line. Then everything worked.