Jump to content
Sign in to follow this  
GuilhermeAw

Cordova + Crosswalk

Recommended Posts

criei um projeto cordova normalmente:

cordova create myApp com.myapp myApp

depois entrei na pasta do projeto

cd myApp

adicionei a plataforma:

cordova platform add android

e adicionei o plugin do crosswalk

cordova plugin add cordova-plugin-crosswalk-webview

se eu importar o projeto no AndroidStudio ele me da um erro de pacote. Pesquisei e esse erro é porque precisa buildar o projeto para o plugin do crosswalk baixar algumas classes etc... Dei o build:

cordova build android --release

Os erros sumiram, mas ele não compila da vários erros de classes duplicadas...

C:\Users\GuilhermeAw\Desktop\teste\platforms\android\build\generated\source\r\x86\release\org\xwalk\core\R.java
    Error:(9, 14) java: duplicate class: org.xwalk.core.R
    C:\Users\GuilhermeAw\Desktop\teste\platforms\android\build\generated\source\r\x86\release\com\teste\R.java
    Error:(10, 14) java: duplicate class: com.teste.R

Se eu pago as classes aparece mais erros...

Error:Android Dex: [android] Unable to execute DX
    Error:Android Dex: [android] com.android.dex.DexException: Multiple dex files define Lorg/apache/cordova/AuthenticationToken;
    Error:Android Dex: [android] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:591)
    Error:Android Dex: [android] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:546)
    Error:Android Dex: [android] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:528)
    Error:Android Dex: [android] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
    Error:Android Dex: [android] at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    Error:Android Dex: [android] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
    Error:Android Dex: [android] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    Error:Android Dex: [android] at com.android.dx.command.dexer.Main.run(Main.java:277)
    Error:Android Dex: [android] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Error:Android Dex: [android] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    Error:Android Dex: [android] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    Error:Android Dex: [android] at java.lang.reflect.Method.invoke(Method.java:497)
    Error:Android Dex: [android] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:188)
    Error:Android Dex: [android] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)

Eu acredito que esteja faltando alguma coisa, mas como é a primeira vez que trabalho com o crosswalk não sei lidar com esses erros, alguém sabe o que pode ser?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By ckcesar
      Galera alguém pode me ajudar, eu gerei uma Build com AngularCli e tento rodar ela com o Cordova e ao inspecionar no Chrome me retorna o seguinte erro no console:
      main-es2015.7678d805abc29502169b.js:1 Service worker registration failed with: TypeError: Failed to register a ServiceWorker: The URL protocol of the current origin ('file://') is not supported. at g._next (main-es2015.7678d805abc29502169b.js:1) at g.__tryOrUnsub (main-es2015.7678d805abc29502169b.js:1) at g.next (main-es2015.7678d805abc29502169b.js:1) at f._next (main-es2015.7678d805abc29502169b.js:1) at f.next (main-es2015.7678d805abc29502169b.js:1) at Kl._next (main-es2015.7678d805abc29502169b.js:1) at Kl.next (main-es2015.7678d805abc29502169b.js:1) at Dl._next (main-es2015.7678d805abc29502169b.js:1) at Dl.next (main-es2015.7678d805abc29502169b.js:1) at G.notifyNext (main-es2015.7678d805abc29502169b.js:1)  
    • By marcossantana10
      Opa, to precisando muito de uma ajuda: estou tentando fazer o upload de arquivos de um app hibrido (rodando android) para um servidor. O código abaixo é executado sem erro, mas o upload não acontece. Será que alguem tem ideia de onde pode estar o erro?
       
      var images = []; var $imagesDiv; document.addEventListener("deviceready", init, false); function init() { $("#addPicture").on("touchend", selPic); $imagesDiv = $("#images"); $("#uploadPictures").on("touchend", uploadPics); } function selPic() { navigator.camera.getPicture(function(f) { var newHtml = "<img src='"+f+"'>"; $imagesDiv.append(newHtml); images.push(f); if(images.length === 1) { $("#uploadPictures").removeAttr("disabled"); } }, function(e) { alert("Error, check console."); console.dir(e); }, { quality: 50, sourceType: Camera.PictureSourceType.PHOTOLIBRARY, destinationType: Camera.DestinationType.FILE_URI }); } function uploadPics() { alert("Ok, going to upload "+images.length+" images."); var defs = []; var fd = new FormData(); images.forEach(function(i) { alert('processing '+i); var def = $.Deferred(); window.resolveLocalFileSystemURL(i, function(fileEntry) { alert('got a file entry'); fileEntry.file(function(file) { alert('now i have a file ob'); console.dir(file); var reader = new FileReader(); reader.onloadend = function(e) { var imgBlob = new Blob([this.result], { type:file.type}); fd.append('file'+(images.indexOf(i)+1), imgBlob); fd.append('fileName'+(images.indexOf(i)+1), file.name); def.resolve(); }; reader.readAsArrayBuffer(file); }, function(e) { alert('error getting file', e); }); }, function(e) { alert('Error resolving fs url', e); }); defs.push(def.promise()); }); $.when.apply($, defs).then(function() { alert("all things done"); var request = new XMLHttpRequest(); request.open('POST', 'url', true); request.send(fd); }); } Do lado do servidor, onde eu deveria receber a requisição e upar os arquivos, está conforme código abaixo:
      <?php header("Access-Control-Allow-Origin: *"); $imgFileName=date("Y").date("m").date("j")."_".$_POST['index']."_".rand(1000,9999).".jpg"; if(move_uploaded_file($_FILES['file']['tmp_name'], "anuncios/".$imgFileName)){ echo "upload ok"; //or anything you need } ?>  
    • By Kellison Ruan
      Olá galera, Boa tarde!
      Estou com um probleminha em Ionic que está quebrando muito minha cabeça por dias.
      Método de pagamento do paypal aparece em meu site, mas não aparece no app ionic, o que será? Já tentei de tudo. Esse app faz comunicação via API do Woocommerce, e lá está habilitado a forma de pagamento com PayPal, porém só não aparece no app, já que na página de checkout no meu site, aparece.
       
      Segue o código da página de checkout do app:
       
      import { Component, Inject } from '@angular/core'; import { NavController, NavParams, AlertController, Loading, LoadingController, ToastController, App } from 'ionic-angular'; import { PlacedPage } from '../placed/placed'; import { PaymentGateway } from "../../models/payment-gateway.models"; import { Constants } from "../../models/constants.models"; import { WordpressClient } from '../../providers/wordpress-client.service'; import { Global } from '../../providers/global'; import { Subscription } from "rxjs/Subscription"; import { CartItem } from "../../models/cart-item.models"; import { OrderRequest } from "../../models/order-request.models"; import { Address } from "../../models/address.models"; import { ShippingLine } from "../../models/shipping-line.models"; import { UserResponse } from "../../models/user-response.models"; import { OrderResponse } from "../../models/order-response.models"; import { Currency } from "../../models/currency.models"; import { InAppBrowser, InAppBrowserOptions } from '@ionic-native/in-app-browser'; import { sha512 } from 'js-sha512'; import { APP_CONFIG, AppConfig } from '../../app/app.config'; import { OrderUpdateRequest } from '../../models/order-update-request.models'; import { Coupon } from '../../models/coupon.models'; import { HomePage } from '../home/home'; import { TranslateService } from '@ngx-translate/core'; import { Helper } from '../../models/helper.models'; import { ShippingMethod } from '../../models/shipping-method.models'; import { PayPal, PayPalPayment, PayPalConfiguration, PayPalPaymentDetails } from '@ionic-native/paypal'; @Component({ selector: 'page-payment', templateUrl: 'payment.html', providers: [WordpressClient] }) export class PaymentPage { private loading: Loading; private loadingShown: Boolean = false; private placedPagePushed: Boolean = false; private paymentDone: Boolean = false; private paymentFailAlerted: Boolean = false; private subscriptions: Array<Subscription> = []; private paymentGateways = new Array<PaymentGateway>(); private cartItems: Array<CartItem>; private selectedPaymentGateway; private selectedAddress: Address; private orderRequest: OrderRequest; private orderId = -1; private user: UserResponse; private totalItems = 0; private total = 0; private couponApplied = false; private pickupTime = 0; private deliveryTime = 0; private shippingChargeGlobal: number; constructor(@Inject(APP_CONFIG) private config: AppConfig, public translate: TranslateService, private iab: InAppBrowser, private toastCtrl: ToastController, public navCtrl: NavController, private navParams: NavParams, private service: WordpressClient, private loadingCtrl: LoadingController, private alertCtrl: AlertController, public appCtrl: App) { this.cartItems = this.navParams.get('cart'); this.totalItems = this.navParams.get('totalItems'); this.total = this.navParams.get('total'); this.shippingChargeGlobal = this.navParams.get('shippingChargeGlobal'); let paymentGateways = JSON.parse(window.localStorage.getItem(Constants.PAYMENT_GATEWAYS)); this.selectedAddress = JSON.parse(window.localStorage.getItem(Constants.SELECTED_ADDRESS)); if (paymentGateways != null) { for (let pg of paymentGateways) { if (pg.enabled && this.paymentImplemented(pg.id)) { this.paymentGateways.push(pg); } } } } ionViewWillLeave() { this.subscriptions.forEach((subscription: Subscription) => { subscription.unsubscribe(); }); this.dismissLoading(); } paymentImplemented(id) { return id === "pumcp" || id === "payuindia" || id === "cod"; } paymentMethod(paymentGateway) { this.selectedPaymentGateway = paymentGateway; } placedPage() { if (this.selectedPaymentGateway == null) { this.translate.get('field_error_payment_method').subscribe(value => { this.showToast(value); }); } else { this.orderRequest = new OrderRequest(); this.orderRequest.payment_method = this.selectedPaymentGateway.id ? this.selectedPaymentGateway.id : "cod"; this.orderRequest.payment_method_title = this.selectedPaymentGateway.title ? this.selectedPaymentGateway.title : "cod"; this.orderRequest.set_paid = false; this.orderRequest.billing = this.selectedAddress; this.orderRequest.shipping = this.selectedAddress; this.user = JSON.parse(window.localStorage.getItem(Constants.USER_KEY)); this.orderRequest.customer_id = String(this.user.id); let selectedShippingMethod: ShippingMethod = JSON.parse(window.localStorage.getItem(Constants.SELECTED_SHIPPING_METHOD)); if (selectedShippingMethod) { let shippingTotal = 0; for (let ci of this.cartItems) { if (!ci.product.shipping_cost_use_global && ci.product.shipping_cost != 1) shippingTotal = shippingTotal + ci.product.shipping_cost; } if (this.shippingChargeGlobal != -1) { shippingTotal = shippingTotal + this.shippingChargeGlobal; } this.orderRequest.shipping_lines = new Array<ShippingLine>(); this.orderRequest.shipping_lines.push(new ShippingLine(selectedShippingMethod.method_id, selectedShippingMethod.method_title, String(shippingTotal))); } this.orderRequest.line_items = this.cartItems; for (let item of this.orderRequest.line_items) { item.product = null; } this.translate.get('order_creating').subscribe(value => { this.presentLoading(value); }); let coupon: Coupon = JSON.parse(window.localStorage.getItem(Constants.SELECTED_COUPON)); let subscription: Subscription = this.service.createOrder(window.localStorage.getItem(Constants.ADMIN_API_KEY), this.orderRequest).subscribe(data => { this.orderId = data.id; if (coupon) { this.applyCoupon(coupon); } else { this.orderPlaced(); } }, err => { console.log(err); this.dismissLoading(); let orderId = Helper.extractOrderIdFromError(err); if (orderId != -1) { this.orderId = orderId; if (coupon) { this.applyCoupon(coupon); } else { this.orderPlaced(); } } else { this.translate.get('order_failed').subscribe(value => { this.showToast(value); }); this.appCtrl.getRootNav().setRoot(HomePage); } }); this.subscriptions.push(subscription); } } applyCoupon(coupon) { let couponSubs: Subscription = this.service.applyCouponCode(window.localStorage.getItem(Constants.ADMIN_API_KEY), String(this.orderId), coupon.code).subscribe(data => { this.couponApplied = true; window.localStorage.removeItem(Constants.SELECTED_COUPON); this.translate.get('confirm_order_coupon_applied').subscribe(value => { this.showToast(value); }); this.orderPlaced(); }, err => { console.log(err); this.dismissLoading(); }); this.subscriptions.push(couponSubs); } orderPlaced() { this.dismissLoading(); if (this.selectedPaymentGateway.id && this.selectedPaymentGateway.id === "cod") { this.clearCart(); this.navCtrl.setRoot(PlacedPage); } else if (this.selectedPaymentGateway.id === "pumcp" || this.selectedPaymentGateway.id === "payuindia") { this.initPayUMoney(); } else { this.translate.get('order_placed_cod').subscribe(value => { this.showToast(value); }); this.clearCart(); this.navCtrl.setRoot(PlacedPage); } } initPayUMoney() { let name = this.user.first_name && this.user.first_name.length ? this.user.first_name : this.user.username; let mobile = this.user.username; let email = this.user.email; let bookingId = String(Math.floor(Math.random() * (99 - 10 + 1) + 10)) + this.orderId; let productinfo = this.orderId; let salt = this.config.payuSalt; let key = this.config.payuKey; let amt = this.couponApplied ? this.total : this.totalItems; let string = key + '|' + bookingId + '|' + amt + '|' + productinfo + '|' + name + '|' + email + '|||||||||||' + salt; let encrypttext = sha512(string); //let url = "payumoney/payuBiz.html?amt=" + amt + "&name=" + name + "&mobileNo=" + mobile + "&email=" + email + "&bookingId=" + bookingId + "&productinfo=" + productinfo + "&salt=" + salt + "&key=" + key; let url = "payumoney/payuBiz.html?amt=" + amt + "&name=" + name + "&mobileNo=" + mobile + "&email=" + email + "&bookingId=" + bookingId + "&productinfo=" + productinfo + "&hash=" + encrypttext + "&salt=" + salt + "&key=" + key; let options: InAppBrowserOptions = { location: 'yes', clearcache: 'yes', zoom: 'yes', toolbar: 'no', closebuttoncaption: 'back' }; const browser: any = this.iab.create(url, '_blank', options); browser.on('loadstop').subscribe(event => { browser.executeScript({ file: "payumoney/payumoneyPaymentGateway.js" }); if (event.url == "http://localhost/success.php") { this.paymentSuccess(); browser.close(); } if (event.url == "http://localhost/failure.php") { this.paymentFailure(); browser.close(); } }); browser.on('exit').subscribe(event => { if (!this.paymentDone && !this.paymentFailAlerted) { this.paymentFailure(); } }); browser.on('loaderror').subscribe(event => { this.showToast('something_went_wrong'); }); } paymentFailure() { this.paymentFailAlerted = true; let subscription: Subscription = this.service.updateOrder(window.localStorage.getItem(Constants.ADMIN_API_KEY), String(this.orderId), new OrderUpdateRequest('cancelled')).subscribe(data => { }, err => { console.log(err); }); this.subscriptions.push(subscription); this.translate.get(['payment_fail_title', 'payment_fail_message', 'ok']).subscribe(res => { let alert = this.alertCtrl.create({ title: res.payment_fail_title, message: res.payment_fail_message, buttons: [{ text: res.ok, role: 'cancel', handler: () => { this.done(); console.log('Okay clicked'); } }] }); alert.present(); }); } paymentSuccess() { this.paymentDone = true; this.clearCart(); this.translate.get('just_a_moment').subscribe(value => { this.presentLoading(value); }); let subscription: Subscription = this.service.updateOrder(window.localStorage.getItem(Constants.ADMIN_API_KEY), String(this.orderId), { set_paid: true }).subscribe(data => { this.done(); }, err => { this.done(); this.paymentSuccess(); console.log(err); }); this.subscriptions.push(subscription); } done() { if (!this.placedPagePushed) { this.placedPagePushed = true; this.dismissLoading(); this.appCtrl.getRootNav().setRoot(this.paymentFailAlerted ? HomePage : PlacedPage); } } private presentLoading(message: string) { this.loading = this.loadingCtrl.create({ content: message }); this.loading.onDidDismiss(() => { }); this.loading.present(); this.loadingShown = true; } private dismissLoading() { if (this.loadingShown) { this.loadingShown = false; this.loading.dismiss(); } } private presentErrorAlert(msg: string) { let alert = this.alertCtrl.create({ title: 'Error', subTitle: msg, buttons: ['OK'] }); alert.present(); } showToast(message: string) { let toast = this.toastCtrl.create({ message: message, duration: 3000, position: 'bottom' }); toast.onDidDismiss(() => { console.log('Dismissed toast'); }); toast.present(); } clearCart() { let cartItems = new Array<CartItem>(); window.localStorage.setItem('cartItems', JSON.stringify(cartItems)); } }  
    • By PeeWee
      Estou aprendendo phonegap e por mais simples que pareça estou tendo muita dificuldade, peguei um código para testes e mesmo ja estando pronto nao rodou como deveria exibindo o erro: net::ERR_CONNECTION_REFUSED, pesquisei, fiz alterações, coloquei o ip ca maquina conforme recomendado mas sem exito, segue o código:
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
          <script  src="http://code.jquery.com/jquery-latest.js"></script>
          <title>AJAX + JSON + PHP</title>  <!--    192.168.1.20  -->
          <script type="text/javascript">
              var dato1="";
              var dato2="";
              var dato3="";
              function traer() {
                  $.getJSON('http://192.168.15.3:8080/JSON/traer.php',
                      
                      function(data){
                          dato1=data[0].Id;
                          dato2=data[0].Nombre;
                          dato3=data[0].Apellido;
                                    }
                        );
              }
              function mostrar() {
                  $("#dato-1").text(dato1);
                  $("#dato-2").text(dato2);
                  $("#dato-3").text(dato3);
              }
          
          
          </script>
      </head>
      <body>
          <div class="container">
              <h1>Traer datos de BD con JSON</h1>
              <hr>
              <br>
              <input type="button" name="" value="Traer datos" onclick="traer()">
              <input type="button" name="" value="Mostrar datos" onclick="mostrar()">
              <h3 id="dato-1">DATO 1</h3>
              <h3 id="dato-2">DATO 2</h3>
              <h3 id="dato-3">DATO 3</h3>
          </div>    
       
       
       
       
      <?php 
                  $host = "localhost";
                  $usuario = "root";
                  $pass = "";
                  $bd = "demostracion";
                  
                  $servidor = mysql_connect($host, $usuario, $pass);
                  
                   mysql_set_charset("utf8", $servidor);
                  $conexion = mysql_select_db($bd, $servidor);
                      
                  $consulta = "SELECT * FROM datos";
                  $sql = mysql_query($consulta);
               
                  $datos= array();
                  while ($obj = mysql_fetch_object($sql)) {
                      $datos[] = array('Id' => $obj->Id,
                                        'Nombre' => $obj->Nombre,
                                        'Apellido' => $obj->Apellido,
                          );
                      }
                      
                      echo '' . json_encode($datos) . '';
                      mysql_close($servidor);
                      header('Content-type: application/json');
                      header("Access-Control-Allow-Origin: *");
          ?>
       
      o BD está correto, não sei mais o que fazer, se alguém puder ajudar agradeço muito, fico no aguardo por sugestões.
       
    • By Vitor Pereira dos Santos
      Preciso que a imagem que está guardada no Storage firebase apareça na listview customizada, no entanto não consigo setar a imagem no formato gs://, ja tentei utilizar o Picasso e o Glide, mas ambos precisam da URL da imagem, ou seja: http://.. E Não consigo pegar essa url. 
       
      O código é esse: https://github.com/VitorSantos1996/LivrariaFireBase
       
      Se tiver como estar a imagem no formato gs://.. ficará mais fácil.
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.