Class: Pindo::AndroidBuildHelper
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ApkHelper
#build_aab, #build_apk
#find_android_subproject, #get_build_tools, #get_ext_values, #get_keystore_config, #get_main_module, #modify_il2cpp_config, #remove_desktop_google_service, #unity_android_project?
Methods included from SoHelper
#build_so_library, #copy_so_files
#check_gradle_files, #update_build_gradle, #update_gradle_version
Class Method Details
.share_instance ⇒ Object
16
17
18
|
# File 'lib/pindo/module/android/build_helper.rb', line 16
def share_instance
instance
end
|
Instance Method Details
#auto_build_apk(project_dir, debug = false, ignore_sub = false) ⇒ Object
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
|
# File 'lib/pindo/module/android/build_helper.rb', line 21
def auto_build_apk(project_dir, debug = false, ignore_sub = false)
gradle_properties_path = File.join(project_dir, "gradle.properties")
if File.exist?(gradle_properties_path)
puts "检查 gradle.properties 中的 Java Home 设置..."
content = File.read(gradle_properties_path)
java_home_match = content.match(/org\.gradle\.java\.home\s*=\s*(.+)/)
if java_home_match && !java_home_match[1].empty?
java_home_path = java_home_match[1].strip
puts "找到 Java Home 路径: #{java_home_path}"
ENV['JAVA_HOME'] = java_home_path
ENV['PATH'] = "#{java_home_path}/bin:#{ENV['PATH']}"
puts "已设置 JAVA_HOME 环境变量为: #{java_home_path}"
puts "Java 版本信息:"
system("java -version")
end
end
if !ignore_sub
sub_android_dir = find_android_subproject(project_dir)
if sub_android_dir
prepare_proj(sub_android_dir)
unless build_so_library(sub_android_dir)
raise RuntimeError, "编译SO库失败:"
end
copy_so_files(sub_android_dir, project_dir)
end
end
prepare_proj(project_dir)
build_apk(project_dir, debug)
end
|
#dsign(project_path, debug) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/pindo/module/android/build_helper.rb', line 82
def dsign(project_path, debug)
keystore_config = get_keystore_config(project_path, debug)
ks = keystore_config[:store_file]
puts "读取 keystore path = #{ks}"
ks_pass = keystore_config[:store_password]
puts "读取 keystore pass = #{ks_pass}"
key_alias = keystore_config[:key_alias]
puts "读取 key alias = #{key_alias}"
key_pass = keystore_config[:key_password]
puts "读取 key pass = #{key_pass}"
end
|
#get_application_id(project_path) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/pindo/module/android/build_helper.rb', line 57
def get_application_id(project_path)
main_module = get_main_module(project_path)
return nil unless main_module
gradle_path = File.join(main_module, "build.gradle")
if File.exist?(gradle_path)
content = File.read(gradle_path)
if content =~ /applicationId\s+['"]([^'"]+)['"]/
return $1
end
end
manifest_path = File.join(main_module, "src", "main", "AndroidManifest.xml")
if File.exist?(manifest_path)
require 'nokogiri'
doc = Nokogiri::XML(File.read(manifest_path))
package = doc.at_xpath('//manifest/@package')&.value
return package if package
end
nil
end
|