简体   繁体   English

在清单中设置WRITE_EXTERNAL_STORAGE权限时出错-未知属性android:name

[英]Error while setting WRITE_EXTERNAL_STORAGE permision in manifest - Unknow attribute android:name

I'm developing an Android app with Android studio. 我正在使用Android Studio开发一个Android应用。

I've been trying to set some permissions into my manifest file in order to write some file to the external storage everything following the tutorial: http://developer.android.com/training/basics/data-storage/files.html 我一直试图在清单文件中设置一些权限,以便将所有文件都写到外部存储中,以完成教程之后的所有操作: http : //developer.android.com/training/basics/data-storage/files.html

Here is my manifest file: 这是我的清单文件:

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="18" />

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



    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

          ..... and some more tags .....

The problem is that manifest is telling me that "android:name" is an unknow attribute, and if I remove it, of course, it tells me that a name attribute is needed, so I can't create a new file in my app because of this permission problem 问题是清单文件告诉我“ android:name”是一个未知属性,如果我删除它,当然,它告诉我需要一个name属性,所以我无法在应用中创建新文件由于此权限问题

Is there somethign I'm missing? 有没有我想念的东西? or something deprecated not shown at the tutorial? 还是本教程中未显示的不推荐使用的东西?

I can't post Images due to my low reputation sorry but the error goes throgh every android:name= and android:name= tags 由于信誉低下,我无法发布图片抱歉,但每个android:name =和android:name =标签的错误都贯穿其中

There seem to be multiple issues with your AndroidManifest file. 您的AndroidManifest文件似乎存在多个问题。 First, a Java Package is usually declared like the following: 首先,通常像下面这样声明一个Java Package

com.domain.package

So your declaration should be com.iuandroid.timetracker . 因此,您的声明应为com.iuandroid.timetracker

Secondly, the maxSdkVersion in in the wrong spot. 其次, maxSdkVersion位于错误的位置。 This... 这个...

android:maxSdkVersion="18" />

should be in the <uses-sdk/> section, not between the permission tags. 应该在<uses-sdk/>部分中,而不是在权限标签之间。 Your permissions are also declared incorrectly; 您的权限也被错误地声明; it should be... 它应该是...

<uses-permission android:name="YOUR_PERMISSION"/>

instead of... 代替...

<android:uses-permission android:name="YOUR_PERMISSION"/>

Lastly, you are also missing a few closing tags. 最后,您还缺少一些结束标记。 Your AndroidManifest.xml file should be as follows when formatted correctly: 正确格式化后,您的AndroidManifest.xml文件应如下所示:

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="18"
        android:maxSdkVersion="18" />

    <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:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM