Skip to content

Instantly share code, notes, and snippets.

@zeuxisoo
Created May 30, 2011 01:48
Show Gist options
  • Select an option

  • Save zeuxisoo/998348 to your computer and use it in GitHub Desktop.

Select an option

Save zeuxisoo/998348 to your computer and use it in GitHub Desktop.
Titanium - Change the app name to support chinese/other word on android

Step 1

  1. open current titanium project (e.g. TestTabIcon/build/android/AndroidManifest.xml)

  2. update the app name

    android:label="TestTabIcon" to android:label="什麼都好"

  3. press cmd + i on AndroidManifest.xml

  4. change sharing & permissions

    all Names should be Read Only

Step 2

Open Direcotry

/Library/Application Support/Titanium/mobilesdk/osx/1.7.0.RC1/android

Open builder.py

Find (Line. 1060)

if new_manifest_contents != old_contents:
	trace("Writing out AndroidManifest.xml")
	amf = open(android_manifest,'w')
	amf.write(new_manifest_contents)
	amf.close()
	manifest_changed = True

Change to

if new_manifest_contents != old_contents:
	pass
	#trace("Writing out AndroidManifest.xml")
	#amf = open(android_manifest,'w')
	#amf.write(new_manifest_contents)
	#amf.close()
	#manifest_changed = True

Open android.py

Find (Line. 102)

def render(self, template_dir, template_file, dest, dest_file, **kwargs):
	tmpl = self.load_template(os.path.join(template_dir, 'templates', template_file))
	f = None
	try:
		print "[TRACE] Generating %s" % os.path.join(dest, dest_file)
		f = open(os.path.join(dest, dest_file), "w")
		f.write(tmpl.render(config = self.config, **kwargs))
	finally:
		if f!=None: f.close

Change to

def render(self, template_dir, template_file, dest, dest_file, **kwargs):
	tmpl = self.load_template(os.path.join(template_dir, 'templates', template_file))
	f = None
	if dest_file != "AndroidManifest.xml":
		try:
			print "[TRACE] Generating %s" % os.path.join(dest, dest_file)
			f = open(os.path.join(dest, dest_file), "w")
			f.write(tmpl.render(config = self.config, **kwargs))
		finally:
			if f!=None: f.close
	else:
		print "[TRACE] Skip AndroidManifest.xml ..................................";

Step 3

Try to build on device again

Q&A

  • Can not found AndroidManifest.xml

    Please recovery all step and build once after to try again

  • Can not found the direcotry

    In this case, it is 1.7.0 RC1, please change your current titanium version and try again

  • Can not see the change on emulator

    Please try to install on device

  • Can not see the change on device

    Please try to install on device and make sure the exists app was deleted first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment