@matheusfaxina wrote:
Has anyone had a similar error? I am using Ionic 3.
Error
Error: Uncaught (in promise): Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object referencePdfService
export class PdfPedidoService { static DEFAULT_PASTE = 'forca-vendas-pdf-pedido'; static DEFAULT_LOCATION = cordova.file.externalRootDirectory; constructor(private _file: File, private _pedidoDao: PedidoRepository, private _itemPedidoDao: ItemPedidoRepository, private _vendedorLoginService: VendedorLoginService, private _vendedorParametroService: VendedorParametroService) { this._file.createDir(PdfPedidoService.DEFAULT_LOCATION, PdfPedidoService.DEFAULT_PASTE, true); } getLocale(pedido: Pedido) { return `${PdfPedidoService.DEFAULT_LOCATION}/${PdfPedidoService.DEFAULT_PASTE}/${pedido.id_integracao}.pdf`; } async criarArquivoPDF(pedido: Pedido) { const documentPDF = await this.criarObjetoDocumento(pedido); const bytesPDF = await this.criarPDFMemoria(documentPDF); await this.salvarArrayByteNoDipositivo(bytesPDF, pedido.id_integracao + '.pdf'); } private criarPDFMemoria(objDocumentPDF: any): Promise<ArrayBufferLike> { return new Promise(resolve => { pdfmake.createPdf(objDocumentPDF) .getBuffer(buffer => { const utf8 = new Uint8Array(buffer); const binaryArray = utf8.buffer; resolve(binaryArray); }); }); } private salvarArrayByteNoDipositivo(arrayBytes: any, nomeArquivo: string) { return this._file.writeFile(`${PdfPedidoService.DEFAULT_LOCATION}/${PdfPedidoService.DEFAULT_PASTE}`, nomeArquivo, arrayBytes, {replace: true}); } private construirPrazoPagamento(pedido: Pedido): string { if (!pedido.fk_ids_tabela_prazo) { return ''; } const tabelasSelecionadas = NormalizadorUtil.toNumberArray(pedido.fk_ids_tabela_prazo); return tabelasSelecionadas.join('/') + ' dias \n'; } private construirBody(pedido: Pedido) { const roundPipe = new RoundPipe(); const monetarioPipe = new MonetarioPipe(); const header = [ { text: 'Produto', style: 'tabelaHeader' }, { text: 'Quantidade', style: [ 'tabelaHeader', 'center' ] }, { text: 'Preço Bruto', style: [ 'tabelaHeader', 'center' ] }, { text: 'Desconto', style: [ 'tabelaHeader', 'center' ] }, { text: 'Preço Líquido', style: [ 'tabelaHeader', 'center' ] } ]; const retorno = [header]; for (let itemPedido of pedido.listaItemPedido) { retorno.push([ { text: itemPedido.produto.descricao, style: 'tabelaNomeProduto' }, { text: itemPedido.quantidade.toString(), style: 'tabelaColunaNumerica' }, { text: monetarioPipe.transform(roundPipe.transform(itemPedido.valor_bruto)), style: 'tabelaColunaNumerica' }, { text: roundPipe.transform(itemPedido.desconto_porcentagem, 3) + '%', style: 'tabelaColunaNumerica' }, { text: monetarioPipe.transform(roundPipe.transform(itemPedido.valor_liquido)), style: 'itemTotal' } ]) } return retorno; } private async criarObjetoDocumento(pedido: Pedido) { await this._pedidoDao.initialize(pedido); await this._itemPedidoDao.initializeArray(pedido.listaItemPedido); const textPrazo = this.construirPrazoPagamento(pedido); const objBody = this.construirBody(pedido); const roundPipe = new RoundPipe(); const monetarioPipe = new MonetarioPipe(); const telefonePipe = new TelefonePipe(); const cnpjCpfPipe = new CnpjCpfPipe(); const titleCasePipe = new TitleCasePipe(); return { content: [ { columns: [ { text: 'Contato', style: 'tituloSuperior', }, { text: 'Pedido', style: 'tituloSuperior', }, ] }, { columns: [ { text: `${titleCasePipe.transform(this._vendedorLoginService.vendedorLogado.empresa_nome)} \n ${cnpjCpfPipe.transform(this._vendedorLoginService.vendedorLogado.empresa_cnpjCpf)} \n ${telefonePipe.transform(this._vendedorLoginService.vendedorLogado.empresa_telefone)} \n ${this._vendedorLoginService.vendedorLogado.empresa_email}`, style: 'subTituloSuperior' }, { text: `${titleCasePipe.transform(pedido.cliente.nome_fantasia)} \n ${cnpjCpfPipe.transform(pedido.cliente.cnpj_cpf)} \n ${textPrazo} ${titleCasePipe.transform(pedido.tipoPagamento.descricao)}`, style: 'subTituloSuperior' }, ] }, '\n\n', { table: { headerRows: 1, widths: [ '*', 'auto', 'auto', 'auto', 'auto' ], body: objBody }, }, { table: { headerRows: 0, widths: [ '*', 80 ], body: [ [ { text: 'Subtotal', style: 'tabelaRodape' }, { text: monetarioPipe.transform(roundPipe.transform(pedido.valor_bruto)), style: 'itemsFooterSubValue' } ], [ { text: 'Desconto', style: 'tabelaRodape' }, { text: monetarioPipe.transform(roundPipe.transform(pedido.desconto_valor)), style: 'itemsFooterSubValue' } ], [ { text: 'TOTAL', style: 'itemsFooterTotalTitle' }, { text: monetarioPipe.transform(roundPipe.transform(pedido.valor_liquido)), style: 'itemsFooterTotalValue' } ], ] }, layout: 'lightHorizontalLines' }, ], styles: { tituloSuperior: { fontSize: 14, bold: true, alignment: 'left', margin: [ 0, 20, 0, 5 ], }, subTituloSuperior: { alignment: 'left' }, invoiceBillingAddressTitle: { margin: [ 0, 7, 0, 3 ], bold: true }, invoiceBillingAddress: {}, tabelaHeader: { margin: [ 0, 5, 0, 5 ], bold: true }, tabelaNomeProduto: { bold: false, }, itemSubTitle: { italics: true, fontSize: 11 }, tabelaColunaNumerica: { margin: [ 0, 5, 0, 5 ], alignment: 'center', }, itemTotal: { margin: [ 0, 5, 0, 5 ], bold: true, alignment: 'center', }, tabelaRodape: { margin: [ 0, 5, 0, 5 ], bold: true, alignment: 'right', }, itemsFooterSubValue: { margin: [ 0, 5, 0, 5 ], bold: true, alignment: 'center', }, itemsFooterTotalTitle: { margin: [ 0, 5, 0, 5 ], bold: true, alignment: 'right', }, itemsFooterTotalValue: { margin: [ 0, 5, 0, 5 ], bold: true, alignment: 'center', }, signaturePlaceholder: { margin: [ 0, 70, 0, 0 ], }, signatureName: { bold: true, alignment: 'center', }, signatureJobTitle: { italics: true, fontSize: 10, alignment: 'center', }, notesTitle: { fontSize: 10, bold: true, margin: [ 0, 50, 0, 3 ], }, notesText: { fontSize: 10 }, center: { alignment: 'center', }, }, defaultStyle: { columnGap: 20, } }; } }Button Share
async onClickCompartilharPedido(pedido: Pedido) { const titleCasePipe = new TitleCasePipe(); await this.pdfPedido.criarArquivoPDF(pedido); await this.socialSharing.share(`Olá ${titleCasePipe.transform(pedido.cliente.nome_fantasia)}, o pedido que você solicitou em ${this.datePipe.transform(pedido.data_emissao, 'dd/MM/yyyy')} está em anexo!`, 'Pedido detalhado', this.pdfPedido.getLocale(pedido)); this.vetorPedidosSelecionados = []; }Config.xml
<?xml version='1.0' encoding='utf-8'?> <widget id="br.com.sgsistemas.forcavendas" version="2.7.3" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:tools="http://schemas.android.com/tools"> <name>Força de Vendas</name> <description>Aplicativo Força de Vendas</description> <content original-src="index.html" src="http://192.168.3.86:8100" /> <access origin="*" /> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <allow-intent href="tel:*" /> <allow-intent href="sms:*" /> <allow-intent href="mailto:*" /> <allow-intent href="geo:*" /> <preference name="ScrollEnabled" value="false" /> <preference name="android-targetSdkVersion" value="28" /> <preference name="android-minSdkVersion" value="19" /> <preference name="ShowSplashScreen" value="true" /> <preference name="ShowSplashScreenSpinner" value="false" /> <preference name="android-windowSoftInputMode" value="adjustPan" /> <preference name="BackupWebStorage" value="none" /> <preference name="SplashMaintainAspectRatio" value="true" /> <preference name="FadeSplashScreenDuration" value="300" /> <preference name="FadeSplashScreen" value="true" /> <preference name="loadUrlTimeoutValue" value="700000" /> <preference name="AutoHideSplashScreen" value="false" /> <preference name="SplashShowOnlyFirstTime" value="false" /> <preference name="SplashScreenDelay" value="3000" /> <preference name="SplashScreen" value="screen" /> <preference name="KeyboardDisplayRequiresUserAction" value="false" /> <preference name="KeyboardResize" value="false" /> <allow-navigation href="http://192.168.102.214:8100" /> <allow-navigation href="http://192.168.0.34:8100" /> <allow-navigation href="http://192.168.0.44:8100" /> <allow-navigation href="http://172.18.0.1:8100" /> <allow-navigation href="http://192.168.0.44:8101" /> <platform name="android"> <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application"> <application android:usesCleartextTraffic="true"> <provider android:authorities="${applicationId}" android:exported="true" android:grantUriPermissions="true" android:name="android.support.v4.content.FileProvider" tools:replace="android:authorities"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" tools:replace="android:resource" /> </provider> </application> </edit-config> <icon density="ldpi" src="resources/sg/android/icon/drawable-ldpi-icon.png" /> <icon density="mdpi" src="resources/sg/android/icon/drawable-mdpi-icon.png" /> <icon density="hdpi" src="resources/sg/android/icon/drawable-hdpi-icon.png" /> <icon density="xhdpi" src="resources/sg/android/icon/drawable-xhdpi-icon.png" /> <icon density="xxhdpi" src="resources/sg/android/icon/drawable-xxhdpi-icon.png" /> <icon density="xxxhdpi" src="resources/sg/android/icon/drawable-xxxhdpi-icon.png" /> <splash density="land-ldpi" src="resources/sg/android/splash/drawable-land-ldpi-screen.png" /> <splash density="land-mdpi" src="resources/sg/android/splash/drawable-land-mdpi-screen.png" /> <splash density="land-hdpi" src="resources/sg/android/splash/drawable-land-hdpi-screen.png" /> <splash density="land-xhdpi" src="resources/sg/android/splash/drawable-land-xhdpi-screen.png" /> <splash density="land-xxhdpi" src="resources/sg/android/splash/drawable-land-xxhdpi-screen.png" /> <splash density="land-xxxhdpi" src="resources/sg/android/splash/drawable-land-xxxhdpi-screen.png" /> <splash density="port-ldpi" src="resources/sg/android/splash/drawable-port-ldpi-screen.png" /> <splash density="port-mdpi" src="resources/sg/android/splash/drawable-port-mdpi-screen.png" /> <splash density="port-hdpi" src="resources/sg/android/splash/drawable-port-hdpi-screen.png" /> <splash density="port-xhdpi" src="resources/sg/android/splash/drawable-port-xhdpi-screen.png" /> <splash density="port-xxhdpi" src="resources/sg/android/splash/drawable-port-xxhdpi-screen.png" /> <splash density="port-xxxhdpi" src="resources/sg/android/splash/drawable-port-xxxhdpi-screen.png" /> </platform> <allow-navigation href="http://172.19.0.1:8100" /> <allow-navigation href="http://192.168.0.11:8100" /> <allow-navigation href="http://192.168.237.68:8100" /> <allow-navigation href="http://192.168.3.86:8100" /> <allow-navigation href="http://192.168.3.86:8101" /> <plugin name="cordova-plugin-file" spec="^6.0.2" /> <plugin name="mx.ferreyra.callnumber" spec="0.0.2" /> <plugin name="cordova-plugin-ionic-keyboard" spec="2.2.0" /> <plugin name="cordova-plugin-advanced-http" spec="^1.11.1" /> <plugin name="cordova-plugin-ionic-webview" spec="^1.2.1" /> <plugin name="cordova-plugin-network-information" spec="^1.3.4" /> <plugin name="cordova-plugin-splashscreen" spec="^4.1.0" /> <plugin name="cordova-plugin-whitelist" spec="^1.3.4" /> <plugin name="cordova-plugin-zip" spec="^3.1.0" /> <plugin name="cordova-sqlite-storage" spec="^2.6.0" /> <plugin name="ionic-plugin-keyboard" spec="^2.2.1" /> <plugin name="cordova-plugin-headercolor" spec="^1.0.0" /> <plugin name="cordova-plugin-statusbar" spec="^2.4.3" /> <plugin name="cordova-plugin-nativegeocoder" spec="^3.2.2" /> <plugin name="call-number" spec="^1.0.1" /> <plugin name="uk.co.workingedge.cordova.plugin.sqliteporter" spec="^1.1.1" /> <plugin name="cordova-android-play-services-gradle-release" spec="^1.4.6"> <variable name="PLAY_SERVICES_VERSION" value="15.+" /> </plugin> <plugin name="cordova-plugin-x-socialsharing" spec="^5.4.4"> <variable name="ANDROID_SUPPORT_V4_VERSION" value="24.1.1+" /> </plugin> <plugin name="cordova-plugin-app-version" spec="^0.1.9" /> <plugin name="cordova-plugin-is-debug" spec="^1.0.0" /> <plugin name="cordova-plugin-android-permissions" spec="^1.0.2" /> <plugin name="cordova-plugin-keyboard" spec="^1.2.0" /> <plugin name="cordova-plugin-device" spec="^2.0.3" /> <allow-navigation href="http://192.168.3.86:8102" /> <allow-navigation href="http://192.168.3.86:8103" /> <allow-navigation href="http://192.168.3.86:8104" /> <allow-navigation href="http://192.168.3.86:8105" /> <allow-navigation href="http://192.168.3.86:8106" /> <engine name="android" spec="7.1.4" /> </widget>Sharing_paths.xml
<?xml version="1.0" encoding="utf-8"?> <paths> <external-path name="Android/data/${applicationId}/socialsharing_downloads" path="./socialsharing-downloads"/> <root-path name="root" path="/"/> </paths>
Posts: 1
Participants: 1