Titanium 開發 Android App 時使用中文名稱


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Step 1
1. 打開專案 (例如. TestTabIcon/build/android/AndroidManifest.xml)

2. 找到以下句子並更改檔案 App 名稱
android:label="TestTabIcon" to android:label="什麼都好"

3. 按下 cmd + i 在 AndroidManifest.xml 之上

4. 改變權限 "sharing & permissions"
所有用戶群集都是 "只讀"

Step 2
1. 打開目錄 (注: 這裡為 1.7.0 RC1)
/Library/Application Support/Titanium/mobilesdk/osx/1.7.0.RC1/android

2. 打開 builder.py
找到

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

改為

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

3. 打開 android.py
找到

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

改為

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
1. 重新安裝到模擬器上

*** 註意地方
1. 找不到 AndroidManifest.xml
請還原以上步驟,先 Build 出第一次

2. 找不到 Step 2 目錄
請將 1.7.0 RC 換成你的 SDK 版本再試

3. 在模擬器看不到已經變更
請再嘗試安裝到真機上

4. 在真機上看不到已變更
請移除原有的 App 再安裝試試