同一个应用的多个定制版本

时间:2021-03-30 18:24:04

Whats the best way to deploy several customized versions of a Android application?

部署Android应用程序的几个定制版本的最佳方式是什么?

Currently I have a script to exchange the resource folder for getting a customized version of my app. It works great, but all custom versions still have the same package name in the AndroidManifest.xml. Therefore it is not possible to install two customized versions of the app at the same time.

目前我有一个脚本,用来交换资源文件夹,以获得我的应用程序的定制版本。因此,不可能同时安装两个定制版本的app。

This is one solution for this problem, but that has to be done by hand

这是这个问题的一个解决方案,但这必须手工完成

Can you think of a more easy solution, or how this could be built into a skript?

你能想出一个更简单的解决方案吗?

(btw: it is not for a porn/spam/whatever app, not even a paid one)

(顺便说一句:它不是针对色情/垃圾邮件/任何应用,甚至不是付费应用)

8 个解决方案

#1


23  

Perhaps the built-in Android "library" concept was not fully baked at the time of the original post, but it may be the preferred method as of 2011. Follow these steps for an ant build:

或许内置的Android“库”概念在最初发布时还没有完全成熟,但到2011年,它可能是首选的方法。按照以下步骤构建ant:

Starting from a working app (let's call it directory "myOrigApp", package com.foo.myapp), just add this line to "default.properties" to make it a library:

从一个可用的应用程序开始(我们称它为“myOrigApp”,package com.foo.myapp),将这一行添加到“default”。使其成为图书馆:

android.library=true

Now create a new app in a sibling directory in any way you prefer (let's call it directory "sibling", package com.foo.myVariant). Using Intellij Idea, for example, create a project 'from scratch' with directory 'sibling' and it will create all the files/directories you would normally need.

现在,以您喜欢的任何方式在同胞目录中创建一个新的应用程序(让我们将它称为“同胞”目录,包com.foo.myVariant)。例如,使用Intellij Idea,用“sibling”目录创建一个“从头开始”的项目,它将创建您通常需要的所有文件/目录。

In that new, sibling directory edit "default.properties" to add the dependency:

在新的、同级目录编辑“默认”。属性添加依赖项:

android.library.reference.1=../myOrigApp

Copy over the Manifest from the original dir:

复制原署长的舱单:

cd sibling
cp ../myOrigApp/AndroidManifest.xml  ../myOrigApp/local.properties ../myOrigApp/build.properties  .

Edit that copied Manifest file to change its package name to your new variant, "com.foo.myVarient"; that's the only change.

编辑复制的Manifest文件,将其包名更改为新的变体“com.foo.myVarient”;这是唯一的改变。

If you just run the ant build scripts, you may be done. (I had to just set up signing keys.)

如果您只是运行ant构建脚本,那么您可能已经完成了。(我只需要设置签名键。)

If you want to set up an IDE like Idea to have the library project as a dependent of the variant project, follow these steps to add a library project to the variant project (assumes you already have a project set up for both):

如果您想要建立一个IDE,例如将库项目作为一个依赖于该变体项目的项目,请按照以下步骤向该变量项目添加一个库项目(假设您已经为这两个项目设置了一个项目):

  • Open the original project, bring up Project Settings, select your Facet and check "Is Library Project" and save.
  • 打开原始项目,打开项目设置,选择你的面,检查“Is Library project”并保存。
  • Open the variant project, bring up Project Settings, select Modules
  • 打开变体项目,打开项目设置,选择模块
  • Add a module
  • 添加一个模块
  • Select “Import existing module”
  • 选择“导入现有模块”
  • Browse to the Original directory (myOrigApp) and select its .iml file (IntelliJ project source file)
  • 浏览到原始目录(myOrigApp)并选择它的.iml文件(IntelliJ项目源文件)
  • Click "Finish." (The library project is added as a module within the variant project.)
  • 点击“完成”。(在变体项目中,库项目作为模块添加。)
  • In the modules list click over the Variant project to select it.
  • 在模块列表中,单击变体项目以选择它。
  • On the right hand side select the "Dependencies" tab.
  • 在右侧选择“Dependencies”选项卡。
  • Click "Add…"
  • 点击“添加……”
  • Choose "Module dependency…" (A list should appear that includes the name of the module/library you previously added to the project--perhaps the only entry in the list).
  • 选择“模块依赖……”(应该出现一个列表,其中包含先前添加到项目中的模块/库的名称——可能是列表中唯一的条目)。
  • Select the library project you added and press OK. (It will be added to the list of dependencies of your project.)
  • 选择添加的库项目并按OK。(它将被添加到项目的依赖项列表中。)
  • Press OK to finish configuring the project. (You should see 2 modules, with the library's resources and classes available and recognized in the Variant project.)
  • 按OK完成项目配置。(您应该会看到两个模块,其中包含在变体项目中可用的和可识别的库资源和类。)

#2


6  

What I did for something similar to this is to just use an antlib task and then go through all java and xml files to replace my old package string to the new package string. It didn't matter if the files were not in the correct src paths according to the package. Just doing a regex replace for all the files was enough for me to get this working...

我所做的与此类似的事情是使用antlib任务,然后遍历所有java和xml文件,将旧的包字符串替换为新的包字符串。根据包,文件是否在正确的src路径中并不重要。只是做一个regex替换所有的文件就足够让我做这个工作了…

For example to replace it in all your java files under the src directory:

例如,在src目录下的所有java文件中替换它:

 <replaceregexp flags="g" byline="false">
    <regexp pattern="old.package.string" /> 
    <substitution expression="new.package.string" />
    <fileset dir="src" includes="**/*.java" /> 
 </replaceregexp>

#3


5  

You definitely want to use Gradle flavors that comes natively, encouraged even, on Android Studio.

你肯定想在Android Studio中使用本地的、甚至是鼓励的渐变风格。

It seems to explain all the basics really well. I just finished converting to Gradle today, and it works great. Custom app icons, names, and strings, etc.

它似乎很好地解释了所有的基础知识。我今天刚完成了升级,效果很好。自定义应用程序图标、名称和字符串等。

As the website explains, part of the purpose behind this design was to make it more dynamic and more easily allow multiple APKs to be created with essentially the same code, which sounds similar what you're doing.

正如网站所解释的,这个设计的部分目的是使它更动态,更容易地让多个APKs使用基本相同的代码创建,这听起来与您正在做的类似。

I probably didn't explain it the best, but that website does a pretty good job.

我可能没有解释得最好,但是这个网站做得很好。

#4


4  

The linked-to solution does not have to be done by hand. Bear in mind that the package attribute in the <manifest> element does not have to be where the code resides, so long as you spell out the fully-qualified classes elsewhere in the manifest (e.g., activity android:name="com.commonsware.android.MyActivity" rather than activity android:name=".MyActivity"). Script your manifest change and use Ant to build a new APK. AFAIK, that should work.

链接的解决方案不必手工完成。请记住, 元素中的package属性不必位于代码所在的位置,只要您在manifest中其他地方拼写出完全限定的类(例如,activity android:name=“com.common swar.android.myactivity”,而不是activity android:name=“. myactivity”)。编写清单更改脚本,并使用Ant构建新的APK。AFAIK,应该工作。

#5


2  

Support Multiple Partners Prepare config.xml

支持多个合作伙伴准备config.xml

Build project for different partner

为不同的合作伙伴构建项目

<!--partner.dir, pkg.name, ver.code, ver.name are input from command line when execute 'ant' -->

<!-- set global properties for this build -->
<property name="build.bin" location="bin"/>
<property name="build.gen" location="gen"/>
<property name="src" location="src"/>
<property name="res" location="res"/>

<target name="preparefiles" description="Prepare files for different partner" >
    <delete dir="${build.bin}" />
    <delete dir="${build.gen}" />

    <copy todir="${res}" overwrite="true" />
        <fileset dir="${partner.dir}/res" /> 
    </copy>

    <!-- change the import in all Java source files -->
    <replaceregexp file="AndroidManifest.xml"
        match='android.versionCode="(.*)"'
        replace='android.versionCode="${ver.code}"'
        byline="false">

    <replaceregexp file="AndroidManifest.xml"
        match='android.versionName="(.*)"'
        replace='android.versionName="${ver.name}"'
        byline="false">

    <replaceregexp file="AndroidManifest.xml"
        match='package="(.*)"'
        replace='package="${pkg.name}"'
        byline="false">

    <!-- change the package name in AndroidManifest -->
    <replaceregexp flags="g" byline="false">
        <regexp pattern="import(.*)com.myproject.com.R;" /> 
        <substitution expression="import com.${pkg.name}.R;" />
        <fileset dir="${src}" includes="**/*.java" /> 
    </replaceregexp>

    <replaceregexp flags="g" byline="false">
        <regexp pattern="(package com.myproject.com;)" /> 
        <substitution expression="\1&#10;import com.${pkg.name}.R;" />
        <fileset dir="${src}" includes="**/*.java" /> 
    </replaceregexp>
</target>

Prepare Files $ ant -f config.xml -Dpartner.dir="xxx" -Dpkg.name="xxx" -Dver.code="xxx" -Dver.name="xxx" preparefiles

准备文件$ ant -f配置。xml -Dpartner。dir =“xxx”-Dpkg.name = -Dver“xxx”。代码=“xxx”-Dver.name = preparefiles“xxx”

Create build.xml Build $ ant debug or $ ant release

创建构建。xml构建$ ant debug或$ ant release

#6


1  

I'm using the maven-android-plugin to achieve this. Specify one AndroidManifest.xml for the generated-sources goal and another AndroidManifest.xml for the final apk goal. That way the source code project retains the actual source code package name during generation of the R class and the build phase, while the market adapted manifest package name is in the second AndroidManifest.xml which is included in the final apk file.

我正在使用maven-android插件来实现这一点。指定一个AndroidManifest。用于生成源目标和另一个AndroidManifest的xml。最终apk目标的xml。这样,源代码项目在生成R类和构建阶段期间保留实际的源代码包名,而市场适应的manifest包名在第二个AndroidManifest中。包含在最终apk文件中的xml。

#7


0  

I wound up with a script that patches the sources; patching the source sounds risky, but in presence of version control the risk is acceptable.

我最后用了一个脚本来修补源文件;修补源代码听起来有风险,但是在版本控制中,风险是可以接受的。

So I made one version, committed the source, made the other version, committed the source, and looking at diffs wrote a patching script in Python.

所以我做了一个版本,提交源代码,另一个版本,提交源代码,看一下diffs用Python编写了一个补丁脚本。

I am not sure if it is the best solution. (And the code misses some os.path.joins)

我不确定这是否是最好的解决办法。(代码漏掉了一些os.path.join)

The heart of the script is the following function:

该脚本的核心功能如下:

# In the file 'fname',
# find the text matching "before oldtext after" (all occurrences) and
# replace 'oldtext' with 'newtext' (all occurrences).
# If 'mandatory' is true, raise an exception if no replacements were made.
def fileReplace(fname,before,newtext,after,mandatory=True):
    with open(fname, 'r+') as f:
    read_data = f.read()
    pattern = r"("+re.escape(before)+r")\w+("+re.escape(after)+r")"
    replacement = r"\1"+newtext+r"\2"
    new_data,replacements_made = re.subn(pattern,replacement,read_data,flags=re.MULTILINE)
    if replacements_made and really:
        f.seek(0)
        f.truncate()
        f.write(new_data)
        if verbose:
            print "patching ",fname," (",replacements_made," occurrence", "s" if 1!=replacements_made else "",")"
    elif replacements_made:
        print fname,":"
        print new_data
    elif mandatory:
        raise Exception("cannot patch the file: "+fname)

And you may find the following one of use:

你可能会发现以下一种用法:

# Change the application resource package name everywhere in the src/ tree.
# Yes, this changes the java files. We hope that if something goes wrong,
# the version control will save us.
def patchResourcePackageNameInSrc(pname):
    for root, dirs, files in os.walk('src'):
    if '.svn' in dirs:
        dirs.remove('.svn')
    for fname in files:
        fileReplace(os.path.join(root,fname),"import com.xyz.",pname,".R;",mandatory=False)

There is also a function that copies assets from x-assets-cfgname to assets (earlier it turned out that for me it is more convenient to have a subdirectory in assets).

还有一个函数可以将资产从x-assets-cfgname复制到资产(早些时候我发现在assets中有子目录更方便)。

def copyAssets(vname,force=False):
    assets_source = "x-assets-"+vname+"/xxx"
    assets_target = "assets/xxx"
    if not os.path.exists(assets_source):
        raise Exception("Invalid variant name: "+vname+" (the assets directory "+assets_source+" does not exist)")
    if os.path.exists(assets_target+"/.svn"):
        raise Exception("The assets directory must not be under version control! "+assets_target+"/.svn exists!")
    if os.path.exists(assets_target):
        shutil.rmtree(assets_target)
    shutil.copytree(assets_source, assets_target, ignore=shutil.ignore_patterns('.svn'))

Well, you get the idea. Now you can write your own script.

你懂的。现在您可以编写自己的脚本了。

#8


0  

I think the best way is to create a new project and copy the stuff. steps, - create new android project without a class - create package (package name should be corresponding to the one in the manifest file), or just copy the package name in the 'gen' folder - copy the java files - copy the drawable folders - copy the layout files - copy any other file(s) used in ur project - copy manifest file's data

我认为最好的方法是创建一个新项目并复制这些东西。步骤,创建新的android项目没有类,创建包(包名称应该对应一个清单文件),或者只是在“创”文件夹中复制包名称- java文件复制拷贝可拉的文件夹-布局文件复制拷贝任何文件用于你的项目(s)-复制清单文件的数据

this has been simpler for me for the task

这对我来说更简单

#1


23  

Perhaps the built-in Android "library" concept was not fully baked at the time of the original post, but it may be the preferred method as of 2011. Follow these steps for an ant build:

或许内置的Android“库”概念在最初发布时还没有完全成熟,但到2011年,它可能是首选的方法。按照以下步骤构建ant:

Starting from a working app (let's call it directory "myOrigApp", package com.foo.myapp), just add this line to "default.properties" to make it a library:

从一个可用的应用程序开始(我们称它为“myOrigApp”,package com.foo.myapp),将这一行添加到“default”。使其成为图书馆:

android.library=true

Now create a new app in a sibling directory in any way you prefer (let's call it directory "sibling", package com.foo.myVariant). Using Intellij Idea, for example, create a project 'from scratch' with directory 'sibling' and it will create all the files/directories you would normally need.

现在,以您喜欢的任何方式在同胞目录中创建一个新的应用程序(让我们将它称为“同胞”目录,包com.foo.myVariant)。例如,使用Intellij Idea,用“sibling”目录创建一个“从头开始”的项目,它将创建您通常需要的所有文件/目录。

In that new, sibling directory edit "default.properties" to add the dependency:

在新的、同级目录编辑“默认”。属性添加依赖项:

android.library.reference.1=../myOrigApp

Copy over the Manifest from the original dir:

复制原署长的舱单:

cd sibling
cp ../myOrigApp/AndroidManifest.xml  ../myOrigApp/local.properties ../myOrigApp/build.properties  .

Edit that copied Manifest file to change its package name to your new variant, "com.foo.myVarient"; that's the only change.

编辑复制的Manifest文件,将其包名更改为新的变体“com.foo.myVarient”;这是唯一的改变。

If you just run the ant build scripts, you may be done. (I had to just set up signing keys.)

如果您只是运行ant构建脚本,那么您可能已经完成了。(我只需要设置签名键。)

If you want to set up an IDE like Idea to have the library project as a dependent of the variant project, follow these steps to add a library project to the variant project (assumes you already have a project set up for both):

如果您想要建立一个IDE,例如将库项目作为一个依赖于该变体项目的项目,请按照以下步骤向该变量项目添加一个库项目(假设您已经为这两个项目设置了一个项目):

  • Open the original project, bring up Project Settings, select your Facet and check "Is Library Project" and save.
  • 打开原始项目,打开项目设置,选择你的面,检查“Is Library project”并保存。
  • Open the variant project, bring up Project Settings, select Modules
  • 打开变体项目,打开项目设置,选择模块
  • Add a module
  • 添加一个模块
  • Select “Import existing module”
  • 选择“导入现有模块”
  • Browse to the Original directory (myOrigApp) and select its .iml file (IntelliJ project source file)
  • 浏览到原始目录(myOrigApp)并选择它的.iml文件(IntelliJ项目源文件)
  • Click "Finish." (The library project is added as a module within the variant project.)
  • 点击“完成”。(在变体项目中,库项目作为模块添加。)
  • In the modules list click over the Variant project to select it.
  • 在模块列表中,单击变体项目以选择它。
  • On the right hand side select the "Dependencies" tab.
  • 在右侧选择“Dependencies”选项卡。
  • Click "Add…"
  • 点击“添加……”
  • Choose "Module dependency…" (A list should appear that includes the name of the module/library you previously added to the project--perhaps the only entry in the list).
  • 选择“模块依赖……”(应该出现一个列表,其中包含先前添加到项目中的模块/库的名称——可能是列表中唯一的条目)。
  • Select the library project you added and press OK. (It will be added to the list of dependencies of your project.)
  • 选择添加的库项目并按OK。(它将被添加到项目的依赖项列表中。)
  • Press OK to finish configuring the project. (You should see 2 modules, with the library's resources and classes available and recognized in the Variant project.)
  • 按OK完成项目配置。(您应该会看到两个模块,其中包含在变体项目中可用的和可识别的库资源和类。)

#2


6  

What I did for something similar to this is to just use an antlib task and then go through all java and xml files to replace my old package string to the new package string. It didn't matter if the files were not in the correct src paths according to the package. Just doing a regex replace for all the files was enough for me to get this working...

我所做的与此类似的事情是使用antlib任务,然后遍历所有java和xml文件,将旧的包字符串替换为新的包字符串。根据包,文件是否在正确的src路径中并不重要。只是做一个regex替换所有的文件就足够让我做这个工作了…

For example to replace it in all your java files under the src directory:

例如,在src目录下的所有java文件中替换它:

 <replaceregexp flags="g" byline="false">
    <regexp pattern="old.package.string" /> 
    <substitution expression="new.package.string" />
    <fileset dir="src" includes="**/*.java" /> 
 </replaceregexp>

#3


5  

You definitely want to use Gradle flavors that comes natively, encouraged even, on Android Studio.

你肯定想在Android Studio中使用本地的、甚至是鼓励的渐变风格。

It seems to explain all the basics really well. I just finished converting to Gradle today, and it works great. Custom app icons, names, and strings, etc.

它似乎很好地解释了所有的基础知识。我今天刚完成了升级,效果很好。自定义应用程序图标、名称和字符串等。

As the website explains, part of the purpose behind this design was to make it more dynamic and more easily allow multiple APKs to be created with essentially the same code, which sounds similar what you're doing.

正如网站所解释的,这个设计的部分目的是使它更动态,更容易地让多个APKs使用基本相同的代码创建,这听起来与您正在做的类似。

I probably didn't explain it the best, but that website does a pretty good job.

我可能没有解释得最好,但是这个网站做得很好。

#4


4  

The linked-to solution does not have to be done by hand. Bear in mind that the package attribute in the <manifest> element does not have to be where the code resides, so long as you spell out the fully-qualified classes elsewhere in the manifest (e.g., activity android:name="com.commonsware.android.MyActivity" rather than activity android:name=".MyActivity"). Script your manifest change and use Ant to build a new APK. AFAIK, that should work.

链接的解决方案不必手工完成。请记住, 元素中的package属性不必位于代码所在的位置,只要您在manifest中其他地方拼写出完全限定的类(例如,activity android:name=“com.common swar.android.myactivity”,而不是activity android:name=“. myactivity”)。编写清单更改脚本,并使用Ant构建新的APK。AFAIK,应该工作。

#5


2  

Support Multiple Partners Prepare config.xml

支持多个合作伙伴准备config.xml

Build project for different partner

为不同的合作伙伴构建项目

<!--partner.dir, pkg.name, ver.code, ver.name are input from command line when execute 'ant' -->

<!-- set global properties for this build -->
<property name="build.bin" location="bin"/>
<property name="build.gen" location="gen"/>
<property name="src" location="src"/>
<property name="res" location="res"/>

<target name="preparefiles" description="Prepare files for different partner" >
    <delete dir="${build.bin}" />
    <delete dir="${build.gen}" />

    <copy todir="${res}" overwrite="true" />
        <fileset dir="${partner.dir}/res" /> 
    </copy>

    <!-- change the import in all Java source files -->
    <replaceregexp file="AndroidManifest.xml"
        match='android.versionCode="(.*)"'
        replace='android.versionCode="${ver.code}"'
        byline="false">

    <replaceregexp file="AndroidManifest.xml"
        match='android.versionName="(.*)"'
        replace='android.versionName="${ver.name}"'
        byline="false">

    <replaceregexp file="AndroidManifest.xml"
        match='package="(.*)"'
        replace='package="${pkg.name}"'
        byline="false">

    <!-- change the package name in AndroidManifest -->
    <replaceregexp flags="g" byline="false">
        <regexp pattern="import(.*)com.myproject.com.R;" /> 
        <substitution expression="import com.${pkg.name}.R;" />
        <fileset dir="${src}" includes="**/*.java" /> 
    </replaceregexp>

    <replaceregexp flags="g" byline="false">
        <regexp pattern="(package com.myproject.com;)" /> 
        <substitution expression="\1&#10;import com.${pkg.name}.R;" />
        <fileset dir="${src}" includes="**/*.java" /> 
    </replaceregexp>
</target>

Prepare Files $ ant -f config.xml -Dpartner.dir="xxx" -Dpkg.name="xxx" -Dver.code="xxx" -Dver.name="xxx" preparefiles

准备文件$ ant -f配置。xml -Dpartner。dir =“xxx”-Dpkg.name = -Dver“xxx”。代码=“xxx”-Dver.name = preparefiles“xxx”

Create build.xml Build $ ant debug or $ ant release

创建构建。xml构建$ ant debug或$ ant release

#6


1  

I'm using the maven-android-plugin to achieve this. Specify one AndroidManifest.xml for the generated-sources goal and another AndroidManifest.xml for the final apk goal. That way the source code project retains the actual source code package name during generation of the R class and the build phase, while the market adapted manifest package name is in the second AndroidManifest.xml which is included in the final apk file.

我正在使用maven-android插件来实现这一点。指定一个AndroidManifest。用于生成源目标和另一个AndroidManifest的xml。最终apk目标的xml。这样,源代码项目在生成R类和构建阶段期间保留实际的源代码包名,而市场适应的manifest包名在第二个AndroidManifest中。包含在最终apk文件中的xml。

#7


0  

I wound up with a script that patches the sources; patching the source sounds risky, but in presence of version control the risk is acceptable.

我最后用了一个脚本来修补源文件;修补源代码听起来有风险,但是在版本控制中,风险是可以接受的。

So I made one version, committed the source, made the other version, committed the source, and looking at diffs wrote a patching script in Python.

所以我做了一个版本,提交源代码,另一个版本,提交源代码,看一下diffs用Python编写了一个补丁脚本。

I am not sure if it is the best solution. (And the code misses some os.path.joins)

我不确定这是否是最好的解决办法。(代码漏掉了一些os.path.join)

The heart of the script is the following function:

该脚本的核心功能如下:

# In the file 'fname',
# find the text matching "before oldtext after" (all occurrences) and
# replace 'oldtext' with 'newtext' (all occurrences).
# If 'mandatory' is true, raise an exception if no replacements were made.
def fileReplace(fname,before,newtext,after,mandatory=True):
    with open(fname, 'r+') as f:
    read_data = f.read()
    pattern = r"("+re.escape(before)+r")\w+("+re.escape(after)+r")"
    replacement = r"\1"+newtext+r"\2"
    new_data,replacements_made = re.subn(pattern,replacement,read_data,flags=re.MULTILINE)
    if replacements_made and really:
        f.seek(0)
        f.truncate()
        f.write(new_data)
        if verbose:
            print "patching ",fname," (",replacements_made," occurrence", "s" if 1!=replacements_made else "",")"
    elif replacements_made:
        print fname,":"
        print new_data
    elif mandatory:
        raise Exception("cannot patch the file: "+fname)

And you may find the following one of use:

你可能会发现以下一种用法:

# Change the application resource package name everywhere in the src/ tree.
# Yes, this changes the java files. We hope that if something goes wrong,
# the version control will save us.
def patchResourcePackageNameInSrc(pname):
    for root, dirs, files in os.walk('src'):
    if '.svn' in dirs:
        dirs.remove('.svn')
    for fname in files:
        fileReplace(os.path.join(root,fname),"import com.xyz.",pname,".R;",mandatory=False)

There is also a function that copies assets from x-assets-cfgname to assets (earlier it turned out that for me it is more convenient to have a subdirectory in assets).

还有一个函数可以将资产从x-assets-cfgname复制到资产(早些时候我发现在assets中有子目录更方便)。

def copyAssets(vname,force=False):
    assets_source = "x-assets-"+vname+"/xxx"
    assets_target = "assets/xxx"
    if not os.path.exists(assets_source):
        raise Exception("Invalid variant name: "+vname+" (the assets directory "+assets_source+" does not exist)")
    if os.path.exists(assets_target+"/.svn"):
        raise Exception("The assets directory must not be under version control! "+assets_target+"/.svn exists!")
    if os.path.exists(assets_target):
        shutil.rmtree(assets_target)
    shutil.copytree(assets_source, assets_target, ignore=shutil.ignore_patterns('.svn'))

Well, you get the idea. Now you can write your own script.

你懂的。现在您可以编写自己的脚本了。

#8


0  

I think the best way is to create a new project and copy the stuff. steps, - create new android project without a class - create package (package name should be corresponding to the one in the manifest file), or just copy the package name in the 'gen' folder - copy the java files - copy the drawable folders - copy the layout files - copy any other file(s) used in ur project - copy manifest file's data

我认为最好的方法是创建一个新项目并复制这些东西。步骤,创建新的android项目没有类,创建包(包名称应该对应一个清单文件),或者只是在“创”文件夹中复制包名称- java文件复制拷贝可拉的文件夹-布局文件复制拷贝任何文件用于你的项目(s)-复制清单文件的数据

this has been simpler for me for the task

这对我来说更简单