Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter App is crashing in runtime after adding plugins #25862

Closed
KarimMohamed20 opened this issue Dec 29, 2018 · 14 comments
Closed

Flutter App is crashing in runtime after adding plugins #25862

KarimMohamed20 opened this issue Dec 29, 2018 · 14 comments
Labels
c: crash Stack traces logged to the console p: tooling Affects the flutter_plugin_tools package package flutter/packages repository. See also p: labels.

Comments

@KarimMohamed20
Copy link

KarimMohamed20 commented Dec 29, 2018

I have a project and it 's now in deployment there 's some plugins I needed to add in pubspec.yaml

 file_picker: any
 location: any
 device_calendar: any
 flutter_pdf_viewer: any
 http: any
 sqflite: any
 path_provider: any
 url_launcher: any
 share: any
 shared_preferences: any
 datetime_picker_formfield: any
 fluttertoast: any
 google_maps_flutter: any
 cupertino_icons: any
 firebase_messaging: any
 image_picker: any
 flutter_local_notifications: any

after running

flutter build apk

> * What went wrong:
> Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:appcompat-v7' has different version for the compile (27.1.0) > and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution

but after adding this code

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.0"
            }
        }
    }
}

to android/build.gradle there 's no error appeared but now I had many problems in runtime and app crashes anyone can help ?

@kangwang1988
Copy link
Contributor

@KarimMohamed2005
First, please paste your flutter doctor -v output in details here.
Second, if possible, please create a demo project which can help us reproduce your problem.

@KarimMohamed20
Copy link
Author

KarimMohamed20 commented Dec 29, 2018

flutter doctor -v log :

[✓] Flutter (Channel stable, v1.0.0, on Linux, locale en_US.UTF-8)
    • Flutter version 1.0.0 at /home/karim/flutter
    • Framework revision 5391447fae (4 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /home/karim/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling
      support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /home/karim/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

[✓] Android Studio (version 3.1)
    • Android Studio at /home/karim/android-studio
    • Flutter plugin version 27.1.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1024-b01)

[✓] IntelliJ IDEA Community Edition (version 2018.2)
    • IntelliJ at /home/karim/idea-IC-182.4323.46
    • Flutter plugin version 29.1.3
    • Dart plugin version 182.4323.44

[✓] VS Code (version 1.28.2)
    • VS Code at /usr/share/code
    • Flutter extension version 2.21.1

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

@KarimMohamed20
Copy link
Author

@kangwang1988
Copy link
Contributor

kangwang1988 commented Dec 29, 2018

@KarimMohamed2005

You mean it will crash, can you paste the crash info with "adb logcat"?

Besides, please read #14020 to see if it helps.

@KarimMohamed20
Copy link
Author

KarimMohamed20 commented Dec 29, 2018

/lib/arm64, /mnt/expand/c78d097a-9980-4bae-ade9-9ef60e40c4b2/app/com.example.gocloud-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libflutter.so"
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at java.lang.Runtime.loadLibrary0(Runtime.java:984)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at java.lang.System.loadLibrary(System.java:1530)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at io.flutter.view.FlutterMain.startInitialization(FlutterMain.java:157)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at io.flutter.view.FlutterMain.startInitialization(FlutterMain.java:134)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at io.flutter.app.FlutterApplication.onCreate(FlutterApplication.java:22)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1026)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at android.app.ActivityThread.-wrap2(ActivityThread.java)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:102)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:154)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6119)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
12-29 18:22:45.311 26437 26437 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
12-29 18:22:45.314  1346 27520 W ActivityManager:   Force finishing activity com.example.gocloud/.MainActivity
12-29 18:22:45.314  1346 27520 D ActivityManager: William-Debug:taskRecord =TaskRecord{17f541e #1337 I=com.lenovo.launcher/com.android.launcher3.Launcher U=0 StackId=0 sz=1}
12-29 18:22:45.315  1346 27520 E ActivityManager: William-Debug:moveToFront -->notifyFocusedTaskChangedLocked
12-29 18:22:45.317  1346 27520 D ActivityTrigger: ActivityTrigger activityPauseTrigger 
12-29 18:22:45.323  1645  1645 D AppPanel:  onTaskFocuseChange
12-29 18:22:45.327  1346  1388 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@66537c2
12-29 18:22:45.327  1346  1388 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@22209d3
12-29 18:22:45.327  1645  1645 D AppPanel:  onTaskFocuseChange : mCurrentFocusTask : null <-isForceReoladRecents :false <- mIntoSpliteScreenTask :null
12-29 18:22:45.329  1346  1388 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@b410c09
12-29 18:22:45.329  1346  1388 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@4530e0e
12-29 18:22:45.362  1346  5267 I OpenGLRenderer: Initialized EGL, version 1.4
12-29 18:22:45.362  1346  5267 D OpenGLRenderer: Swap behavior 1
12-29 18:22:45.638  1645  1645 D BatteryMeterDrawable: mPluginButNotCharging is  drawing
12-29 18:22:45.818  1346  1387 W ActivityManager: Activity pause timeout for ActivityRecord{ed2319d u0 com.example.gocloud/.MainActivity t1527 f}
12-29 18:22:45.823  1346  1387 I WindowManager: Failed to capture screenshot of Token{70b2612 ActivityRecord{ed2319d u0 com.example.gocloud/.MainActivity t1527 f}} appWin=Window{559b93f u0 Starting com.example.gocloud} drawState=4
12-29 18:22:45.940  2357  2357 V Launcher: Launcher.onResume()
12-29 18:22:45.941  2357  2357 D Launcher

@KarimMohamed20
Copy link
Author

KarimMohamed20 commented Dec 30, 2018

can anyone help ?

@zoechi zoechi added c: crash Stack traces logged to the console plugin p: tooling Affects the flutter_plugin_tools package labels Dec 30, 2018
@zoechi zoechi added this to the Goals milestone Dec 30, 2018
@KarimMohamed20
Copy link
Author

KarimMohamed20 commented Dec 30, 2018

@zoechi
After search I changed the gradle version and made some changes in build.gradle but it also still crashes

android/build.gradle

buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

android/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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28
    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.gocloud"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        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'
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.android.support:support-v4:28.0.0'
}

@georgerappel
Copy link

georgerappel commented Dec 31, 2018

I have this very problem with the image_picker package, but for versions 26- to 27.1.1. When I require it, the project won't build. When I remove it, it works normally.

Removing the image_picker from your project didn't work for me, so maybe other packages have this issue.

The solution you provided for the build.gradle worked for me though, as stated here: #14020 (comment)

@kangwang1988
Copy link
Contributor

@KarimMohamed2005
Try this:
image

You can also have a look at your apk structure and make sure the libflutter.so exists in the expected lib directory like this:
image

Now, libflutter.so is provided for armeabi-v7a and arm64-v8a. If you didn't specify abiFilters, it might crash as yours.

@KarimMohamed20
Copy link
Author

@kangwang1988

I think you saved my life 💯 .
Thank You Very Much

@gabrc52
Copy link

gabrc52 commented Jan 23, 2019

@KarimMohamed2005 Even though you've worked around the issue, it's still a bug, so please reopen.

GitHub issues are for reporting bugs and if you can't find information on how to do something on the Flutter site (documentation problems), not for solving your specific problems.

@iapicca
Copy link
Contributor

iapicca commented Jan 14, 2020

Hi @KarimMohamed2005
are you experiencing the issue with the latest stable version of flutter
and the latest plugin version?
thank you

@iapicca iapicca added waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds p: third party labels Jan 14, 2020
@KarimMohamed20 KarimMohamed20 changed the title App in runtime Crash after adding plugins App crashes in runtime after adding plugins Jan 15, 2020
@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 15, 2020
@KarimMohamed20
Copy link
Author

Hi @KarimMohamed2005
are you experiencing the issue with the latest stable version of flutter
and the latest plugin version?
thank you

Actually I didn't try from along time but I think it will work fine without problems

@KarimMohamed20 KarimMohamed20 changed the title App crashes in runtime after adding plugins Flutter App is crashing in runtime after adding plugins Feb 3, 2020
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console p: tooling Affects the flutter_plugin_tools package package flutter/packages repository. See also p: labels.
Projects
None yet
Development

No branches or pull requests

6 participants