When I tried to change the package name in MainActivity.kt inside kotlin the app doesn't run
This error:
e: /Users/dma/development/flutter_share/android/app/src/main/kotlin/com/example/souqmubtath/MainActivity.kt: (8, 7): Redeclaration: MainActivity
e: /Users/dma/development/flutter_share/android/app/src/main/kotlin/dev/dhari/souqmubtath/MainActivity.kt: (8, 7): Redeclaration: MainActivity
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 27s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 27.6s
Gradle task assembleDebug failed with exit code 1
You haven't changed your package name correctly,
Just go to the following path
android > app > src >main > kotlin
Inside that you will find one more package like your_package_name containing MainActivity file.
In your case it is like, "com.example.souqmubtath "
So to change it properly, just go to your android manifest file, from there just find package="com.example.souqmubtath"
Just select com.example.souqmubtath and refactor it.
For refactor either select the package name -> right click on it -> Refactor -> Rename. OR Just select the package name and use refactor rename shortcut which is Shift+F6
You can rename it to your desired package name. In your case it is like "dev.dhari.souqmubtath"
Also, go to your android > app > build.gradle file path. Inside the file and defaultConfig{} find out applicationId and refactor it as well to the same name as your package name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With