Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
80cafba2
Commit
80cafba2
authored
Apr 24, 2019
by
Pavitra Golchha
Committed by
Jeffrey Schiller
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace JarSigner with ApkSigner (#1417)
Replace JarSigner with ApkSigner
parent
71b2e0aa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
48 deletions
+42
-48
appinventor/buildserver/src/com/google/appinventor/buildserver/Compiler.java
...rver/src/com/google/appinventor/buildserver/Compiler.java
+41
-48
appinventor/components/build.xml
appinventor/components/build.xml
+1
-0
appinventor/lib/android/tools/apksigner.jar
appinventor/lib/android/tools/apksigner.jar
+0
-0
No files found.
appinventor/buildserver/src/com/google/appinventor/buildserver/Compiler.java
View file @
80cafba2
...
...
@@ -133,6 +133,8 @@ public final class Compiler {
RUNTIME_FILES_DIR
+
"kawa.jar"
;
private
static
final
String
SIMPLE_ANDROID_RUNTIME_JAR
=
RUNTIME_FILES_DIR
+
"AndroidRuntime.jar"
;
private
static
final
String
APKSIGNER_JAR
=
RUNTIME_FILES_DIR
+
"apksigner.jar"
;
private
static
final
String
LINUX_AAPT_TOOL
=
"/tools/linux/aapt"
;
...
...
@@ -1134,18 +1136,18 @@ public final class Compiler {
reporter
.
report
(
95
);
}
// Sign the apk file
out
.
println
(
"________Signing the apk file"
);
if
(!
compiler
.
runJarSigner
(
apkAbsolutePath
,
keystoreFilePath
))
{
return
false
;
}
// ZipAlign the apk file
out
.
println
(
"________ZipAligning the apk file"
);
if
(!
compiler
.
runZipAlign
(
apkAbsolutePath
,
tmpDir
))
{
return
false
;
}
// Sign the apk file
out
.
println
(
"________Signing the apk file"
);
if
(!
compiler
.
runApkSigner
(
apkAbsolutePath
,
keystoreFilePath
))
{
return
false
;
}
if
(
reporter
!=
null
)
{
reporter
.
report
(
100
);
}
...
...
@@ -1439,47 +1441,6 @@ public final class Compiler {
return
true
;
}
private
boolean
runJarSigner
(
String
apkAbsolutePath
,
String
keystoreAbsolutePath
)
{
// TODO(user): maybe make a command line flag for the jarsigner location
String
javaHome
=
System
.
getProperty
(
"java.home"
);
// This works on Mac OS X.
File
jarsignerFile
=
new
File
(
javaHome
+
SLASH
+
"bin"
+
SLASH
+
"jarsigner"
);
if
(!
jarsignerFile
.
exists
())
{
// This works when a JDK is installed with the JRE.
jarsignerFile
=
new
File
(
javaHome
+
SLASH
+
".."
+
SLASH
+
"bin"
+
SLASH
+
"jarsigner"
);
if
(
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
))
{
jarsignerFile
=
new
File
(
javaHome
+
SLASH
+
".."
+
SLASH
+
"bin"
+
SLASH
+
"jarsigner.exe"
);
}
if
(!
jarsignerFile
.
exists
())
{
LOG
.
warning
(
"YAIL compiler - could not find jarsigner."
);
err
.
println
(
"YAIL compiler - could not find jarsigner."
);
userErrors
.
print
(
String
.
format
(
ERROR_IN_STAGE
,
"JarSigner"
));
return
false
;
}
}
String
[]
jarsignerCommandLine
=
{
jarsignerFile
.
getAbsolutePath
(),
"-digestalg"
,
"SHA1"
,
"-sigalg"
,
"MD5withRSA"
,
"-keystore"
,
keystoreAbsolutePath
,
"-storepass"
,
"android"
,
apkAbsolutePath
,
"AndroidKey"
};
if
(!
Execution
.
execute
(
null
,
jarsignerCommandLine
,
System
.
out
,
System
.
err
))
{
LOG
.
warning
(
"YAIL compiler - jarsigner execution failed."
);
err
.
println
(
"YAIL compiler - jarsigner execution failed."
);
userErrors
.
print
(
String
.
format
(
ERROR_IN_STAGE
,
"JarSigner"
));
return
false
;
}
return
true
;
}
private
boolean
runZipAlign
(
String
apkAbsolutePath
,
File
tmpDir
)
{
// TODO(user): add zipalign tool appinventor->lib->android->tools->linux and windows
// Need to make sure assets directory exists otherwise zipalign will fail.
...
...
@@ -1500,7 +1461,7 @@ public final class Compiler {
}
// TODO: create tmp file for zipaling result
String
zipAlignedPath
=
tmpDir
.
getAbsolutePath
()
+
SLASH
+
"zipaligned.apk"
;
// zipalign -f
-v
4 infile.zip outfile.zip
// zipalign -f 4 infile.zip outfile.zip
String
[]
zipAlignCommandLine
=
{
getResource
(
zipAlignTool
),
"-f"
,
...
...
@@ -1530,6 +1491,38 @@ public final class Compiler {
return
true
;
}
private
boolean
runApkSigner
(
String
apkAbsolutePath
,
String
keystoreAbsolutePath
)
{
int
mx
=
childProcessRamMb
-
200
;
/*
apksigner sign\
--ks <keystore file>\
--ks-key-alias AndroidKey\
--ks-pass pass:android\
<APK>
*/
String
[]
apksignerCommandLine
=
{
System
.
getProperty
(
"java.home"
)
+
"/bin/java"
,
"-jar"
,
"-mx"
+
mx
+
"M"
,
getResource
(
APKSIGNER_JAR
),
"sign"
,
"-ks"
,
keystoreAbsolutePath
,
"-ks-key-alias"
,
"AndroidKey"
,
"-ks-pass"
,
"pass:android"
,
apkAbsolutePath
};
long
startApkSigner
=
System
.
currentTimeMillis
();
if
(!
Execution
.
execute
(
null
,
apksignerCommandLine
,
System
.
out
,
System
.
err
))
{
LOG
.
warning
(
"YAIL compiler - apksigner execution failed."
);
err
.
println
(
"YAIL compiler - apksigner execution failed."
);
userErrors
.
print
(
String
.
format
(
ERROR_IN_STAGE
,
"APKSIGNER"
));
return
false
;
}
String
apkSignerTimeMessage
=
"APKSIGNER time: "
+
((
System
.
currentTimeMillis
()
-
startApkSigner
)
/
1000.0
)
+
" seconds"
;
out
.
println
(
apkSignerTimeMessage
);
LOG
.
info
(
apkSignerTimeMessage
);
return
true
;
}
/*
* Loads the icon for the application, either a user provided one or the default one.
*/
...
...
appinventor/components/build.xml
View file @
80cafba2
...
...
@@ -180,6 +180,7 @@
<!-- END Android Support Libraries -->
<copy
toFile=
"${public.deps.dir}/android.jar"
file=
"${lib.dir}/android/android-26/android.jar"
/>
<copy
toFile=
"${public.deps.dir}/dx.jar"
file=
"${lib.dir}/android/tools/dx.jar"
/>
<copy
toFile=
"${public.deps.dir}/apksigner.jar"
file=
"${lib.dir}/android/tools/apksigner.jar"
/>
<copy
toFile=
"${public.deps.dir}/CommonVersion.jar"
file=
"${build.dir}/common/CommonVersion.jar"
/>
<!-- Add extension libraries here -->
...
...
appinventor/lib/android/tools/apksigner.jar
0 → 100644
View file @
80cafba2
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment