Dom*_*ber 7 android gradle variants android-studio
我在gradle/android studio中使用Product Variants来实现以下项目设置:
在我试图实现这个(占位符,多个清单)时,我已经遵循了多个教程,但没有任何作用.
在本教程之后,我做了以下工作:http: //www.kevinrschultz.com/blog/2014/03/23/using-android-content-providers-with-multiple-package-names/
我的build.gradle:
android {
compileSdkVersion 19
buildToolsVersion '20'
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
app1 {
packageName "com.test.app1"
//applicationId "com.test.app1"
}
app2 {
packageName "com.test.app2"
//applicationId "com.test.app2"
}
}}
Run Code Online (Sandbox Code Playgroud)
在这里我的清单文件.
的src/main /清单:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<application>
</application>
Run Code Online (Sandbox Code Playgroud)
SRC/APP1 /清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.test.app1”
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.app1.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
SRC/APP 2 /清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.test.app2”
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.app2.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
这给我以下错误信息:
Manifest merger failed : Main AndroidManifest.xml at AndroidManifest.xml manifest:package attribute is not declared
Run Code Online (Sandbox Code Playgroud)
不幸的是,由于我的应用程序需要不同的包路径,因此无法为每个单独的清单标记设置包.如果我仍然这样做,合并将无法合并清单文件,因为不同的包值.除了packageName,我还尝试设置"applicationId",但这也不起作用.使用这样的占位符package="${applicationId}"
不起作用,因为它不解析变量值.
任何想法如何解决这个问题?我正在使用带有gradle 0.12.2的Android Studio 0.8.2
您可以安全地添加
<manifest xmlns:android="..."
package="com.test.app">
</manifest>
Run Code Online (Sandbox Code Playgroud)
在你的主要清单中。
但你必须在你的 build.gradle 中使用applicationId
and 。packageName
build.gradle的applicationId
会在不同的构建过程中覆盖此值。
更好的方法是使用applicationIdSuffix
而不是用于applicationId
不同的产品口味。
该字段必须出现在您的主清单中。
归档时间: |
|
查看次数: |
7369 次 |
最近记录: |