Inclusion Criteria:  Histologically or cytologically confirmed diagnosis of an advanced, unresectable and/or metastatic non-haematologic malignancy. Patient must have measurable or evaluable lesions (according to Response Evaluation Criteria In Solid Tumors (RECIST) 1.1). Eastern Cooperative Oncology Group score of 0 or 1 Availability and patient willingness to provide a sample of tumour for confirmation of the patient´s Human epidermal growth factor receptor 2 (HER2) status. This sample can be archival material obtained at any time prior to study enrollment Patient willing to undergo a fresh tumour biopsy prior to first treatment and also 5-7 hours (h) after any treatment with BI 1810631 during cycle 1 (except biopsies of brain metastases) for pharmacodynamic assessments  Adequate organ function defined as all of the following:  Absolute neutrophil count (ANC) ≥ 1.5 x 109/L (≥ 1.5 x 103/μL) (≥ 1500/mm3); haemoglobin ≥ 9.0 g/dL (≥ 90 g/L) (≥ 5.6 mmol/L); platelets ≥ 100 x 109/L (100 x 103/μL) (100 x 103/mm3) without the use of hematopoietic growth factors within 4 weeks of start of trial medication Total bilirubin ≤ 1.5 times the upper limit of normal (ULN), except for patients with Gilbert's syndrome: total bilirubin ≤ 3 x ULN or direct bilirubin ≤ 1.5 x ULN Creatinine ≤ 1.5 x ULN. If creatinine is > 1.5 x ULN, patient is eligible if concurrent creatinine clearance ≥ 50 ml/min (measured or calculated by Chronic Kidney Disease Epidemiology (CKD-EPI) formula or Japanese version of CKD-EPI formula for Japanese patients) Aspartate transaminase (AST) and alanine transaminase (ALT) ≤ 3 x ULN if no demonstrable liver metastases, or otherwise ≤ 5 x ULN if transaminase elevation is attributable to liver metastases Alkaline Phosphatase < 5 x ULN Recovered from any previous therapy-related toxicity to ≤ Common Terminology Criteria for Adverse Events (CTCAE) Grade 1 at start of treatment (except for alopecia, stable sensory neuropathy and hypothyroidism (patients on thyroid replacement therapy) which must be ≤ CTCAE Grade 2) Life expectancy of at least 12 weeks at the start of treatment in the opinion of the investigator At least 18 years of age at the time of consent or over the legal age of consent in countries where that is greater than 18 years Signed and dated written informed consent in accordance with International Council on Harmonisation-Good Clinical Practice (ICH-GCP) and local legislation prior to admission to the trial Male or female patients. Women of childbearing potential (WOCBP)1 and men who are able to father a child must be ready and able to use highly effective methods of birth control per International Council on Harmonisation (ICH) M3 (R2) that result in a low failure rate of less than 1% per year when used consistently and correctly  Additional Inclusion criteria for Phase Ia  Patients with a documented diagnosis of HER2 aberration: overexpression OR gene amplification OR non-synonymous somatic mutation OR gene rearrangement involving HER2 or Neuregulin 1 (NRG1) Patient who has failed conventional treatment or for whom no therapy of proven efficacy exists or who is not eligible for established treatment options. Patient must have exhausted, or not be a suitable candidate for, available treatment options known to prolong survival for their disease  Additional Inclusion criteria for Phase Ib  Patient with documented HER2 Exon20 insertion-mutation positive non-small cell lung cancer (NSCLC) as per central lab results Patient who had received, in the advanced/metastatic setting, at least one line of systemic therapy. Patients with NSCLC harboring additionally genomic aberrations for which approved targeted therapy is available such as but not limited to non-resistant epidermal growth factor receptor (EGFR) mutations, EGFR T790M mutation, Anaplastic lymphoma kinase (ALK) rearrangement, reactive oxygen species (ROS) re-arrangement, and v-raf murine sarcoma viral oncogene homolog B (BRAF) V600E mutation, must have received prior treatment with an approved targeted therapy  Exclusion Criteria:  Major surgery (major according to the investigator's assessment) performed within 4 weeks prior to first trial treatment or planned within 6 months after screening  Previous or concomitant malignancies other than the one treated in this trial within the last 2 years, except;  effectively treated non-melanoma skin cancers effectively treated carcinoma in situ of the cervix effectively treated ductal carcinoma in situ other effectively treated malignancy that is considered cured by local treatment. Treatment with a systemic anti-cancer therapy or investigational drug within 21 days or 5 half-lives (whichever is shorter) of the first treatment with the study medication Patients who must or wish to continue the intake of restricted medication or any drug considered likely to interfere with the safe conduct of the trial Use of concomitant medications that are narrow therapeutic index drugs that are substrates of P-Glycoprotein (P-gp) or Breast Cancer Resistance Protein (BCRP) (e.g. digoxin, dabigatran etexilate) Treatment with strong Cytochrome P450 3A4 (CYP3A4) inhibitors Treatment with strong Cytochrome P450 3A (CYP3A) inducers Further exclusion criteria apply