'ERROR:: Unknown Directory structure, both java & kotlin files not found

As I was trying to change my package name using a package (change_app_package_name). I bumped into this error:-

Old Package Name: com.milanzi.shamba_huru
Updating build.gradle File
Updating Main Manifest file
Updating Debug Manifest file
Updating Profile Manifest file

ERROR:: Unknown Directory structure, both java & kotlin files not found.

Seems the package cannot find either java or kotlin files within the directory.



Solution 1:[1]

I have solved by changing the directory name where the MainActivity.kt is placed

For example

  • First your package name is com.example.app_name

  • Then you need to change into com.milanzi.shamba_huru (use your own package name)

  • Run

    flutter pub run change_app_package_name:main com.milanzi.shamba_huru

So if the error appears, you just need to create a new folder by name of your package

  • Before your path was /android/app/src/main/kotlin/com/example/app_name/MainActivity.kt
  • Change into /android/app/src/main/kotlin/com/milanzi/shamba_huru/MainActivity.kt
  • Now try run against flutter pub run change_app_package_name:main com.milanzi.shamba_huru

NB: If you didn't change the folder name, you can't run it on android. But you can run on IOS.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 4xMafole