Commit 70d7fe3a authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Revert "Replace jarsigner with apksigner" (#8164)

parent b38a6cbb
......@@ -102,7 +102,7 @@ Instructions to update the Android Tools version that the bots download by execu
The following packages are currently installed:
* Android SDK Tools
* Android SDK platform-tools
* Android SDK Build-tools 24.0.3
* Android SDK Build-tools 23.0.1
* Android 6.0 (API 23)
* SDK Platform 23
* Extras
......
efeebca78800d6855e15a22c6087a54766d1d4e9
0d320c50b0ed188c7e1182388e2beb623a1d307d
7eb88931c39c05a3b140da769e67c216d45db2b9
fa5ea0ca1e0c7c2e40914f3202c7545de4dbca9c
4b0d8fa0dcacd537330149332a28e033edfd3ca8
e5715e2cc0d5644a241a4b3281bfada92bc145c2
......@@ -24,7 +24,6 @@ const String kAndroidHome = 'ANDROID_HOME';
// $ANDROID_HOME/build-tools/22.0.1/aapt
// $ANDROID_HOME/build-tools/23.0.2/aapt
// $ANDROID_HOME/build-tools/24.0.0-preview/aapt
// $ANDROID_HOME/build-tools/25.0.2/apksigner
// $ANDROID_HOME/platforms/android-22/android.jar
// $ANDROID_HOME/platforms/android-23/android.jar
......@@ -226,8 +225,6 @@ class AndroidSdkVersion implements Comparable<AndroidSdkVersion> {
String get zipalignPath => getBuildToolsPath('zipalign');
String get apksignerPath => getBuildToolsPath('apksigner');
List<String> validateSdkWellFormed() {
if (_exists(androidJarPath) != null)
return <String>[_exists(androidJarPath)];
......@@ -241,9 +238,6 @@ class AndroidSdkVersion implements Comparable<AndroidSdkVersion> {
if (_canRun(zipalignPath) != null)
return <String>[_canRun(zipalignPath)];
if (_canRun(apksignerPath) != null)
return <String>[_canRun(apksignerPath) + '\napksigner requires Android SDK Build Tools 24.0.3 or newer.'];
return <String>[];
}
......
......@@ -5,6 +5,7 @@
import 'dart:async';
import '../base/io.dart';
import '../base/os.dart';
import '../base/platform.dart';
import '../base/process_manager.dart';
import '../doctor.dart';
......@@ -62,11 +63,11 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
}
List<String> validationResult = androidSdk.validateSdkWellFormed();
// Empty result means SDK is well formated.
if (validationResult.isEmpty) {
// Empty result means SDK is well formatted.
// The SDK also requires a valid Java JDK installation.
const String _kJdkDownload = 'https://www.oracle.com/technetwork/java/javase/downloads/';
String javaVersion;
try {
......@@ -81,20 +82,27 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
} catch (error) {
}
if (javaVersion == null) {
if (javaVersion != null) {
messages.add(new ValidationMessage(javaVersion));
if (os.which('jarsigner') == null) {
messages.add(new ValidationMessage.error(
'The jarsigner utility was not found; this is used to build Android APKs. You may need to install\n'
'or re-install the Java JDK: $_kJdkDownload.'
));
} else {
type = ValidationType.installed;
}
} else {
messages.add(new ValidationMessage.error(
'No Java Development Kit (JDK) found; you can download the JDK from $_kJdkDownload.'
'No Java Development Kit (JDK) found; you can download the JDK from $_kJdkDownload.'
));
} else {
type = ValidationType.installed;
}
} else {
messages.addAll(validationResult.map((String message) {
return new ValidationMessage.error(message);
}));
messages.add(new ValidationMessage(
'Try re-installing or updating your Android SDK,\n'
'visit https://flutter.io/setup/#android-setup for detailed instructions.'));
messages.add(new ValidationMessage('Try re-installing or updating your Android SDK.'));
}
}
......
......@@ -10,6 +10,7 @@ import '../android/gradle.dart';
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/os.dart';
import '../base/process.dart';
import '../base/process_manager.dart';
import '../base/utils.dart';
......@@ -67,14 +68,14 @@ class _ApkBuilder {
File _aapt;
File _dx;
File _zipalign;
File _apksigner;
File _jarsigner;
_ApkBuilder(this.sdk) {
_androidJar = fs.file(sdk.androidJarPath);
_aapt = fs.file(sdk.aaptPath);
_dx = fs.file(sdk.dxPath);
_zipalign = fs.file(sdk.zipalignPath);
_apksigner = fs.file(sdk.apksignerPath);
_jarsigner = os.which('jarsigner');
}
String checkDependencies() {
......@@ -86,8 +87,10 @@ class _ApkBuilder {
return 'Cannot find dx at ${_dx.path}';
if (!processManager.canRun(_zipalign.path))
return 'Cannot find zipalign at ${_zipalign.path}';
if (!processManager.canRun(_apksigner.path))
return 'Cannot find apksigner at ${_apksigner.path}';
if (_jarsigner == null)
return 'Cannot find jarsigner in PATH.';
if (!_jarsigner.existsSync())
return 'Cannot find jarsigner at ${_jarsigner.path}';
return null;
}
......@@ -120,13 +123,15 @@ class _ApkBuilder {
}
void sign(File keystore, String keystorePassword, String keyAlias, String keyPassword, File outputApk) {
assert(_apksigner != null);
runCheckedSync(<String>[_apksigner.path, 'sign',
'--ks', keystore.path,
'--ks-key-alias', keyAlias,
'--ks-pass', 'pass:$keystorePassword',
'--key-pass', 'pass:$keyPassword',
assert(_jarsigner != null);
runCheckedSync(<String>[_jarsigner.path,
'-keystore', keystore.path,
'-storepass', keystorePassword,
'-keypass', keyPassword,
'-digestalg', 'SHA1',
'-sigalg', 'MD5withRSA',
outputApk.path,
keyAlias,
]);
}
......@@ -366,14 +371,15 @@ int _buildApk(
unalignedApk, components.manifest, assetBuilder.directory,
artifactBuilder.directory, components.resources, buildMode
);
File finalApk = fs.file(outputFile);
ensureDirectoryExists(finalApk.path);
builder.align(unalignedApk, finalApk);
int signResult = _signApk(builder, components, finalApk, keystore, buildMode);
int signResult = _signApk(builder, components, unalignedApk, keystore, buildMode);
if (signResult != 0)
return signResult;
File finalApk = fs.file(outputFile);
ensureDirectoryExists(finalApk.path);
builder.align(unalignedApk, finalApk);
printTrace('calculateSha: $outputFile');
File apkShaFile = fs.file('$outputFile.sha1');
apkShaFile.writeAsStringSync(calculateSha(finalApk));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment