react-native-community / cli

React Native command line tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error type 3 Error: Activity class {....} does not exist

eidan66 opened this issue · comments

Environment

 System:
  OS: macOS 14.4.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 248.00 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: /usr/local/bin/node
  Yarn: Not Found
  npm:
    version: 10.2.5
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: XXX/.gem/ruby/3.3.0/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-UpsideDownCakePrivacySandbox | Google Play ARM 64 v8a
      - android-UpsideDownCakePrivacySandbox | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11567975
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 3.3.0
    path: XXX/.rubies/ruby-3.3.0/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.5
    wanted: 0.73.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

npx react-native doctor
Common
 ✓ Node.js - Required to execute JavaScript code
 ✓ npm - Required to install NPM dependencies
 ✓ Watchman - Used for watching changes in the filesystem when in development mode
 ✓ Metro - Required for bundling the JavaScript code

Android
 ✓ Adb - Required to verify if the android device is attached correctly
 ✓ JDK - Required to compile Java code
 ✓ Android Studio - Required for building and installing your app on Android
 ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation
 ✓ Gradlew - Build tool required for Android builds
 ✓ Android SDK - Required for building and installing your app on Android

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ Ruby - Required for installing iOS dependencies
 ✓ CocoaPods - Required for installing iOS dependencies
 ✓ ios-deploy - Required for installing your app on a physical device with the CLI
 ✓ .xcode.env - File to customize Xcode environment

Errors:   0
Warnings: 0

Description

I Updated namespace and applicationId to be the same name (after we initiate the project and change the name), after it i ran npm run android i'm getting this error message and the app won't open automatically
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=XX.XXX.XXXX/.MainActivity } Error type 3 Error: Activity class {XX.XXX.XXXX/XX.XXX.XXXX.MainActivity} does not exist.

XX.XXX.XXXX = my package name

Reproducible Demo

I can't share the code..

/adb -s 2A291FDH200865 shell am start -n XX.XXX.XXXX/XX.XXX.XXXX.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=XX.XXX.XXXX/.MainActivity }
Error type 3
Error: Activity class {XX.XXX.XXXX/XX.XXX.XXXX.MainActivity} does not exist.
// android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
        
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <!-- Include this only if you are planning to use the camera roll -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
    <uses-permission android:name="android.permission.USE_FINGERPRINT" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="true"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustPan"
        android:screenOrientation="portrait"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.RUN"/>
        </intent-filter>
        <intent-filter android:label="WatchTower" android:autoVerify="true">
              <action android:name="android.intent.action.VIEW" />
              <category android:name="android.intent.category.DEFAULT" />
              <category android:name="android.intent.category.BROWSABLE" />
              <data android:scheme="https" android:host="cpwt.page.link" />
        </intent-filter>
        <intent-filter android:label="WatchTower" android:autoVerify="true">
              <action android:name="android.intent.action.VIEW" />
              <category android:name="android.intent.category.DEFAULT" />
              <category android:name="android.intent.category.BROWSABLE" />
              <data android:scheme="https" android:host="XXXXXXX" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
      <meta-data
          android:name="com.google.mlkit.vision.DEPENDENCIES"
          android:value="barcode" />
    </application>
</manifest>

//android/app/build.gradle

.... some code...

android {
    ndkVersion rootProject.ext.ndkVersion

    buildToolsVersion rootProject.ext.buildToolsVersion
    compileSdk rootProject.ext.compileSdkVersion

    namespace 'XX.XXX.XXXX'
    defaultConfig {
        applicationId 'XX.XXX.XXXX'


...rest of the code...

I have try those things before open this ticket:
https://stackoverflow.com/questions/20915266/error-type-3-error-activity-class-does-not-exist
#2269 (and it already install by react native community by the versions on my project)
./gradlew clean -> npm run android -> same error
removing build folder -> same error

BUILD SUCCESSFUL in 2m 9s
771 actionable tasks: 766 executed, 5 up-to-date
info Connecting to the development server...
debug Running command "XXX/adb -s 2A291FDH200865 reverse tcp:8081 tcp:8081"
info Starting the app on "2A291FDH200865"...
debug Running command "/XXX/adb -s 2A291FDH200865 shell am start -n XX.XXX.XXXX/XX.XXX.XXXX.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER"
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=XX.XXX.XXXX/.MainActivity }
Error type 3
Error: Activity class {XX.XXX.XXXX/XX.XXX.XXXX.MainActivity} does not exist.
error Failed to start the app.
Error: Command failed with exit code 1: XXX/adb -s 2A291FDH200865 shell am start -n XX.XXX.XXXX/XX.XXX.XXXX.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
    at makeError (XXX/node_modules/execa/lib/error.js:60:11)
    at module.exports.sync (/XXX/node_modules/execa/index.js:194:17)
    at tryLaunchAppOnDevice (/XXX/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryLaunchAppOnDevice.js:57:22)
    at XXX/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:93:39
    at Array.forEach (<anonymous>)
    at runOnAllDevices (/XXX/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:88:48)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Command.handleAction (XXX/node_modules/@react-native-community/cli/build/index.js:118:9)

The issue also accrues on my app.
Help please!