[英]Android Studio Gradle not Syncing
我是Android Studio的新手,我基本上是想打開一個我下載並編譯/運行它的現有項目。 當Gradle嘗試同步時出現以下錯誤...
Error:Cannot read packageName from /Users/Amanda/Desktop/MyProject/src/main/AndroidManifest.xml
我在網上進行了研究,並嘗試了幾種解決方案,但都沒有解決我的問題://我也嘗試過“使緩存無效並重新啟動”,但是它也不起作用。
這是我的清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.amanda.myproject.app">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="My Project">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".resourceListing"
android:label="My App Listing">
</activity>
<activity
android:name=".ListApps"
android:label="@string/title_activity_list_apps">
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
</manifest>
我的build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'com.android.application'
allprojects {
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
}
dependencies {
}
有時clean
無法刪除某些構建文件夾文件。
請嘗試以下步驟:
1-復制清單文件,然后從項目中刪除清單文件。
2-刪除您的app/build
文件夾。
3-然后清理您的項目
4-再次將清單文件添加到src/main
目錄
5-再次清理項目
6-重建項目
在build.gradle
文件build.gradle
packageName
設置為applicationId
。
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "me.amanda.myproject.app"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0.1"
}
現在,當您構建apk時,您的packageName
將替換為defaultConfig> applicationId
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.