我正在研究这个Building Simple Chat Client with Parse,我正在使用gradle 2.4来构建我的项目。我的build.gradle和AndroidManifest.xml
代码是:
的build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.parse.bolts:bolts-android:1.+'
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0+'
compile 'com.squareup.picasso:picasso:2.5.0'
}
的AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:label="@string/app_name"
android:name="main.java.org.hello.ChatApplication">
<activity
android:name=".ChatActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我收到了下一个错误:
/home/grados-sanchez/workspace/simplechat/src/main/AndroidManifest.xml:0:0 Error:
uses-sdk:minSdkVersion 1 cannot be smaller than version 7 declared in library /home/grados-sanchez/workspace/simplechat/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
:processDebugManifest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 7 declared in library /home/grados-sanchez/workspace/simplechat/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- debug option to get more log output.
BUILD FAILED
请你帮帮我
答案 0 :(得分:20)
您必须将minSdkVersion
添加到build.gradle
。
否则,gradle使用默认值= 1
您使用的是minSdk=7
的库,那么您无法使用minSdk = 1.
另请注意gradle 覆盖清单中的值。
添加如下内容:
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
}
}
注意你的build.gradle。你有两个依赖块。你必须合并这些块。
答案 1 :(得分:4)
添加
<uses-sdk tools:overrideLibrary="android.support.v7.appcompat"/>
到您的AndroidManifest.xml,它将工作。这将使Manifest合并在API版本较旧时也可以添加它。不要忘记在xml根目录中添加tools命名空间,如下所示。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
xmlns:tools="http://schemas.android.com/tools">
您还可以在此处找到有关此内容的更多信息:http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-tools:overrideLibrary-marker
答案 2 :(得分:0)
您似乎忘记在build.gradle中添加以下代码。将它添加到build.gradle并尝试编译
defaultConfig {
applicationId "com.XXX.XXXX" // your application package
multiDexEnabled true
minSdkVersion 14
targetSdkVersion 18
versionCode 99
versionName "11.1.5.5"
}