Upon finishing a flutter app, running with no problems on ADB device, no Flutter Doctor problems, generated signed APK, installed to device before uploading to Google Play. Installed app on device, clicked to open app on device, got "Unfortunately, app has stopped working." Banged head on wall.
What I did to fix problems that gave errors when trying to build signed APK: Fixed all build problems (could not find AndroidManifest, could not read @string property, the android:configChanges thing, directed to the MainActivity file in the Project Structure, downloaded dependencies in Project Structure "Problems" tab; everything fixed). App did build with 0 errors.
Cleaned project using Flutter Clean (Tools, Flutter) and Code Cleanup (under Analyze tab) before generating signed APK.
Other stackoverflow questions on this topic, but did not solve this problem: Why my signed apk crashes? Why my signed apk crashes?
I have searched the internet for days, and find myself still with my forehead repeatedly rebounding off a quite solid wall that shows no signs of experiencing any sort of structural failure anytime soon.
I don't know which part of my code to share, because I have no idea what the flippin problem is. I recreated the problem with the default app that flutter creates when you create a new app in IntelliJ. So, even the default app, with no new code, generates the same problem with the signed APK crashing when installed.
Another strange thing: the app is approximately 54 mB when installed on device. What the holy hollerin heckfire is going on? The APK is about 7 mB.
This is the logcat:
--------- beginning of crash 01-25 22:30:48.093 27488-27488/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.nothing2, PID: 27488 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.nothing2/com.example.nothing2.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.nothing2.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.nothing2-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.nothing2-1/lib/arm, /data/app/com.example.nothing2-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2345) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) at android.app.ActivityThread.access$900(ActivityThread.java:163) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5585) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.nothing2.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.nothing2-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.nothing2-1/lib/arm, /data/app/com.example.nothing2-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at android.app.Instrumentation.newActivity(Instrumentation.java:1068) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2335) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) at android.app.ActivityThread.access$900(ActivityThread.java:163) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5585) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) Suppressed: java.lang.ClassNotFoundException: com.example.nothing2.MainActivity at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 12 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available 01-25 22:30:48.099 1200-3616/? W/ActivityManager: Force finishing activity com.example.nothing2/.MainActivity 01-25 22:30:48.126 1200-27502/? W/DropBoxManagerService: Dropping: data_app_crash (2388 > 0 bytes)
app/build.gradle source code:
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.example.nothing2"
minSdkVersion 16
targetSdkVersion 27
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'
}