use of com.android.tools.idea.run.ApkProvisionException in project intellij by bazelbuild.
the class BlazeAndroidBinaryApplicationIdProvider method getPackageName.
@Override
public String getPackageName() throws ApkProvisionException {
BlazeAndroidDeployInfo deployInfo = buildStep.getDeployInfo();
Manifest manifest = deployInfo.getMergedManifest();
if (manifest == null) {
throw new ApkProvisionException("Could not find merged manifest: " + deployInfo.getMergedManifestFile());
}
String applicationId = ApplicationManager.getApplication().runReadAction((Computable<String>) () -> manifest.getPackage().getValue());
if (applicationId == null) {
throw new ApkProvisionException("No application id in merged manifest: " + deployInfo.getMergedManifestFile());
}
return applicationId;
}
use of com.android.tools.idea.run.ApkProvisionException in project intellij by bazelbuild.
the class BlazeAndroidBinaryApplicationLaunchTaskProvider method getApplicationLaunchTask.
public static LaunchTask getApplicationLaunchTask(Project project, ApplicationIdProvider applicationIdProvider, File mergedManifestFile, BlazeAndroidBinaryRunConfigurationState configState, StartActivityFlagsProvider startActivityFlagsProvider, ProcessHandlerLaunchStatus processHandlerLaunchStatus) {
try {
String applicationId = applicationIdProvider.getPackageName();
final LaunchTask launchTask;
switch(configState.getMode()) {
case BlazeAndroidBinaryRunConfigurationState.DO_NOTHING:
launchTask = null;
break;
case BlazeAndroidBinaryRunConfigurationState.LAUNCH_DEFAULT_ACTIVITY:
BlazeDefaultActivityLocator activityLocator = new BlazeDefaultActivityLocator(project, mergedManifestFile);
launchTask = new DefaultActivityLaunchTask(applicationId, activityLocator, startActivityFlagsProvider);
break;
case BlazeAndroidBinaryRunConfigurationState.LAUNCH_SPECIFIC_ACTIVITY:
launchTask = new SpecificActivityLaunchTask(applicationId, configState.getActivityClass(), startActivityFlagsProvider);
break;
case BlazeAndroidBinaryRunConfigurationState.LAUNCH_DEEP_LINK:
launchTask = new AndroidDeepLinkLaunchTask(configState.getDeepLink(), startActivityFlagsProvider);
break;
default:
launchTask = null;
break;
}
return launchTask;
} catch (ApkProvisionException e) {
LOG.error(e);
processHandlerLaunchStatus.terminateLaunch("Unable to identify application id");
return null;
}
}
use of com.android.tools.idea.run.ApkProvisionException in project intellij by bazelbuild.
the class BlazeAndroidBinaryNormalBuildRunContext method getApplicationLaunchTask.
@Override
public LaunchTask getApplicationLaunchTask(LaunchOptions launchOptions, @Nullable Integer userId, AndroidDebugger androidDebugger, AndroidDebuggerState androidDebuggerState, ProcessHandlerLaunchStatus processHandlerLaunchStatus) throws ExecutionException {
final StartActivityFlagsProvider startActivityFlagsProvider = new DefaultStartActivityFlagsProvider(androidDebugger, androidDebuggerState, project, launchOptions.isDebug(), UserIdHelper.getFlagsFromUserId(userId));
BlazeAndroidDeployInfo deployInfo;
try {
deployInfo = buildStep.getDeployInfo();
} catch (ApkProvisionException e) {
throw new ExecutionException(e);
}
return BlazeAndroidBinaryApplicationLaunchTaskProvider.getApplicationLaunchTask(project, applicationIdProvider, deployInfo.getMergedManifestFile(), configState, startActivityFlagsProvider, processHandlerLaunchStatus);
}
use of com.android.tools.idea.run.ApkProvisionException in project intellij by bazelbuild.
the class BlazeAndroidLaunchTasksProvider method getConnectDebuggerTask.
@Nullable
@Override
public DebugConnectorTask getConnectDebuggerTask(@NotNull LaunchStatus launchStatus, @Nullable AndroidVersion version) {
if (!isDebug) {
return null;
}
Set<String> packageIds = Sets.newHashSet();
try {
String packageName = applicationIdProvider.getPackageName();
packageIds.add(packageName);
} catch (ApkProvisionException e) {
Logger.getInstance(AndroidLaunchTasksProvider.class).error(e);
}
try {
String packageName = applicationIdProvider.getTestPackageName();
if (packageName != null) {
packageIds.add(packageName);
}
} catch (ApkProvisionException e) {
// not as severe as failing to obtain package id for main application
Logger.getInstance(AndroidLaunchTasksProvider.class).warn("Unable to obtain test package name, will not connect debugger " + "if tests don't instantiate main application");
}
AndroidDebugger androidDebugger = debuggerManager.getAndroidDebugger();
AndroidDebuggerState androidDebuggerState = debuggerManager.getAndroidDebuggerState(project);
if (androidDebugger == null || androidDebuggerState == null) {
return null;
}
try {
return runContext.getDebuggerTask(androidDebugger, androidDebuggerState, packageIds, monitorRemoteProcess());
} catch (ExecutionException e) {
launchStatus.terminateLaunch(e.getMessage());
return null;
}
}
use of com.android.tools.idea.run.ApkProvisionException in project intellij by bazelbuild.
the class BlazeAndroidTestApplicationIdProvider method getPackageName.
@Override
public String getPackageName() throws ApkProvisionException {
BlazeAndroidDeployInfo deployInfo = buildStep.getDeployInfo();
Manifest manifest = Iterables.getFirst(deployInfo.getAdditionalMergedManifests(), null);
if (manifest == null) {
// and can instead be in the same package as the tests.
return getTestPackageName();
}
String applicationId = ApplicationManager.getApplication().runReadAction((Computable<String>) () -> manifest.getPackage().getValue());
if (applicationId == null) {
throw new ApkProvisionException("No application id in manifest under test");
}
return applicationId;
}
Aggregations