@@ -297,6 +297,13 @@ Future<void> buildGradleApp({
297297 command.add ('-Plocal-engine-repo=${localEngineRepo .path }' );
298298 command.add ('-Plocal-engine-build-mode=${buildInfo .modeName }' );
299299 command.add ('-Plocal-engine-out=${localEngineArtifacts .engineOutPath }' );
300+ command.add ('-Ptarget-platform=${_getTargetPlatformByLocalEnginePath (
301+ localEngineArtifacts .engineOutPath )}' );
302+ } else if (androidBuildInfo.targetArchs.isNotEmpty) {
303+ final String targetPlatforms = androidBuildInfo
304+ .targetArchs
305+ .map (getPlatformNameForAndroidArch).join (',' );
306+ command.add ('-Ptarget-platform=$targetPlatforms ' );
300307 }
301308 if (target != null ) {
302309 command.add ('-Ptarget=$target ' );
@@ -322,12 +329,6 @@ Future<void> buildGradleApp({
322329 if (androidBuildInfo.shrink) {
323330 command.add ('-Pshrink=true' );
324331 }
325- if (androidBuildInfo.targetArchs.isNotEmpty) {
326- final String targetPlatforms = androidBuildInfo
327- .targetArchs
328- .map (getPlatformNameForAndroidArch).join (',' );
329- command.add ('-Ptarget-platform=$targetPlatforms ' );
330- }
331332 if (shouldBuildPluginAsAar) {
332333 // Pass a system flag instead of a project flag, so this flag can be
333334 // read from include_flutter.groovy.
@@ -537,11 +538,6 @@ Future<void> buildGradleAar({
537538 command.add ('-Ptarget=$target ' );
538539 }
539540
540- if (androidBuildInfo.targetArchs.isNotEmpty) {
541- final String targetPlatforms = androidBuildInfo.targetArchs
542- .map (getPlatformNameForAndroidArch).join (',' );
543- command.add ('-Ptarget-platform=$targetPlatforms ' );
544- }
545541 if (globals.artifacts is LocalEngineArtifacts ) {
546542 final LocalEngineArtifacts localEngineArtifacts = globals.artifacts as LocalEngineArtifacts ;
547543 final Directory localEngineRepo = _getLocalEngineRepo (
@@ -571,6 +567,12 @@ Future<void> buildGradleAar({
571567 'in ${outputDirectory .path }'
572568 );
573569 }
570+ command.add ('-Ptarget-platform=${_getTargetPlatformByLocalEnginePath (
571+ localEngineArtifacts .engineOutPath )}' );
572+ } else if (androidBuildInfo.targetArchs.isNotEmpty) {
573+ final String targetPlatforms = androidBuildInfo.targetArchs
574+ .map (getPlatformNameForAndroidArch).join (',' );
575+ command.add ('-Ptarget-platform=$targetPlatforms ' );
574576 }
575577
576578 command.add (aarTask);
@@ -928,7 +930,7 @@ Directory _getLocalEngineRepo({
928930 assert (engineOutPath != null );
929931 assert (androidBuildInfo != null );
930932
931- final String abi = getEnumName (androidBuildInfo.targetArchs.first );
933+ final String abi = _getAbiByLocalEnginePath (engineOutPath );
932934 final Directory localEngineRepo = globals.fs.systemTempDirectory
933935 .createTempSync ('flutter_tool_local_engine_repo.' );
934936
@@ -979,3 +981,27 @@ Directory _getLocalEngineRepo({
979981 }
980982 return localEngineRepo;
981983}
984+
985+ String _getAbiByLocalEnginePath (String engineOutPath) {
986+ String result = 'armeabi_v7a' ;
987+ if (engineOutPath.contains ('x86' )) {
988+ result = 'x86' ;
989+ } else if (engineOutPath.contains ('x64' )) {
990+ result = 'x86_64' ;
991+ } else if (engineOutPath.contains ('arm64' )) {
992+ result = 'arm64_v8a' ;
993+ }
994+ return result;
995+ }
996+
997+ String _getTargetPlatformByLocalEnginePath (String engineOutPath) {
998+ String result = 'android-arm' ;
999+ if (engineOutPath.contains ('x86' )) {
1000+ result = 'android-x86' ;
1001+ } else if (engineOutPath.contains ('x64' )) {
1002+ result = 'android-x64' ;
1003+ } else if (engineOutPath.contains ('arm64' )) {
1004+ result = 'android-arm64' ;
1005+ }
1006+ return result;
1007+ }
0 commit comments