【问题标题】:'android:name' in <activity> tag must be a valid Java class name in React Native<activity> 标签中的 'android:name' 必须是 React Native 中的有效 Java 类名
【发布时间】:2019-06-06 07:18:19
【问题描述】:

我刚刚创建了一个 react-native 应用程序并构建了 React Native 应用程序给我下面的错误。

H:\App Data\ejob-app\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:2: AAPT: error: attribute 'package' in <manifest> tag is not a valid Android package name: 'com.ejob-app'.

H:\App Data\ejob-app\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:17: AAPT: error: attribute 'android:name' in <application> tag must be a valid Java class name.

H:\App Data\ejob-app\android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:24: AAPT: error: attribute 'android:name' in <activity> tag must be a valid Java class name.

最后出现以下错误..

FAILURE: Build failed with an exception.

* Where:
Build file 'H:\App Data\ejob-app\android\app\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> Plugin with id 'com.ejob.app' not found.

* 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 2s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and 
have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

这是我的AndroidManifest.xml,用于检查所需的配置。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ejob-app"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="26" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
    android:name="com.ejob-app.MainApplication"
    android:allowBackup="false"
    android:debuggable="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.ejob-app.MainActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:label="@string/app_name"
        android:windowSoftInputMode="adjustResize" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

请指导我,如果我遗漏了什么,请告诉我。我对 react-native 很陌生。

【问题讨论】:

  • 也从 AndroidManifest.xml 上传代码
  • 也告诉我们app/build.gradle,因为上面写着error build.gradle line 1 &gt; Plugin with id 'com.ejob.app' not found.
  • 您的清单中缺少

标签: javascript android react-native android-studio manifest


【解决方案1】:

包名不应包含破折号。从

重命名您的包

'com.ejob-app'

'com.ejob_app'

你可以关注this question

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,就我而言,问题是当我创建颤振项目时,我将组织名称命名为 in.mycompany(注意,“in”)。现在,“in”似乎是 Dart 中的一个关键字,因此,Android Studio 在它生成的文件中使用了“in”。但是,这让 Gradle 不高兴,并导致它生成消息说 name 必须是有效的 Java 包名称。真是个难题:)

    解决方法是在整个项目中搜索`in`.mycompany这个字符串,并在build.gradle和AndroidManifest.xml文件中将其改为in.mycompany(这样的文件有好几个,随便搜索一下)。但在 kotlin 文件 MainActivity.kt 中将其保留为 `in`

    这为我解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-18
      • 2019-01-09
      • 2019-12-17
      相关资源
      最近更新 更多