I’m aware there’s a plethora of questions/answers regarding this issue. However, I have spent the past few days trying a number of solutions I’ve found on SO and none have worked thus far.

My error:

BUILD SUCCESSFUL in 52s
372 actionable tasks: 352 executed, 20 up-to-date
info Running C:\Users\User\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
info Starting the app on emulator-5554 (C:\Users\User\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 shell am start -n mypackage/mypackage.MainActivity)...
Starting: Intent { cmp=mypackage/.MainActivity }
Error type 3
Error: Activity class {mypackage/mypackage.MainActivity} does not exist.

Here is a list of all the things I’ve attempted to do based on other SO posts:

Attempts

  1. Running adb kill-server, adb start-server, then react-native run-android 和国内的大多数教程不同,这点非常起作用

  2. Running adb reverse tcp:8081 tcp:8081, then react-native run-android (a senior dev I used to work with told me the issue might be related to this a long time ago, but I cannot get in touch with him)

  3. Uninstalling the App from the Emulator, as well as my physical device

  4. Build -> Clean Project

  5. Files -> Invalidate Cache / Restart

  6. Files -> Sync Project with Gradle Files

  7. Build -> Rebuild Project

  8. Deleted gradle cache files in /project/android/.gradle/5.1.1

  9. AndroidManifest.xml -> <activity android:name=".MainActivity" to <activity android:name="packagename.MainActivity"

  10. android/app/build.gradle to view buildTypes

debug {
  applicationIdSuffix ".debug"
}
stagingRelease {
  applicationIdSuffix ".staging"
}
release {

}

Ran react-native run-android --variant=[debug] --appIdSuffix '[.debug]'

&&

Ran react-native run-android --variant=[stagingRelease] --appIdSuffix '[.staging]'

(these came with different errors)

  1. Make sure android/app/build.gradle
defaultConfig {
        applicationId "WHATEVER_THIS_IS" 
}

needs to match android/app/src/main/java/com/app_name/MainActivity.java line one:

package WHATEVER_THIS_IS;

needs to match android/app/src/main/java/com/app_name/MainApplication.java line one:

package WHATEVER_THIS_IS;

needs to match android/app/src/main/AndroidManifest.xml line one:

package="WHATEVER_THIS_IS">
  1. Went to android/app/build.gradle and changed:
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}

to

splits {
    abi {
        reset()
        enable true
        universalApk true  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
  1. Went to C:/Users/User/.gradle to delete the cache. Was unable to delete everything, as I kept getting alerts that many of the files/folders inside are currently “open in another program” (untrue as far as I can tell)

Nothing worked.

原文地址:http://www.cnblogs.com/sexintercourse/p/16927449.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性