Dear community,
in the past days I created a small app by use of Capacitor that runs fine in Android Studio.
For simplicity I picked the debug version of the APK file from the project folder and tried to install it on my own mobile (Samsung A50). Android asked several questions regarding security and finally said “App not installed”. However the app was visible in the list of apps and ran fine.
Then I sent the APK to another user. Unfortunate installation fails on his mobile (Xiaomi) although he says that he installed APKs from unknown sources successfully before.
How to fix this? Is the debug version of the APK not suited for running standalone? How can I build a correct APK?
Best regards, Ulrich
In case it helps, this is the javascript:
window.addEventListener('click', event => {
if (event.target.id == 'btn-pick-db-file') {
exportsFilepicker.pickFiles({
types: ['application/octet-stream'],
multiple: false
}).then(result => {
console.log(result.files[0]);
Capacitor.Plugins.Filesystem.readFile({ path: result.files[0].path })
.then(file => {
console.log(file.data);
fetch('data:application/octet-stream;base64,' + file.data)
.then(res => res.blob())
.then(blob => {
console.log(blob);
window.capacitor_blob_writer({
path: 'file:///data/user/0/com.substanzen.app/databases/SubstancesSQLite.db',
blob: blob
// fast_mode: true
}).then(result => {
alert('Datenbankdatei wurde erfolgreich eingelesen');
displaySubstances();
});
});
});
});
}
});
function readDatabaseFile(event) {
Capacitor.Plugins.Filesystem.requestPermissions().then((status) => {
console.log(status);
fetch('https://example.com/path/db-cors.php')
.then(response => response.blob())
.then(blob => {
// console.log(blob);
window.capacitor_blob_writer({
path: 'file:///data/user/0/com.substanzen.app/databases/SubstancesSQLite.db',
blob: blob
// fast_mode: true
}).then(result => {
alert('Datenbankdatei wurde erfolgreich eingelesen');
});
});
});
}
function displaySubstances() {
conn = new exports.SQLiteConnection(exports.CapacitorSQLite);
console.log(conn);
conn.createConnection(
"Substances", false, "no-encryption", 3, false
).then(db => {
console.log(db);
db.open("Substances", false, 'no-encryption', 3, true).then(() => {
const sql = 'select * from `Substanzen - Substanzen`';
db.query(sql).then(
result => {
console.log(result);
document.querySelector('section.substances').innerHTML = '';
result.values.forEach(row => {
console.log(row.Name + ' - ' + row.Art);
// HTML aus Template lesen und die Platzhalter ersetzen
let html = document.getElementById('substance-tpl').innerHTML
.replace(/{{name}}/g, row.Name)
.replace(/{{art}}/g, row.Art)
.replace(/{{beschreibung}}/g, row.Beschreibung)
if (row.Bild) {
console.log((typeof new Blob([new Uint8Array(row.Bild).buffer])))
html = html.replace(/{{img}}/g, URL.createObjectURL(new Blob([new Uint8Array(row.Bild).buffer])));
} else {
html = html.replace(/{{img}}/g, '""');
}
// HTML in section mit den Substanzen am Ende eintragen
document.querySelector('section.substances')
.insertAdjacentHTML('beforeend', html)
});
});
db.close("Substances");
});
});
}
// displaySubstances();
Edit: In the meantime I read this:
and built a debug version of the app but no success, cannot be installed either.
Edit1: Performed some more research and built a release APK. Unfortunately installation of this APK fails complete: Message “App wasn’t installed” displaying immediately without any querys regarding security.