Posts

Showing posts with the label How Tos

react-native run-android : sun.security.provider.cert path.SunCertPathBuilderException : unable to find valid certification path to req uested target

Image
F:\webrowser>react-native run-android Scanning folders for symlinks in F:\webrowser\node_modules (73ms) Starting JS server... Building and installing the app on the device (cd android && gradlew.bat install Debug)... Downloading https://services.gradle.org/distributions/gradle-4.1-all.zip Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.val idator.ValidatorException: PKIX path building failed: sun.security.provider.cert path.SunCertPathBuilderException: unable to find valid certification path to req uested target at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker. java:1514) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.jav a:216) at s

error: package com.tencent.mm.sdk.openapi does not exist

Task :app:compileReleaseJavaWithJavac C:\Users\lenger\Desktop\webrowser\android\app\src\main\java\com\wx\react\WeChatModule.java:9: error: package com.tencent.mm.sdk.openapi does not exist import com.tencent.mm.sdk.openapi.IWXAPIEventHandler; ^ C:\Users\lenger\Desktop\webrowser\android\app\src\main\java\com\wx\react\WeChatModule.java:11: error: cannot find symbol public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEventHandler { ^ symbol: class IWXAPIEventHandler 2 errors FAILURE: Build failed with an exception. solution com.tencent.mm.sdk ==> com.tencent.mm.opensdk

gradle build : Could not find method compile() for arguments

In build.gradle file add one of the following: dependencies { compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+' } What went wrong: A problem occurred evaluating root project 'webrowser'. Could not find method compile() for arguments [com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Cause edit wrong android/build.gradle Solution edit correct android/app/build.gradle.

install GNU tools via chocolatey for windows

Image
https://chocolatey.org/install @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(' https://chocolatey.org/install.ps1 '))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" choco install -y gnuwin32-coreutils.install choco install gnuwin32-grep.install -y choco install which -y choco install git -y choco install vim -y C:\Users\lenger>which rm C:\Program Files (x86)\GnuWin32\bin\rm.exe C:\Users\lenger>which which C:\ProgramData\chocolatey\bin\which.exe C:\Users\lenger>which ls C:\Program Files (x86)\GnuWin32\bin\ls.exe C:\Users\lenger>which grep C:\Program Files (x86)\GnuWin32\bin\grep.exe C:\Users\lenger>which mv C:\Program Files (x86)\GnuWin32\bin\mv.exe C:\Users\lenger>which mkdir C:\Program Files (x86)\GnuWin32\bin\mkdir.exe

react-native : communicate between react-native JS and WebView component

Image
APIs: window.postMessage in WebView , post a message to react-native JS . onMessage callback in react-native JS , receive a message from WebView . injectjavascript , Function that accepts a string that will be passed to the WebView and executed immediately as JavaScript. injectedjavascript , Set this to provide JavaScript that will be injected into the web page when the view loads. onMessage A function that is invoked when the webview calls window.postMessage. Setting this property will inject a postMessage global into your webview, but will still call pre-existing values of postMessage. window.postMessage accepts one argument, data, which will be available on the event object, event.nativeEvent.data. data must be a string. Sample code import React, { Component } from 'react'; import { Button, Platform, StyleSheet, Text, View, WebView, } from 'react-native'; var WEBVIEW_REF = 'webview'; export default class App extends Component<

react-native run-android : Command `run-android` unrecognized

F:\webrowser>react-native run-android Command run-android unrecognized. Make sure that you have run npm install an d that you are inside a react-native project. F:\webrowser>npm install added 781 packages in 338.768s

npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE

F:\webrowser>npm install -g react-native-cli npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE npm ERR! errno UNABLE_TO_VERIFY_LEAF_SIGNATURE npm ERR! request to https://registry.npmjs.org/react-native-cli failed, reason: unable to verify the first certificate npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache_logs\2018-01-11T1 6_55_54_266Z-debug.log solution npm config set strict-ssl false F:\webrowser>npm install -g react-native-cli C:\Users\Administrator\AppData\Roaming\npm\react-native -> C:\Users\Administrato r\AppData\Roaming\npm\node_modules\react-native-cli\index.js react-native-cli@2.0.1 added 41 packages in 23.687s

git clone : SSL cert ificate problem: unable to get local issuer certificate

F:>git clone https://github.com/lengerrong/webrowser.git Cloning into 'webrowser'... fatal: unable to access ' https://github.com/lengerrong/webrowser.git/ ': SSL cert ificate problem: unable to get local issuer certificate F:>git config --global http.sslVerify false F:>git clone https://github.com/lengerrong/webrowser.git Cloning into 'webrowser'... remote: Counting objects: 134, done. remote: Compressing objects: 100% (90/90), done. Receiving objects: 33% (45/134), 492.00 KiB | 17.00 KiB/s

vim : remove ^M

1 vim下 :%s/^M//g 或者 :1,$s/^M//g 均可 补充一点: ^M是使用 "CTRL-V CTRL-M" 而不是字面上的 ^M 2 :set ff=unix 3 dos2unix || unix2dos

vim : switch off automatic creation of backup files

~/.vimrc set nobackup set nowritebackup

Create App Icons for React Native Android App

Image
First you need one png file as your launcher icon. Then you need to resize this icon file to needed resolutions. There is a simple service to resize your app icon to all needed resolutions with rocket speed . Then you can download all your needed icons. Then replace each ic_launcher.png via image with correct resolution. webrowser/android$ find -name "ic_launcher.png" ./app/src/main/res/mipmap-hdpi/ic_launcher.png ./app/src/main/res/mipmap-mdpi/ic_launcher.png ./app/src/main/res/mipmap-xhdpi/ic_launcher.png ./app/src/main/res/mipmap-xxhdpi/ic_launcher.png Or you can use Image Asset Studio to create App Icons. 1.open Android Studio poject in your react native application. 2.use Image Asset Studio In the Foreground Layer tab, select an Asset Type, and then specify the asset in the field underneath: Select Image to specify the path for an image file. If your app supports Android 8.0, create adaptive and legacy launcher icons. If your app supports versions no

Configure Proxy Settings for CMD.EXE, WinHttp

Image
Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\lenger>netsh netsh>winhttp netsh winhttp>set proxy /? Usage: set proxy [proxy-server=] [bypass-list=] Parameters: Tag Value proxy-server - proxy server for use for http and/or https protocol bypass-list - a list of sites that should be visited bypassing the proxy (use " " to bypass all short name hosts) Examples: set proxy myproxy set proxy myproxy:80 " ;bar" set proxy proxy-server="http=myproxy;https=sproxy:88" bypass-list="*.foo.com" netsh winhttp> set HTTP_PROXY=server:port set HTTPS_PROXY=server:port Refer https://technet.microsoft.com/en-us/library/bb430772(v=exchg.141).aspx

install and build your first React Native app on windows

Image
Installing Chocolatey with cmd.exe @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" Installing Node, Python2 and JDK with Chocolatey choco install -y nodejs.install python2 jdk8 Install The React Native CLI npm install -g react-native-cli Setup Android Studio Create Virtual Device Create New Application react-native init AwesomeProject Run android Launch your AVD before run-android react-native run-android If every works well, below is your final result: Refer https://facebook.github.io/react-native/docs/getting-started.html https://chocolatey.org/install Troubleshooting page npm proxy set run-android connection timeout unable to load index.android.bundle

Unable to load script from assets index.android.bundle

Image
Solution mkdir android/app/src/main/assets react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res Run react-native run-android Total time: 23.641 secs 'adb' is not recognized as an internal or external command, operable program or batch file. Starting the app (C:\Users\lenger\AppData\Local\Android\Sdk/platform-tools/adb shell am start -n com.webrowser/com.webrowser.MainActivity... Starting: Intent { cmp=com.webrowser/.MainActivity }

react-native run-android : Connection timed out

Error Log Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip Exception in thread "main" java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.security.ssl.SSLSocketImpl.connect(Unknown Source) at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.protocol.https.HttpsClient. (Unknown

npm config http/https proxy

npm --proxy http://username:password@server :port install packagename npm config set proxy http://username:password@server :port npm config set https-proxy http://username:password@server :port   npm config set strict-ssl false npm config set registry " http://registry.npmjs.org/ " npm config rm proxy npm config rm https-proxy

微信开放平台 创建移动应用 Android 应用签名

Image
keystore file decide it. In fact, it is MD5 value of the keystore file. please refer https://errong.win/generate-keystore/ to generate the keystore file. You can get the MD5 via keytool -list -v -keystore webrowser.keystore MD5: 4F:87:B6:11:A4:37:5A:29:E4:A2:F7:BD:2B:DC:CC:18 Remove all ":" and turn the string to lower case. Application signature is : 4f87b611a4375a29e4a2f7bd2bdccc18

Generate keystore file to sign your android apk

Tool keytool You can get this tool after you installed jdk . Command C:\Program Files\Java\jdk1.8.0_121\bin>keytool.exe -genkey -alias "webrowser" -keyalg "RSA" -validity 10000 -keystore "webrowser.keystore" Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: Errong What is the name of your organizational unit? [Unknown]: Errong What is the name of your organization? [Unknown]: Errong What is the name of your City or Locality? [Unknown]: Nanjing What is the name of your State or Province? [Unknown]: JiangSu What is the two-letter country code for this unit? [Unknown]: CN Is CN=Errong, OU=Errong, O=Errong, L=Nanjing, ST=JiangSu, C=CN correct? [no]: What is your first and last name? [Errong]: What is the name of your organizational unit? [Errong]: What is the name of your organization? [Errong]: What is the name of your City or Locality? [Nanjing]: What is the name of your State

wrong LC_NUMBERIC cause CSS unsupported value

warning: unsupported value position: absolute; width: 12.9em; transform: translateX(16.27em); ^ and you know, some countries uses decimal point as comma - not point. so scanf function cannot read "12.9em" if we set NUMERIC at that country. Such as French.   // query LC_NUMERIC  char* locale = setlocale(LC_NUMERIC, NULL);  // set LC_NUMERIC  char* locale = "en_US.utf8";  setlocale(LC_NUMERIC, locale);    if LC_NUMERIC was set to "frCA.UTF-8" , 12.9em can't be read as a Decimal. The correct should be like "en_US.utf8" Refer: https://en.wikipedia.org/wiki/Decimal_mark http://man7.org/linux/man-pages/man3/setlocale.3.html

Let gdb ignore SIGPIPE signal

(gdb) handle SIGPIPE nostop noprint