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

Unable to instantiate activity -or- Didn't find class MainActivity #1409

Closed
SergeyNemesh opened this issue Feb 15, 2025 · 4 comments
Closed
Assignees
Labels
1 backlog bug Something isn't working

Comments

@SergeyNemesh
Copy link

SergeyNemesh commented Feb 15, 2025

Which API doesn't behave as documented, and how does it misbehave?
The app crashes when downloaded from the store.

Minimal reproduction project
Just use just_audio and just_audio_background on Flutter project.

To Reproduce (i.e. user steps, not code)
Create an AAB file, upload it to the store, and download it to your phone.

Error messages
Fatal Exception: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my_app/com.my_app.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "my_app.MainActivity" on path: DexPathList

       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3195)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
       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:2017)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7403)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)

Expected behavior
I can't understand why the app works perfectly fine locally or when launched via an APK, but when I upload the AAB file for release, I get the following error:

Fatal Exception: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my_app/com.my_app.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "my_app.MainActivity" on path: DexPathList

I've built around 25 different versions with various fixes, but I keep getting the same issue. Interestingly, the app works fine on the second launch.

That is, if I download it from the Play Store, install it, and open it, it crashes. But if I kill the app and reopen it, everything works fine.

Screenshots

Image
Image
Image

Desktop (please complete the following information):
no use

Smartphone (please complete the following information):
all androids

Flutter SDK version

[✓] Flutter (Channel stable, 3.27.4, on macOS 14.6 23G80 darwin-arm64, locale ru-UA)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
no resources

Additional context

android:name="com.ryanheise.audioservice.AudioServiceActivity"

package com.my_app
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity()

@SergeyNemesh SergeyNemesh added 1 backlog bug Something isn't working labels Feb 15, 2025
@jayantur13
Copy link

I am using just_audio: ^0.9.46 and just_audio_background: ^0.0.1-beta.15, my app works fine both in local and from PlayStore (No user mentioned crash and the logs are empty. Tested release build on android 11,12,14 and 15). Nothing customised, did same things as in the documentation. And I think you cannot use "_" in the package name.

✅ Allowed characters:

  • Lowercase letters (a-z)
  • Digits (0-9)
  • Dots (.) to separate package levels

❌ Not allowed:

  • Underscores (_)
  • Uppercase letters (A-Z)
  • Special characters (-, @, #, etc.)

@SergeyNemesh
Copy link
Author

package com.my_app its just placeholder.
issue solved by:
multiDexEnabled = true
dependencies {
implementation("androidx.multidex:multidex:2.0.1")
}

@ryanheise
Copy link
Owner

The app crashes when downloaded from the store.

Which store? Google Play?

Didn't find class "my_app.MainActivity" on path

The official example does NOT use the package name my_app, so I think this bug report contains false information. If you actually did submit the official example to the Google Play Store, please provide me a link to the store page so that I can see that it is actually the official example that you submitted.

@ryanheise
Copy link
Owner

I am going to guess that you did not reproduce this bug on the official example, and so you completed the "Minimal reproduction project" section incorrectly. If it is not reproducible on the official example, then you must fork the example and introduce minimal changes to demonstrate the bug, and provide a link to your fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants