Closed pnthach95 closed 11 months ago
Yeah I can repro that. Seems related to #1951 and https://github.com/react-native-community/cli/issues/1884. Would you like to help us pin-point the issue and fix it?
Hi @thymikee
cli-platform-android@11.3.10
in react-native@0.72.7
console.log(args.mainActivity)
in tryLaunchAppOnDevice
, result is MainActivity
https://github.com/react-native-community/cli/blob/59e4dac7e56fb05f33508ff804c0eac7448c16a8/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts#L23-L27
cli-platform-android@12.1.1
in react-native@0.73.0
console.log(mainActivity)
in tryLaunchAppOnDevice
, result is .MainActivity
https://github.com/react-native-community/cli/blob/a45a2d92c3d53dcb0cf7ba8be4860ad75ff06702/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts#L26-L30
So, mainActivity
always includes .
in 12.1.1
, it doesn't in older versions
This was addressed in #2195 and will hopefully land with RN 73.1
Hi Mike! Could you please provide some info on when the resolution for this issue get landed? Because I tried on RN 0.73.2 but the app still didn't get launched automatically 🥲.
@thymikee need help when applicationId is diff from namespace, or applicationId must match namespace?
@thymikee need help when applicationId is diff from namespace, or applicationId must match namespace?
I have the same problem, I have an application in version 0.64.4, and now I'm updating it to version 0.73.4, with this new "namespace" variable, if I leave the "applicationId" different I get the error below:
CommandError: Couldn't open Android app with activity "br.com.integralservices.development.mob/.MainActivity" on device "Pixel_4_API_34". The app might not be installed, try installing it with: npx expo run:android -d Pixel_4_API_34
Code in current version 0.73.4:
namespace "com.integralservices" defaultConfig { applicationId "br.com.integralservices.development.mob" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0"
buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
}
flavorDimensions "env"
productFlavors {
production {
dimension "env"
applicationId "br.com.integralservices.production.mob"
}
development {
dimension "env"
applicationId "br.com.integralservices.development.mob"
}
staging {
dimension "env"
applicationId "br.com.integralservices.staging.mob"
}
}
Code in old version 0.64.4:
defaultConfig {
applicationId "br.com.integralservices.development.mob"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
flavorDimensions "env"
productFlavors {
production {
dimension "env"
applicationId 'br.com.integralservices.production.mob'
}
development {
dimension "env"
applicationId 'br.com.integralservices.development.mob'
}
staging {
dimension "env"
applicationId 'br.com.integralservices.staging.mob'
}
}
In the old version it runs without problems in the emulator, but in this one I couldn't solve this, did you find any solution?
@thymikee need help when applicationId is diff from namespace, or applicationId must match namespace?
Could @thymikee answer this question for us?
@woowalker @geydson applicationId
doesn't have to match namespace
. You can have different applicationId
s for multiple versions of your app as shown on the snippet above. Make sure the namespace
matches the package name in MainActivity.kt
.
When using product flavors, you can try using --mode
flag to indicate the flavor, e.g. yarn android --mode developmentDebug
. You can also list all available tasks by using --interactive
flag.
@geydson
CommandError: Couldn't open Android app with activity "br.com.integralservices.development.mob/.MainActivity" on device "Pixel_4_API_34". The app might not be installed, try installing it with: npx expo run:android -d Pixel_4_API_34
your output indicates you are using Expo, if the problem still occurs, I'd suggest to open an issue in Expo repository.
Hi @TMisiukiewicz at what version this fix landed?
Upgrading my app to 0.73.7 doesn't solve this issue 🥲
Upgrading my app to 0.73.7 doesn't solve this issue 🥲
If it doesn't work on yours, show your error log
My error log is similar like yours @pnthach95 :
Error: Activity class {com.foo.bar/com.foo.bar.MainActivity} does not exist.
My error log is similar like yours @pnthach95 :
Error: Activity class {com.foo.bar/com.foo.bar.MainActivity} does not exist.
I upgrade my reproducer to 0.73.7 and it can launch app without any problems
https://github.com/react-native-community/cli/assets/31266357/81d10c18-c5ac-407b-af80-18268c3412da
If you believe this issue wasn't resolved, show your reproducer as evidence, don't copy my log
Description
I change
applicationId
but keep package ID. I runyarn android --appId new.app.id
but it throwsError type 3
and app isn't opened.It doesn't happen on older RN versions.
Log on v0.72.7, notice
Starting: Intent
line and compare it to error log belowSteps to reproduce
npx react-native init foobar
android/app/build.gradle
, changeapplicationId "com.foobar"
toapplicationId "com.foo.bar"
yarn android --appId com.foo.bar
Error: Activity class {com.foo.bar/com.foo.bar.MainActivity} does not exist.
and doesn't start appReact Native Version
0.73.0
Affected Platforms
Runtime - Android, Build - MacOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/pnthach95/applicationIdError