在Android Studio中进行清单合并

时间:2013-06-12 09:54:16

标签: android merge android-manifest android-studio

有没有办法在Android Studio中使用ADT的清单合并功能(manifestmerger.enabled = true in project.properties)?

1 个答案:

答案 0 :(得分:1)

<强> 1。创建示例项目

enter image description here

<强> 2。添加新模块

enter image description here

enter image description here

enter image description here

第3。模块设置

enter image description here

enter image description here

enter image description here

<强> 4。删除应用程序模块中的文件

  

将app / ~~~ / values / style.xml移动到common / ~~~ / values / style.xml

enter image description here

enter image description here

编辑1。

<!-- app/~~~/AndroidManifest.xml -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="kr.susemi99.manifestmergerforandroidstudio" >

    <application >
        <activity
            android:name="kr.susemi99.common.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

编辑2。               

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">  <!-- add this line -->
        <activity
            android:name=".MainActivity"
            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>

</manifest>

编辑3。

package kr.susemi99.common;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        int id = item.getItemId();

        if (id == R.id.action_settings)
        {
            Toast.makeText(getApplicationContext(), "test toast", Toast.LENGTH_LONG).show();
        }

        return super.onOptionsItemSelected(item);
    }
}

enter image description here

查看全部http://susemi99.kr/2368