AAPT:错误:在调试清单中找到未知元素<uses-feature>

时间:2018-07-20 00:51:06

标签: android xml react-native android-manifest aapt

我开始使用AAPT2是因为出于某种原因,我的应用程序在相机上不断崩溃,并且我可能从告诉我的内容中发现了错误:

android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:43: AAPT: error: unknown element <uses-feature> found.
android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:47: AAPT: error: unknown element <uses-permission> found.
android\app\build\intermediates\manifests\full\debug\AndroidManifest.xml:48: AAPT: error: unknown element <uses-permission> found.

这是调试清单:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myapp"
    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.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <meta-data
        android:name="android.support.VERSION"
        android:value="25.3.1" />

    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:name="com.myapp.MainApplication"
        android:allowBackup="true"
        android:debuggable="true"
        android:icon="@mipmap/ic_launcher"
        android:label="myapp"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.myapp.MainActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:label="myapp"
            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" />
        **<!-- Problem Occurs Here -->**
        <uses-feature
            android:name="android.hardware.camera"
            android:required="true" />

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

        <activity
            android:name="cn.finalteam.rxgalleryfinal.ui.activity.MediaActivity"
            android:exported="true"
            android:screenOrientation="portrait"
            android:theme="@style/Theme_Light.Default" />
        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme_Light.Default" />

        <provider
            android:name="com.imagepicker.FileProvider"
            android:authorities="com.myapp.provider"
            android:exported="false"
            android:grantUriPermissions="true" >
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths" />
        </provider>

        <meta-data
            android:name="com.dylanvann.fastimage.OkHttpProgressGlideModule"
            android:value="GlideModule" />
    </application>

</manifest>

我查看了其他类似的问题,发现您必须删除所述行或将其放置在其他位置。但是我不熟悉XML的放置,因此可能会引起更多问题。谁能帮我这个忙吗?谢谢!

Src清单:

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

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

<application
  android:name=".MainApplication"
  android:label="myapp"
  android:icon="@mipmap/ic_launcher"
  android:allowBackup="true"
  tools:replace="label"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="myapp"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    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>

1 个答案:

答案 0 :(得分:1)

function datePartOrder(locale) { const parts = new Intl.DateTimeFormat(locale).formatToParts(); const filteredParts = parts.filter(part => ['year', 'month', 'day'].includes(part.type)); const filteredPartNames = filteredParts.map(part => part.type); return filteredPartNames; } // examples: console.log(datePartOrder('en-US')); //["month", "day", "year"] ); console.log(datePartOrder('en-CA')); //["year", "month", "day"]移到<uses-feature android:name="android.hardware.camera" android:required="true" />标记之外,如下所示:

<application>