提问人:user2380187 提问时间:11/10/2023 最后编辑:user2380187 更新时间:11/14/2023 访问量:37
Android 应用程序在调试模式下可在手机上运行,但由于缺少 MainActivity,因此在从 Play 商店下载时无法运行
Android App works on phone in debug mode but not when downloaded from Play Store due to missing MainActivity
问:
我有一个 Flutter 应用程序,它在手机上的调试模式下运行良好,但由于找不到 MainActivity,在发布模式下启动时崩溃。谁能看到我的配置不正确?
这个项目的历史是,我正在尝试升级现有应用程序以满足 Google API 要求。让上传密钥正常工作需要一些时间,我相信这是由于新项目的包名称被错误地指定为 com.simplegradebook.simplegradebook 造成的。最初的应用程序只使用了 com.simplegradebook。
当我更改软件包名称时,上传密钥开始工作。但是,我认为这种改变导致了这个新问题。希望在不再次重新创建项目的情况下解决此问题。
欢迎所有建议。
错误:
2023-11-09 11:12:30.074 30254-30254 AndroidRuntime pid-30254 E FATAL EXCEPTION: main
Process: com.simplegradebook, PID: 30254
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.simplegradebook/com.simplegradebook.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.simplegradebook.MainActivity" on path: DexPathList[[zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/base.apk", zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.arm64_v8a.apk", zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.en.apk", zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.fr.apk", zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/lib/arm64, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/base.apk!/lib/arm64-v8a, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.en.apk!/lib/arm64-v8a, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.fr.apk!/lib/arm64-v8a, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4051)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4325)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.simplegradebook.MainActivity" on path: DexPathList[[zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/base.apk", zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.arm64_v8a.apk", zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.en.apk", zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.fr.apk", zip file "/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/lib/arm64, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/base.apk!/lib/arm64-v8a, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.en.apk!/lib/arm64-v8a, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.fr.apk!/lib/arm64-v8a, /data/app/~~bPyVuggYllXzkUk6SFFvxQ==/com.simplegradebook-yiUEzfIlNLukOOb5TYpHuQ==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
未合并的 Android 版本清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="simplegradebook"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
合并的 Android 版本清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simplegradebook"
android:versionCode="11"
android:versionName="4.0.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="33" />
<application
android:name="com.simplegradebook.simplegradebook"
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:icon="@mipmap/ic_launcher"
android:label="simplegradebook" >
<activity
android:name="com.simplegradebook.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize" >
<!--
Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI.
-->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--
Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java
-->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<uses-library
android:name="androidx.window.extensions"
android:required="false" />
<uses-library
android:name="androidx.window.sidecar"
android:required="false" />
</application>
</manifest>
合并的 Android 调试清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simplegradebook"
android:versionCode="5"
android:versionName="4.0.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="33" />
<!--
The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="android.app.Application"
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
android:debuggable="true"
android:icon="@mipmap/ic_launcher"
android:label="simplegradebook" >
<activity
android:name="com.simplegradebook.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize" >
<!--
Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI.
-->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--
Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java
-->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<uses-library
android:name="androidx.window.extensions"
android:required="false" />
<uses-library
android:name="androidx.window.sidecar"
android:required="false" />
</application>
</manifest>
build.gradle:
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.simplegradebook"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
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.simplegradebook"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
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
manifestPlaceholders = [applicationName: "simplegradebook"]
println(signingConfigs.release.keyAlias)
}
}
}
flutter {
source '../..'
}
dependencies {}
pubspec.yaml:
name: simplegradebook
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 4.0.0+10
environment:
sdk: '>=3.1.5 <4.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
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: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
http: ^0.13.4
shared_preferences: ^2.0.8
flutter_pdfview: ^1.0.1
path_provider: ^2.0.6
permission_handler: ^8.3.0 #For asking permission to load the pdf
material_design_icons_flutter: ^5.0.6595
intl: ^0.17.0
visibility_detector: ^0.2.2
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
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
# 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
MainActivity 包的文件结构图片:
答: 暂无答案
评论