Skip to content

Conversation

TaeBbong
Copy link
Contributor

Problem

By running android example app, I've got following error;

E/AndroidRuntime(10979): FATAL EXCEPTION: main
E/AndroidRuntime(10979): Process: org.thorvg.thorvg_example, PID: 10979
E/AndroidRuntime(10979): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.thorvg.thorvg_example/org.thorvg.thorvg_example.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "org.thorvg.thorvg_example.MainActivity" on path: DexPathList[[zip file "/data/app/~~k_PwgHlx8hquWCXbwDo6Vw==/org.thorvg.thorvg_example-DDmiNqIrixAJqcGyGXRGhw==/base.apk"],nativeLibraryDirectories=[/data/app/~~k_PwgHlx8hquWCXbwDo6Vw==/org.thorvg.thorvg_example-DDmiNqIrixAJqcGyGXRGhw==/lib/arm64, /data/app/~~k_PwgHlx8hquWCXbwDo6Vw==/org.thorvg.thorvg_example-DDmiNqIrixAJqcGyGXRGhw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]

Cause of this error was inconsistent app namespace and package name for overall app.
For example, package name in MainActivity.kt was com.example.example,

package com.example.example

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity()

whereas namespace in build.gradle.kts was com.thorvg.thorvg_example.

android {
    namespace = "com.thorvg.thorvg_example"
    compileSdk = flutter.compileSdkVersion
...

Android app finds app package by namespace defined in android/app/build.gradle.kts, so we need to keep consistency for overall app.

Changes

  • Make whole app package name, namespace into com.thorvg.example.

@hermet hermet added the refactoring Code refactoring / Exceptional handles label Aug 11, 2025
@hermet hermet requested review from Copilot and tinyjin August 11, 2025 13:45
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a namespace inconsistency issue in the Android example app that was causing runtime crashes due to mismatched package names. The app was unable to find the MainActivity class because the package declaration didn't match the namespace configuration.

  • Standardizes package naming from com.example.example to com.thorvg.example
  • Updates both the Kotlin source file package declaration and Gradle namespace configurations
  • Aligns the example app with the main Android module's naming convention

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
example/android/app/src/main/kotlin/com/thorvg/example/MainActivity.kt Updates package declaration to match the namespace
android/build.gradle Updates group and namespace configurations to use consistent naming

Copy link
Member

@tinyjin tinyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.
In the general way of namespace, using domain in reversed order is recommended.

Let's arrange with organization's official domain style (thorvg.org)

@TaeBbong
Copy link
Contributor Author

Thanks for review! I've added commit to fix namespace as "org.thorvg.example".

@tinyjin
Copy link
Member

tinyjin commented Aug 25, 2025

@TaeBbong Please squash the commit. No reason to have 2 commits for single change

@TaeBbong TaeBbong force-pushed the taebbong/fix-example-namespace branch from a2a166d to fc8ef0d Compare August 25, 2025 06:34
@TaeBbong
Copy link
Contributor Author

@TaeBbong Please squash the commit. No reason to have 2 commits for single change

Thanks for the review! I’ve squashed the commits into one as suggested. Please let me know if anything else needs adjustment.

Copy link
Member

@tinyjin tinyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also check example/ios/Runner.xcodeproj/project.pbxproj for bundleId

@TaeBbong
Copy link
Contributor Author

Please also check example/ios/Runner.xcodeproj/project.pbxproj for bundleId

I've added a commit to update bundleId for iOS example app, for targets Runner and RunnerTests.
(If it looks good, I would squash this commit then rename this PR.)

As you know, iOS has only one bundleId declaration for each flavour(debug, profile, release).
For that reason, issue about inconsistent bundleId conflict doesn't occur in iOS.

Just wondering, is there a particular reason bundleIDs are configured differently across build flavours/targets?

Copy link
Contributor Author

@TaeBbong TaeBbong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments for changes in iOS/Runner.xcodeproj.

Comment on lines -479 to +461
PRODUCT_BUNDLE_IDENTIFIER = com.example.lottieNative;
PRODUCT_BUNDLE_IDENTIFIER = org.thorvg.example;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target Runner, Env Profile.

Comment on lines -496 to +478
PRODUCT_BUNDLE_IDENTIFIER = com.example.thorvg.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = org.thorvg.example.RunnerTests;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target RunnerTests, Env Debug.

@tinyjin
Copy link
Member

tinyjin commented Aug 28, 2025

Just wondering, is there a particular reason bundleIDs are configured differently across build flavours/targets?

@TaeBbong No.

@TaeBbong TaeBbong force-pushed the taebbong/fix-example-namespace branch from baea91c to 2a3c69a Compare September 4, 2025 13:37
@tinyjin tinyjin self-requested a review September 4, 2025 14:27
Copy link
Member

@tinyjin tinyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Please squash the commits

@TaeBbong TaeBbong changed the title Rename app namespace in android example Rename app namespace in examples Sep 11, 2025
@TaeBbong TaeBbong force-pushed the taebbong/fix-example-namespace branch from 2a3c69a to 57fd303 Compare September 11, 2025 09:17
@TaeBbong
Copy link
Contributor Author

Thank you. Please squash the commits

Squash done and ready now:)

@TaeBbong TaeBbong requested a review from tinyjin September 11, 2025 09:19
@tinyjin tinyjin merged commit 72f3607 into thorvg:main Sep 11, 2025
@TaeBbong TaeBbong deleted the taebbong/fix-example-namespace branch September 14, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code refactoring / Exceptional handles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants