Java Android studio:无法从清单中读取packageName

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38823794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 20:40:32  来源:igfitidea点击:

Android studio : cannot read packageName from manifest

javaandroidxml

提问by sgrumo

Hi everyone ( this is my first question, please don't be rude ). I'm a beginner in coding and I have ran into this error in Android Studio : "Gradle project sync failed", and the error is "Error:Cannot read packageName from /Users/sgrumo/Downloads/gvr-android-sdk-master/samples/sdk-treasurehunt/src/main/AndroidManifest.xml"

大家好(这是我的第一个问题,请不要粗鲁)。我是编码初学者,我在 Android Studio 中遇到了这个错误:“Gradle 项目同步失败”,错误是“错误:无法从 /Users/sgrumo/Downloads/gvr-android-sdk-master 读取 packageName /samples/sdk-treasurehunt/src/main/AndroidManifest.xml"

My manifest is the following :

我的清单如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.google.vr.sdk.samples.treasurehunt"
          android:versionCode="1"
          android:versionName="1">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.NFC" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <!-- Make accelerometer and gyroscope hard requirements for good head tracking. -->
    <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true"/>
    <uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true"/>
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="22"/>
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />

    <!-- VR feature tags. -->
    <uses-feature android:name="android.software.vr.mode" android:required="false"/>
    <uses-feature android:name="android.hardware.vr.high_performance" android:required="false"/>
    <uses-feature android:name=""
    <application
            android:allowBackup="true"
            android:supportsRtl="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name">
        <activity
                android:name="com.google.vr.sdk.samples.treasurehunt.TreasureHuntActivity"
                android:label="@string/app_name"
                android:screenOrientation="landscape"
                android:configChanges="orientation|keyboardHidden|screenSize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="com.google.intent.category.CARDBOARD" />
            </intent-filter>
        </activity>
    </application>


</manifest>

build.gradle:

构建.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 13
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi-v7a'
            universalApk true
        }
    }
}

dependencies {
    compile project(':libraries-audio')
    compile project(':libraries-base')
    compile project(':libraries-common')
}

采纳答案by Shaishav

Try adding applicationIdin defaultConfig(build.gradle):

尝试添加applicationIddefaultConfigbuild.gradle):

defaultConfig {
    applicationId "com.google.vr.sdk.samples.treasurehunt"
    minSdkVersion 13
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}