my apk won't get excuted causing this problem . My project is a brand new one, but having problems running the app on my device ( Note :#: i did add to my depencecies multidex and it didn't work
implementation 'com.android.support:multidex:2.0.1')
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
// applicationId "com.example.yumor"
// minSdkVersion 19
// minSdkVersion flutter.minSdkVersion
// targetSdkVersion flutter.targetSdkVersion
// versionCode flutterVersionCode.toInteger()
// versionName flutterVersionName
multiDexEnabled true
}
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.1.0')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
~~~!
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform classes.jar (project :sqflite) to match attributes {artifactType=android-dex, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.api.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-incremental-transform=false, dexing-is-debuggable=true, dexing-min-sdk=19, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: C:\Users\Abdou\flutter project\realfultter\yumor\build\sqflite\intermediates\runtime_library_classes_jar\debug\classes.jar.
> Unable to read jar file C:\Users\Abdou\flutter project\realfultter\yumor\build\sqflite\intermediates\runtime_library_classes_jar\debug\classes.jar
If this is set to 20 or lower, you need to configure your app for multiDex support.
defaultConfig {
applicationId "com.inspire.aaym"
minSdkVersion 21
targetSdkVersion 30
}
So, if your app is not intended to be used in the Android version prior to 5.0, setting the minSdkVersion number to 21 will easily fix this issue.
Related
I'm new to flutter and am trying to run a new project on VS code.
installed the latest flutter at 19/1/2022. flutter --version gives me 2.8.1.
jdk is 17.0.1
this is what i get ...
Launching lib\main.dart on SM N975F in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'G:\1-programing\Projects\Flutter\flutter_application_2\android\settings.gradle' (C:\Users\username\.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61
* 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
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
tried to change gradle, which is 6.7 in gradle-wrapper.properties, to 7.3.3 which is the latest.
and this is what i get...
Launching lib\main.dart on SM N975F in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #30206a4d
* 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
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
i have tried changing the build.gradle in android/app/src
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_application_2"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
to
defaultConfig {
applicationId "com.example.gfgpagination"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
and it was not helpfull.
have tried searching these errors but i could not use them to this day.
my build.gradle in android folder
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and my build.gradle in android/app folder
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 flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_application_2"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
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"
}
soooo, I am going to answer my own question.
it seems i was using the latest java SDK version.
As mentioned in the install web page, i must have downloaded java SDK8 .
that's probably everything i did to fix it.
Try this for last error 'Unable to make field private final java.lang.String java.io.File.path' : https://exerror.com/accessible-module-java-base-does-not-opens-java-io-to-unnamed-module/
In your Manifest.xml add below line if it is not present:
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="31" />
For more further information you will visit below link
Stack Overflow Answer
Before updating to Flutter 2.8
defaultConfig {
applicationId "com.kim.app"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
After updating to Flutter 2.8:
defaultConfig {
applicationId "com.example.app"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
How can I update minSdkVersion higher? I cannot find the target "flutter.minSdkVersion" variable anywhere.
Go to android/local.properties
Add the following ie define the versions
flutter.minSdkVersion=21
flutter.targetSdkVersion=30
flutter.compileSdkVersion=30
Once done goto android/app/build.gradle and add the following
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
Then goto android/build.gradle
Update the Kotlin version
ext.kotlin_version = '1.6.0'
just replace flutter.minSdkVersion with your value ,
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Just replace flutter.minSdkVersion to your target version.
flutter.minSdkVersion is found in
https://github.com/flutter/flutter/blob/stable/packages/flutter_tools/gradle/flutter.gradle
I am getting this error while running my Flutter app after setup the Admob service to my app. Before adding the AdMob service the app was running fine. What should I do?
Error:
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.work:work-runtime:2.7.0.
AAR metadata file: C:\Users\nazmu.gradle\caches\transforms-2\files-2.1\6ca6bfbb6ed79157a08fdd6548cc9e4d\work-runtime-2.7.0\META-INF\com\android\build\gradle\aar-metadata.properties.
Screenshot:
Gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID
(https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.bedtime_horror_story"
minSdkVersion 20
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Try change the compileSdkVersion to 31
android {
compileSdkVersion 31
...
}
I'm working on a Flutter project for an Android application.
I need to give sound alerts when the user's action is completed success or wrong.
I've tried the AudioPlayers package but it didn't work.
version: audioplayers: ^0.20.1
playMusic() async {
await audioPlayer.play(url, isLocal: true);
}
I even couldn't build the project after adding audioplayers.
Is there any other package for this?
When I added to AudioPlayers package to pubseck.yaml It was giving Kotlin error.
First I change my Kotlin version to 1.5.10 from 1.30.50 in 'android/build.gradle'.
ext.kotlin_version = '1.5.10'
And then the app started to give multidex errors.
I changed the configuration of 'android/app/build.gradle' like below
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.allstore_mobile"
minSdkVersion 20
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
After the above changes, the AudioPlayers package started to work.
final AudioCache _audioCache = AudioCache(
prefix: 'assets/sounds/',
fixedPlayer: AudioPlayer()..setReleaseMode(ReleaseMode.STOP),
);
_audioCache.play('success.mp3');
i am using simple_edge_detection library from here :
https://www.flutterclutter.dev/flutter/tutorials/implementing-edge-detection-in-flutter/2020/1509/
CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
include_directories(../include)
add_library(lib_opencv SHARED IMPORTED)
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libopencv_java4.so)
set(EDGE_DETECTION_DIR "../ios/Classes")
set(SOURCES
${EDGE_DETECTION_DIR}/native_edge_detection.cpp
${EDGE_DETECTION_DIR}/edge_detector.cpp
${EDGE_DETECTION_DIR}/image_processor.cpp
)
add_library(native_edge_detection SHARED ${SOURCES})
target_link_libraries(native_edge_detection lib_opencv)
build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
// flavorDimensions "default"
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 "dev.flutterclutter.simple_edge_detection_example"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
externalNativeBuild {
cmake {
cppFlags '-frtti -fexceptions -std=c++11'
arguments "-DANDROID_STL=c++_shared"
}
}
}
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
}
}
externalNativeBuild {
cmake {
path "D:/Flutter Projects/flutter-simple-edge-detection/example/android/CMakeLists.txt"
}
}
}
but m getting this error :
FAILURE: Build failed with an exception.
Execution failed for task ':simple_edge_detection:externalNativeBuildDebug'.
Build command failed.
Error while executing process C:\Users\Andorid\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build D:\Flutter Projects\flutter-simple-edge-detection\android.cxx\cmake\debug\armeabi-v7a --target native_edge_detection}
ninja: error: '../../../../src/main/jniLibs/armeabi-v7a/libopencv_java4.so', needed by 'D:/Flutter Projects/flutter-simple-edge-detection/example/build/simple_edge_detection/intermediates/cmake/debug/obj/armeabi-v7a/libnative_edge_detection.so', missing and no known rule to make it