@@ -64,44 +64,36 @@ fn build_apks(
64
64
. join ( "build-tools" )
65
65
. join ( & config. build_tools_version ) ;
66
66
let aapt_path = build_tools_path. join ( "aapt" ) ;
67
- let aapt2_path = build_tools_path. join ( "aapt2" ) ;
68
67
let zipalign_path = build_tools_path. join ( "zipalign" ) ;
69
68
70
- // Compile resources
71
- let compiled_resources_filename = "resources.zip" ;
72
- if let Some ( res_path) = & target_config. res_path {
73
- process ( & aapt2_path)
74
- . arg ( "compile" )
75
- . arg ( "--dir" )
76
- . arg ( res_path)
77
- . arg ( "-o" )
78
- . arg ( compiled_resources_filename)
79
- . cwd ( & target_directory)
80
- . exec ( ) ?;
69
+ // Create unaligned APK which includes resources and assets
70
+ let unaligned_apk_name = format ! ( "{}_unaligned.apk" , target. name( ) ) ;
71
+ let unaligned_apk_path = target_directory. join ( & unaligned_apk_name) ;
72
+ if unaligned_apk_path. exists ( ) {
73
+ std:: fs:: remove_file ( unaligned_apk_path)
74
+ . map_err ( |e| format_err ! ( "Unable to delete APK file. {}" , e) ) ?;
81
75
}
82
76
83
- // Create unaligned APK which includes resources
84
- let unaligned_apk_name = format ! ( "{}_unaligned.apk" , target. name( ) ) ;
85
- let mut aapt2_link_cmd = process ( & aapt2_path) ;
86
- aapt2_link_cmd
87
- . arg ( "link" )
88
- . arg ( "-o" )
77
+ let mut aapt_package_cmd = process ( & aapt_path) ;
78
+ aapt_package_cmd
79
+ . arg ( "package" )
80
+ . arg ( "-F" )
89
81
. arg ( & unaligned_apk_name)
90
- . arg ( "--manifest " )
82
+ . arg ( "-M " )
91
83
. arg ( "AndroidManifest.xml" )
92
84
. arg ( "-I" )
93
85
. arg ( & config. android_jar_path ) ;
94
86
95
- if target_config. res_path . is_some ( ) {
96
- aapt2_link_cmd . arg ( compiled_resources_filename ) ;
87
+ if let Some ( res_path ) = target_config. res_path {
88
+ aapt_package_cmd . arg ( "-S" ) . arg ( res_path ) ;
97
89
}
98
90
99
91
// Link assets
100
92
if let Some ( assets_path) = & target_config. assets_path {
101
- aapt2_link_cmd . arg ( "-A" ) . arg ( assets_path) ;
93
+ aapt_package_cmd . arg ( "-A" ) . arg ( assets_path) ;
102
94
}
103
95
104
- aapt2_link_cmd . cwd ( & target_directory) . exec ( ) ?;
96
+ aapt_package_cmd . cwd ( & target_directory) . exec ( ) ?;
105
97
106
98
// Add shared libraries to the APK
107
99
for shared_library in shared_libraries {
0 commit comments