react-native : multi language support set up, use device locale, react-native-i18n use example

Multi language prepare

.\app\i18n\locales\en.js
export default {
  wcsqa: 'Westminster Shorter Catechism Q&A'
};
.\app\i18n\locales\zh.js
export default {
  wcsqa: '威斯敏斯德小要理问答'
};
.\app\i18n\i18n.js
import I18n from 'react-native-i18n';
import en from './locales/en';
import zh from './locales/zh';

I18n.fallbacks = true;

I18n.translations = {
  en,
  zh
};

export default I18n;

Usage

App.js
import ReactNativeLanguages from 'react-native-languages';
import I18n from './app/i18n/i18n'

ReactNativeLanguages.addEventListener('change', ({ language }) => {
  I18n.locale = language;
});

render() {
    return (
      <View style={styles.container}>
        <View style={styles.header}>
          <Text style={styles.title}>
            {I18n.t('wcsqa')}
          </Text>
          ... // other contents
        </View>
        ... // other contents
      </View>
    )
}

No Image, No Truth

multi-language

Refers

https://github.com/react-community/react-native-languages
https://github.com/AlexanderZaytsev/react-native-i18n
https://errong.win/language-code-for-chinese-should-be-start-with-zh/

react-native : header bar(title + option button) example

Render

   render() {
      return (
        <View style={styles.container}>
          <View style={styles.header}>
            <Text style={styles.title}>
              {I18n.t('wcsqa')} // your title
            </Text>
            <TouchableOpacity onPress={() => {}}>
              <Image
                style={styles.option}
                source={require('./res/img/nav_icon.png')}
              />
            </TouchableOpacity>
          </View>
          <View style={styles.content}>
            <Text>
              {this.wcs[0].Q} // your content
            </Text>
          </View>
        </View>
      )
  }

Style

const styles = StyleSheet.create({
  container: {
    flex: 2,
  },
  header: {
    backgroundColor: '#00FF7F',
    flex: 1,
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-around',
  },
  title: {
    fontSize: 20,
    fontWeight: 'bold'
  },
  option: {
    width:32,
    height:32
  },
  content: {
    backgroundColor: '#F5DEB3',
    flex: 12
  }
});

No Image, No Truth

header-bar

language code for Chinese should be start with 'zh'

According to RFC4646 (http://www.ietf.org/rfc/rfc4646.txt)
language codes for Traditional Chinese should be zh-Hant
react-native-i18n
import { getLanguages } from 'react-native-i18n'
getLanguages().then(languages => {
  console.log(languages);
});

Set system language to Chinese

01-24 17:47:47.957 19851 19873 I ReactNativeJS: [ 'zh-Hans-CN', 'en-US' ]

Set system language to English

01-24 17:56:30.754 20563 20584 I ReactNativeJS: [ 'en-US', 'zh-Hans-CN' ]

react-native run-android : Unable to process incoming event ‘ProgressComplete ’ (ProgressCompleteEvent) on Windows

Error

Unable to process incoming event 'ProgressComplete ' (ProgressCompleteEvent) on Windows

Solution

I looked solution from web, but not found one can work for my issue.
https://github.com/gradle/gradle/issues/882
Then I just closed my shell window(cmd.exe or powershell.exe) and reopen a new one,
I found the issue gone.

react-native : full screen background image example

render

render() {
  return (
    <ImageBackground
       style={styles.bgimg}
       source={require('./res/img/wcs.png')}>
      <View style={styles.fgcontainer}>
        <Text style={styles.qa}>
           WCS WCS WCS
        </Text>
      </View>
    </ImageBackground>
  );
}

Style

const styles = StyleSheet.create({
  bgimg: {
    flex: 1
  },
  fgcontainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  qa: {
    fontSize: 30,
    fontWeight: 'bold'
  }
});

No Image, No Truth

wcsfullscreen

react-native : center an Image example

Render

  render() {
    return (
      <View style={styles.splashContainer}>
        <Image
            source={require('./res/img/Catechism-words.png')}>
        </Image>
      </View>
    )
  }

Style

const styles = StyleSheet.create({
  splashContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#00FF7F'
  }
});

No Image, No True

wcsqa

chromium : extensions, how a extension list on web store was installed to chrome

If you find a liked extension on chrome web store, you can install it just by simple click the "ADD TO CHROME" button.
addtochrome
Let's go deep into chromium codes, and see how it happened.
The key module is chrome.webstore, which a buildin JS object in chrome.
chrome/renderer/extensions/webstore_bindings.cc
chrome/renderer/extensions/webstore_bindings.h
chrome-install-extensions
 
WebstoreBindings::Install
TabHelper::DoInlineInstall
WebstoreInlineInstaller::BeginInstall
WebstoreStandaloneInstaller::ProceedWithInstallPrompt
ShowInstallUI
 
show install prompt dialog

WebstoreStandaloneInstaller::ProceedWithInstallPrompt
NavigationObserver::OnInstallPromptDone
ExtensionService::EnableExtension
ExtensionRegistrar::EnableExtension

chromium : extensions, how background scripts/page get loaded.

Summary

a generated background page such as
chrome-extension://ffdhgjkakefolmigapfdgbcneopmidbf/_generated_background_page.html
will be loaded soon afer extensions service init.
the content of background page is generated by GeneratedBackgroundPageJob.
specially for scheme "chrome-extension://"

GenerateBackgroundPageContents

#3 0x56110ab93b63 extensions::(anonymous namespace)::GeneratedBackgroundPageJob::GetData()
#4 0x7fb7125791e9 net::URLRequestSimpleJob::GetRefCountedData()
#5 0x7fb712578baf net::URLRequestSimpleJob::StartAsync()

extensions::CreateExtensionProtocolHandler

void ProfileIOData::SetUpJobFactoryDefaultsForBuilder(
    net::URLRequestContextBuilder* builder,
    content::URLRequestInterceptorScopedVector request_interceptors,
    std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
        protocol_handler_interceptor) const {
// NOTE(willchan): Keep these protocol handlers in sync with
// ProfileIOData::IsHandledProtocol().
#if BUILDFLAG(ENABLE_EXTENSIONS)
  DCHECK(extension_info_map_.get());
  // Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE).
  bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE;
  builder->SetProtocolHandler(extensions::kExtensionScheme,
                              extensions::CreateExtensionProtocolHandler(
                                  is_incognito, extension_info_map_.get()));
#endif

GeneratedBackgroundPageJob

#2 0x55593de3c42e extensions::(anonymous namespace)::GeneratedBackgroundPageJob::GeneratedBackgroundPageJob()
#3 0x55593de3b4cd extensions::(anonymous namespace)::ExtensionProtocolHandler::MaybeCreateJob()
#4 0x7f0f359c0352 net::URLRequestJobFactoryImpl::MaybeCreateJobWithProtocolHandler()
#5 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#6 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#7 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#8 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#9 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#10 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#11 0x55593f4ea748 ProtocolHandlerRegistry::JobInterceptorFactory::MaybeCreateJobWithProtocolHandler()
#12 0x7f0f359c0c5f net::URLRequestJobManager::CreateJob()
#13 0x7f0f35981e78 net::URLRequest::BeforeRequestComplete()

LoadURL("chrome-extension://ffdhgjkakefolmigapfdgbcneopmidbf/_generated_background_page.html")

[20357:20357:0120/200335.076376:INFO:navigation_controller_impl.cc(659)]  url chrome-extension://ffdhgjkakefolmigapfdgbcneopmidbf/_generated_background_page.html
#2 0x7f4943d1ba52 content::NavigationControllerImpl::LoadURL()
#3 0x56433d6fdc98 extensions::ExtensionHost::LoadInitialURL()
#4 0x56433d6fce59 extensions::ExtensionHost::CreateRenderViewNow()
#5 0x56433d80b5ce extensions::SerialExtensionHostQueue::ProcessOneHost()

CreateBackgroundHostForExtensionLoad

#2 0x557dfb4320c8 extensions::SerialExtensionHostQueue::PostTask()
#3 0x557dfb432074 extensions::SerialExtensionHostQueue::Add()
#4 0x557dfb3f3ffd extensions::LoadMonitoringExtensionHostQueue::Add()
#5 0x557dfb323dae extensions::ExtensionHost::CreateRenderViewSoon()
#6 0x557dfb3fe434 extensions::ProcessManager::CreateBackgroundHost()
#7 0x557dfb40381e extensions::(anonymous namespace)::CreateBackgroundHostForExtensionLoad()
#8 0x557dfb3ff6ad extensions::ProcessManager::CreateStartupBackgroundHosts()
#9 0x557dfb3ff45f extensions::ProcessManager::MaybeCreateStartupBackgroundHosts()
#10 0x557dfb402520 extensions::ProcessManager::Observe()
#11 0x7fbea48e3558 content::NotificationServiceImpl::Notify()
#12 0x557dfeed50af ExtensionService::SetReadyAndNotifyListeners()
#13 0x557dfeed36a0 ExtensionService::Init()
#14 0x557dfef12dc2 extensions::ExtensionSystemImpl::Shared::Init()
#15 0x557dfef137a2 extensions::ExtensionSystemImpl::InitForRegularProfile()
#16 0x557dfcb664ba ProfileManager::DoFinalInitForServices()
#17 0x557dfcb662f3 ProfileManager::DoFinalInit()
#18 0x557dfcb68093 ProfileManager::AddProfile()
#19 0x557dfcb599f2 ProfileManager::CreateAndInitializeProfile()
#20 0x557dfcb59547 ProfileManager::GetProfile()
#21 0x557e002cda08 GetStartupProfile()
#22 0x557dfc6dd99f (anonymous namespace)::CreatePrimaryProfile()
#23 0x557dfc6db686 ChromeBrowserMainParts::PreMainMessageLoopRunImpl()
#24 0x557dfc6da8ec ChromeBrowserMainParts::PreMainMessageLoopRun()
#25 0x7fbea41181e4 content::BrowserMainLoop::PreMainMessageLoopRun()

chromium : extensions, how content scripts get executed

extensions::Dispatcher::RunScriptsAtDocumentEnd

#2 0x5595477272c3 extensions::Dispatcher::RunScriptsAtDocumentEnd()
#3 0x55954c42bb3c ChromeExtensionsRendererClient::RunScriptsAtDocumentEnd()
#4 0x55954c382721 ChromeContentRendererClient::RunScriptsAtDocumentEnd()
#5 0x7ff32f28b88c content::RenderFrameImpl::RunScriptsAtDocumentReady()
#6 0x7ff3226b9739 blink::LocalFrameClientImpl::RunScriptsAtDocumentReady()
#7 0x7ff322f6de36 blink::FrameLoader::FinishedParsing()
#8 0x7ff32239b40b blink::Document::FinishedParsing()
#9 0x7ff323a6a773 blink::HTMLConstructionSite::FinishedParsing()
#10 0x7ff323adf2d7 blink::HTMLTreeBuilder::Finished()
#11 0x7ff323a7e316 blink::HTMLDocumentParser::end()
#12 0x7ff323a74c7f blink::HTMLDocumentParser::AttemptToRunDeferredScriptsAndEnd()
#13 0x7ff323a749a6 blink::HTMLDocumentParser::PrepareToStopParsing()
#14 0x7ff323a7a9cc blink::HTMLDocumentParser::ProcessTokenizedChunkFromBackgroundParser()
#15 0x7ff323a7657d blink::HTMLDocumentParser::PumpPendingSpeculations()
#16 0x7ff323a75eea blink::HTMLDocumentParser::ResumeParsingAfterYield()
#17 0x7ff323a9e2ad blink::HTMLParserScheduler::ContinueParsing()

extensions::Dispatcher::RunScriptsAtDocumentIdle

#2 0x559547727403 extensions::Dispatcher::RunScriptsAtDocumentIdle()
#3 0x55954c42bb8c ChromeExtensionsRendererClient::RunScriptsAtDocumentIdle()
#4 0x55954c382751 ChromeContentRendererClient::RunScriptsAtDocumentIdle()
#5 0x7ff32f28bb0f content::RenderFrameImpl::RunScriptsAtDocumentIdle()
#6 0x7ff3226b9801 blink::LocalFrameClientImpl::RunScriptsAtDocumentIdle()
#7 0x7ff32238dcf3 blink::Document::CheckCompleted()
#8 0x7ff322f6de52 blink::FrameLoader::FinishedParsing()
#9 0x7ff32239b40b blink::Document::FinishedParsing()
#10 0x7ff323a6a773 blink::HTMLConstructionSite::FinishedParsing()
#11 0x7ff323adf2d7 blink::HTMLTreeBuilder::Finished()
#12 0x7ff323a7e316 blink::HTMLDocumentParser::end()
#13 0x7ff323a74c7f blink::HTMLDocumentParser::AttemptToRunDeferredScriptsAndEnd()
#14 0x7ff323a749a6 blink::HTMLDocumentParser::PrepareToStopParsing()
#15 0x7ff323a7a9cc blink::HTMLDocumentParser::ProcessTokenizedChunkFromBackgroundParser()
#16 0x7ff323a7657d blink::HTMLDocumentParser::PumpPendingSpeculations()
#17 0x7ff323a75eea blink::HTMLDocumentParser::ResumeParsingAfterYield()
#18 0x7ff323a9e2ad blink::HTMLParserScheduler::ContinueParsing()

#2 0x559547727403 extensions::Dispatcher::RunScriptsAtDocumentIdle()
#3 0x55954c42bb8c ChromeExtensionsRendererClient::RunScriptsAtDocumentIdle()
#4 0x55954c382751 ChromeContentRendererClient::RunScriptsAtDocumentIdle()
#5 0x7ff32f28bb0f content::RenderFrameImpl::RunScriptsAtDocumentIdle()
#6 0x7ff3226b9801 blink::LocalFrameClientImpl::RunScriptsAtDocumentIdle()
#7 0x7ff32238dcf3 blink::Document::CheckCompleted()
#8 0x7ff32237ce49 blink::Document::LoadEventDelayTimerFired()
#9 0x7ff321e243c1 blink::TaskRunnerTimer<>::Fired()
#10 0x7ff3203dac39 blink::TimerBase::RunInternal()

extensions::Dispatcher::RunScriptsAtDocumentStart

#2 0x559547727183 extensions::Dispatcher::RunScriptsAtDocumentStart()
#3 0x55954c42baec ChromeExtensionsRendererClient::RunScriptsAtDocumentStart()
#4 0x55954c3826f1 ChromeContentRendererClient::RunScriptsAtDocumentStart()
#5 0x7ff32f28a58f content::RenderFrameImpl::RunScriptsAtDocumentElementAvailable()
#6 0x7ff3226b9631 blink::LocalFrameClientImpl::RunScriptsAtDocumentElementAvailable()
#7 0x7ff322f74199 blink::FrameLoader::RunScriptsAtDocumentElementAvailable()
#8 0x7ff3228d47fa blink::HTMLHtmlElement::InsertedByParser()
#9 0x7ff323a68417 blink::HTMLConstructionSite::InsertHTMLHtmlStartTagBeforeHTML()
#10 0x7ff323ad9f86 blink::HTMLTreeBuilder::DefaultForBeforeHTML()
#11 0x7ff323ad3cd3 blink::HTMLTreeBuilder::ProcessEndOfFile()
#12 0x7ff323acdba8 blink::HTMLTreeBuilder::ProcessToken()
#13 0x7ff323acca3e blink::HTMLTreeBuilder::ConstructTree()
#14 0x7ff323a7c569 blink::HTMLDocumentParser::ConstructTreeFromHTMLToken()
#15 0x7ff323a7554f blink::HTMLDocumentParser::PumpTokenizer()
#16 0x7ff323a74a9e blink::HTMLDocumentParser::PumpTokenizerIfPossible()
#17 0x7ff323a7490b blink::HTMLDocumentParser::PrepareToStopParsing()
#18 0x7ff323a7e38f blink::HTMLDocumentParser::AttemptToEnd()
#19 0x7ff323a7ec09 blink::HTMLDocumentParser::Finish()
#20 0x7ff322f48a9f blink::DocumentLoader::FinishedLoading()
#21 0x7ff322f4bef7 blink::DocumentLoader::MaybeLoadEmpty()
#22 0x7ff322f4c0aa blink::DocumentLoader::StartLoading()
#23 0x7ff322f6cf3b blink::FrameLoader::Init()
#24 0x7ff32278e370 blink::LocalFrame::Init()
#25 0x7ff32283843b blink::WebLocalFrameImpl::InitializeCoreFrame()
#26 0x7ff322839643 blink::WebLocalFrameImpl::CreateChildFrame()
#27 0x7ff3226bc864 blink::LocalFrameClientImpl::CreateFrame()
#28 0x7ff3228d01ff blink::HTMLFrameOwnerElement::LoadOrRedirectSubframe()
#29 0x7ff3228cd834 blink::HTMLFrameElementBase::OpenURL()
#30 0x7ff3228ce314 blink::HTMLFrameElementBase::SetNameAndOpenURL()
#31 0x7ff3228ce4ce blink::HTMLFrameElementBase::DidNotifySubtreeInsertionsToDocument()
#32 0x7ff322358190 blink::ContainerNode::DidInsertNodeVector()
#33 0x7ff322358b63 blink::ContainerNode::AppendChild()
#34 0x7ff32245fe9a blink::Node::appendChild()
#35 0x7ff323537216 blink::NodeV8Internal::appendChildMethodForMainWorld()
#36 0x7ff323536ed7 blink::V8Node::appendChildMethodCallbackForMainWorld()
#37 0x7ff3244240f2 v8::internal::FunctionCallbackArguments::Call()
#38 0x7ff32451f0a5 v8::internal::(anonymous namespace)::HandleApiCallHelper<>()
#39 0x7ff32451d199 v8::internal::Builtin_Impl_HandleApiCall()
#40 0x7ff32451cbdd v8::internal::Builtin_HandleApiCall()

chromium : how extension install prompt dialog get showed

installerprompt
 
#2 0x5589ca9aaeba ExtensionInstallPrompt::ShowDialog()
#3 0x5589ca9aac7c ExtensionInstallPrompt::ShowDialog()
#4 0x5589ca9aa96e ExtensionInstallPrompt::ShowDialog()
#5 0x5589cb168cca extensions::WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess()
#6 0x5589cab3821b extensions::WebstoreInstallHelper::ReportResultsIfComplete()
#7 0x5589cab37efd extensions::WebstoreInstallHelper::OnFetchComplete()
#8 0x5589c85da07b chrome::BitmapFetcher::OnImageDecoded()
#9 0x5589c85dc1d1 ImageDecoder::OnDecodeImageSucceeded()
#10 0x5589c7303c4f _ZN4base8internal13FunctorTraitsIMN10extensions8internal26ScopedCallbackRunnerHelperIFvRKNSt3__16vectorIhNS5_9allocatorIhEEEEN6device5mojom18SerialReceiveErrorEEEEFvSB_SE_EvE6InvokeIPSG_JS9_SE_EEEvSI_OT_DpOT0_
#11 0x5589c7303baa _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIMN10extensions8internal26ScopedCallbackRunnerHelperIFvRKNSt3__16vectorIhNS7_9allocatorIhEEEEN6device5mojom18SerialReceiveErrorEEEEFvSD_SG_EJPSI_SB_SG_EEEvOT_DpOT0_
#12 0x5589c85dda95 _ZN4base8internal7InvokerINS0_9BindStateIM22SiteDataCountingHelperFvRKNSt3__13setI4GURLNS4_4lessIS6_EENS4_9allocatorIS6_EEEEN7storage11StorageTypeEEJNS0_17UnretainedWrapperIS3_EEEEEFvSD_SF_EE7RunImplIRKSH_RKNS4_5tupleIJSJ_EEEJLm0EEEEvOT_OT0_NS4_16integer_sequenceImJXspT1_EEEESD_OSF_
#13 0x5589c85dda13 _ZN4base8internal7InvokerINS0_9BindStateIM22SiteDataCountingHelperFvRKNSt3__13setI4GURLNS4_4lessIS6_EENS4_9allocatorIS6_EEEEN7storage11StorageTypeEEJNS0_17UnretainedWrapperIS3_EEEEEFvSD_SF_EE3RunEPNS0_13BindStateBaseESD_SF_
#14 0x5589c8300fb6 _ZNKR4base17RepeatingCallbackIFvRKNS_8FilePathEN30DownloadPathReservationTracker22FilenameConflictActionEEE3RunES3_S5_
#15 0x5589c85db8cc (anonymous namespace)::OnDecodeImageDone()
#16 0x5589c85dddd9 _ZN4base8internal13FunctorTraitsIPFvNS_17RepeatingCallbackIFviEEENS2_IFvRK8SkBitmapiEEEiS7_EvE6InvokeIJRKS4_RKS9_RKiS7_EEEvSB_DpOT_
#17 0x5589c85ddd50 _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIRKPFvNS_17RepeatingCallbackIFviEEENS4_IFvRK8SkBitmapiEEEiS9_EJRKS6_RKSB_RKiS9_EEEvOT_DpOT0_
#18 0x5589c85ddcd9 _ZN4base8internal7InvokerINS0_9BindStateIPFvNS_17RepeatingCallbackIFviEEENS3_IFvRK8SkBitmapiEEEiS8_EJS5_SA_iEEEFvS8_EE7RunImplIRKSC_RKNSt3__15tupleIJS5_SA_iEEEJLm0ELm1ELm2EEEEvOT_OT0_NSJ_16integer_sequenceImJXspT1_EEEES8_
#19 0x5589c85ddb94 _ZN4base8internal7InvokerINS0_9BindStateIPFvNS_17RepeatingCallbackIFviEEENS3_IFvRK8SkBitmapiEEEiS8_EJS5_SA_iEEEFvS8_EE3RunEPNS0_13BindStateBaseES8_
#20 0x5589c6a440a1 _ZNO4base12OnceCallbackIFvRKN13safe_browsing22ArchiveAnalyzerResultsEEE3RunES4_
#21 0x5589c6f7c660 _ZN4base8internal13FunctorTraitsINS_12OnceCallbackIFvRKN13update_client12CrxInstaller6ResultEEEEvE6InvokeIS9_JS5_EEEvOT_DpOT0_
#22 0x5589c6f7c55d _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoINS_12OnceCallbackIFvRKN13update_client12CrxInstaller6ResultEEEEJS7_EEEvOT_DpOT0_
#23 0x5589c6f7c520 _ZN4base8internal7InvokerINS0_9BindStateINS_12OnceCallbackIFvRKN13update_client12CrxInstaller6ResultEEEEJS6_EEEFvvEE7RunImplISA_NSt3__15tupleIJS6_EEEJLm0EEEEvOT_OT0_NSF_16integer_sequenceImJXspT1_EEEE
#24 0x5589c6f7c479 _ZN4base8internal7InvokerINS0_9BindStateINS_12OnceCallbackIFvRKN13update_client12CrxInstaller6ResultEEEEJS6_EEEFvvEE7RunOnceEPNS0_13BindStateBaseE
#25 0x7f636ffcc061 _ZNO4base12OnceCallbackIFvvEE3RunEv
#26 0x7f63700261ca base::debug::TaskAnnotator::RunTask()
#27 0x7f63700c7105 base::internal::IncomingTaskQueue::RunTask()
#28 0x7f63700d005a base::MessageLoop::RunTask()
#29 0x7f63700d0306 base::MessageLoop::DeferOrRunPendingTask()
#30 0x7f63700d0650 base::MessageLoop::DoWork()
#31 0x7f63700d3cfc base::MessagePumpGlib::HandleDispatch()
#32 0x7f63700d44a1 base::(anonymous namespace)::WorkSourceDispatch()
#33 0x7f6358d36e04 g_main_context_dispatch
#34 0x7f6358d37048 <unknown>
#35 0x7f6358d370ec g_main_context_iteration
#36 0x7f63700d3dff base::MessagePumpGlib::Run()
#37 0x7f63700cf7dc base::MessageLoop::Run()
#38 0x7f637017c79b base::RunLoop::Run()
#39 0x5589c81d6e4d ChromeBrowserMainParts::MainMessageLoopRun()
#40 0x7f636a340b56 content::BrowserMainLoop::RunMainMessageLoopParts()
#41 0x7f636a34a95f content::BrowserMainRunnerImpl::Run()
#42 0x7f636a3346ab content::BrowserMain()
#43 0x7f636bf029b8 content::RunNamedProcessTypeMain()
#44 0x7f636bf055aa content::ContentMainRunnerImpl::Run()
#45 0x7f636befba6d content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
#46 0x7f637083d89d service_manager::Main()
#47 0x7f636bf017ff content::ContentMain()
#48 0x5589c69b623e ChromeMain
#49 0x5589c69b6152 main
#50 0x7f635721cf45 __libc_start_main
#51 0x5589c69b602a _start
 

#2 0x56342b8ac561 extensions::WebstoreInstallHelper::Start()
#3 0x56342bedc79e extensions::WebstorePrivateBeginInstallWithManifest3Function::Run()
#4 0x563427b821cd ExtensionFunction::RunWithValidation()
#5 0x563427b894d0 extensions::ExtensionFunctionDispatcher::DispatchWithCallbackInternal()
#6 0x563427b884e4 extensions::ExtensionFunctionDispatcher::Dispatch()
#7 0x563427bf08ec extensions::ExtensionWebContentsObserver::OnRequest()
#8 0x563427b05fd2 _ZN3IPC20DispatchToMethodImplIN10extensions21AppWindowContentsImplEMS2_FvPN7content15RenderFrameHostERKNSt3__16vectorINS1_15DraggableRegionENS6_9allocatorIS8_EEEEES4_NS6_5tupleIJSB_EEEJLm0EEEEvPT_T0_PT1_OT2_NS6_16integer_sequenceImJXspT3_EEEE
#9 0x563427b05f00 _ZN3IPC16DispatchToMethodIN10extensions21AppWindowContentsImplEN7content15RenderFrameHostEJRKNSt3__16vectorINS1_15DraggableRegionENS5_9allocatorIS7_EEEEENS5_5tupleIJSA_EEEEENS5_9enable_ifIXeqsZT1_sr3std10tuple_sizeINS5_5decayIT2_E4typeEEE5valueEvE4typeEPT_MSM_FvPT0_DpT1_ESP_OSH_
#10 0x563427bf1021 _ZN3IPC8MessageTI29ExtensionHostMsg_Request_MetaNSt3__15tupleIJ31ExtensionHostMsg_Request_ParamsEEEvE8DispatchIN10extensions28ExtensionWebContentsObserverES9_N7content15RenderFrameHostEMS9_FvPSB_RKS4_EEEbPKNS_7MessageEPT_PT0_PT1_T2_
#11 0x563427bf085c extensions::ExtensionWebContentsObserver::OnMessageReceived()
#12 0x56342b60544a extensions::ChromeExtensionWebContentsObserver::OnMessageReceived()
#13 0x7f0fbfc2b229 content::WebContentsImpl::OnMessageReceived()
#14 0x7f0fbf38664a content::RenderFrameHostImpl::OnMessageReceived()
#15 0x7f0fbf914861 content::RenderProcessHostImpl::OnMessageReceived()
#16 0x7f0fc30edbc8 IPC::ChannelProxy::Context::OnDispatchMessage()
#17 0x7f0fc30f403f _ZN4base8internal13FunctorTraitsIMN3IPC12ChannelProxy7ContextEFvRKNS2_7MessageEEvE6InvokeIRK13scoped_refptrIS4_EJS7_EEEvS9_OT_DpOT0_
#18 0x7f0fc30f3f9f _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIRKMN3IPC12ChannelProxy7ContextEFvRKNS4_7MessageEEJRK13scoped_refptrIS6_ES9_EEEvOT_DpOT0_
#19 0x7f0fc30f3f2d _ZN4base8internal7InvokerINS0_9BindStateIMN3IPC12ChannelProxy7ContextEFvRKNS3_7MessageEEJ13scoped_refptrIS5_ES6_EEEFvvEE7RunImplIRKSA_RKNSt3__15tupleIJSC_S6_EEEJLm0ELm1EEEEvOT_OT0_NSJ_16integer_sequenceImJXspT1_EEEE
#20 0x7f0fc30f3e3c _ZN4base8internal7InvokerINS0_9BindStateIMN3IPC12ChannelProxy7ContextEFvRKNS3_7MessageEEJ13scoped_refptrIS5_ES6_EEEFvvEE3RunEPNS0_13BindStateBaseE
#21 0x7f0fc4bd9061 _ZNO4base12OnceCallbackIFvvEE3RunEv
#22 0x7f0fc4c331ca base::debug::TaskAnnotator::RunTask()
#23 0x7f0fc4cd4105 base::internal::IncomingTaskQueue::RunTask()
#24 0x7f0fc4cdd05a base::MessageLoop::RunTask()
#25 0x7f0fc4cdd306 base::MessageLoop::DeferOrRunPendingTask()
#26 0x7f0fc4cdd650 base::MessageLoop::DoWork()
#27 0x7f0fc4ce0cfc base::MessagePumpGlib::HandleDispatch()
#28 0x7f0fc4ce14a1 base::(anonymous namespace)::WorkSourceDispatch()
#29 0x7f0fad943e04 g_main_context_dispatch
#30 0x7f0fad944048 <unknown>
#31 0x7f0fad9440ec g_main_context_iteration
#32 0x7f0fc4ce0dff base::MessagePumpGlib::Run()
#33 0x7f0fc4cdc7dc base::MessageLoop::Run()
#34 0x7f0fc4d8979b base::RunLoop::Run()
#35 0x563428f4be4d ChromeBrowserMainParts::MainMessageLoopRun()
#36 0x7f0fbef4db56 content::BrowserMainLoop::RunMainMessageLoopParts()
#37 0x7f0fbef5795f content::BrowserMainRunnerImpl::Run()
#38 0x7f0fbef416ab content::BrowserMain()
#39 0x7f0fc0b0f9b8 content::RunNamedProcessTypeMain()
#40 0x7f0fc0b125aa content::ContentMainRunnerImpl::Run()
#41 0x7f0fc0b08a6d content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
#42 0x7f0fc544a89d service_manager::Main()
#43 0x7f0fc0b0e7ff content::ContentMain()
#44 0x56342772b23e ChromeMain
#45 0x56342772b152 main
#46 0x7f0fabe29f45 __libc_start_main
#47 0x56342772b02a _start

chromium : extensions load back trace

#2 0x55c01d36db9d extensions::ExtensionRegistry::AddEnabled()
#3 0x55c01d3696cf extensions::ExtensionRegistrar::AddExtension()
#4 0x55c020eda0f6 ExtensionService::AddExtension()
#5 0x55c020f7e344 extensions::InstalledLoader::Load()
#6 0x55c020f7f31b extensions::InstalledLoader::LoadAllExtensions()
#7 0x55c020ed12e5 ExtensionService::Init()
#8 0x55c020f10a82 extensions::ExtensionSystemImpl::Shared::Init()
#9 0x55c020f11462 extensions::ExtensionSystemImpl::InitForRegularProfile()
#10 0x55c01eb6419a ProfileManager::DoFinalInitForServices()
#11 0x55c01eb63fd3 ProfileManager::DoFinalInit()
#12 0x55c01eb65d73 ProfileManager::AddProfile()
#13 0x55c01eb576d2 ProfileManager::CreateAndInitializeProfile()
#14 0x55c01eb57227 ProfileManager::GetProfile()
#15 0x55c0222cb5f8 GetStartupProfile()
#16 0x55c01e6db67f (anonymous namespace)::CreatePrimaryProfile()
#17 0x55c01e6d9366 ChromeBrowserMainParts::PreMainMessageLoopRunImpl()
#18 0x55c01e6d85cc ChromeBrowserMainParts::PreMainMessageLoopRun()
#19 0x7fccb0fb41e4 content::BrowserMainLoop::PreMainMessageLoopRun()
#20 0x7fccafe9bcfd _ZN4base8internal13FunctorTraitsIMN7content14NetworkContext11DiskCheckerEFvvEvE6InvokeIPS4_JEEEvS6_OT_DpOT0_
#21 0x7fccafe9bc74 _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIMN7content14NetworkContextEFvvEJPS5_EEEvOT_DpOT0_
#22 0x7fccafe9bc25 _ZN4base8internal7InvokerINS0_9BindStateIMN7content14NetworkContext11DiskCheckerEFvvEJNS0_17UnretainedWrapperIS5_EEEEEFvvEE7RunImplIRKS7_RKNSt3__15tupleIJS9_EEEJLm0EEEEvOT_OT0_NSG_16integer_sequenceImJXspT1_EEEE
#23 0x7fccafea19dc _ZN4base8internal7InvokerINS0_9BindStateIMN7content14NetworkContext11DiskCheckerEFvvEJNS0_17UnretainedWrapperIS5_EEEEEFvvEE3RunEPNS0_13BindStateBaseE
#24 0x7fccafe5c50d _ZNKR4base17RepeatingCallbackIFvvEE3RunEv
#25 0x7fccb1c19edd content::StartupTaskRunner::RunAllTasksNow()
#26 0x7fccb0fafa67 content::BrowserMainLoop::CreateStartupTasks()
#27 0x7fccb0fbe60d content::BrowserMainRunnerImpl::Initialize()
#28 0x7fccb0fa8644 content::BrowserMain()
#29 0x7fccb2b769b8 content::RunNamedProcessTypeMain()
#30 0x7fccb2b795aa content::ContentMainRunnerImpl::Run()
#31 0x7fccb2b6fa6d content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
#32 0x7fccb74b189d service_manager::Main()
#33 0x7fccb2b757ff content::ContentMain()
#34 0x55c01cebb23e ChromeMain
#35 0x55c01cebb152 main
#36 0x7fcc9de90f45 __libc_start_main

chromium : How KeyedService was created

DependencyManager::CreateContextServices

void DependencyManager::CreateContextServices(base::SupportsUserData* context,
                                              bool is_testing_context) {
  MarkContextLive(context);

  std::vector<DependencyNode*> construction_order;
  if (!dependency_graph_.GetConstructionOrder(&construction_order)) {
    NOTREACHED();
  }

#ifndef NDEBUG
  DumpContextDependencies(context);
#endif

  for (auto* dependency_node : construction_order) {
    KeyedServiceBaseFactory* factory =
        static_cast<KeyedServiceBaseFactory*>(dependency_node);
    if (is_testing_context && factory->ServiceIsNULLWhileTesting() &&
        !factory->HasTestingFactory(context)) {
      factory->SetEmptyTestingFactory(context);
    } else if (factory->ServiceIsCreatedWithContext()) {
      factory->CreateServiceNow(context);
    }
  }
}
 
#14 0x7f08ec0395de DependencyManager::CreateContextServices()
#15 0x7f08eb2b2410 BrowserContextDependencyManager::DoCreateBrowserContextServices()
#16 0x7f08eb2b22df BrowserContextDependencyManager::CreateBrowserContextServices()
#17 0x55aa9c98a995 ProfileImpl::OnLocaleReady()
#18 0x55aa9c986389 ProfileImpl::OnPrefsLoaded()
#19 0x55aa9c98605d ProfileImpl::ProfileImpl()
#20 0x55aa9c982084 Profile::CreateProfile()
#21 0x55aa9c9f7887 ProfileManager::CreateProfileHelper()
#22 0x55aa9c9e96ba ProfileManager::CreateAndInitializeProfile()
#23 0x55aa9c9e9237 ProfileManager::GetProfile()
#24 0x55aaa015d608 GetStartupProfile()
#25 0x55aa9c56d68f (anonymous namespace)::CreatePrimaryProfile()
#26 0x55aa9c56b376 ChromeBrowserMainParts::PreMainMessageLoopRunImpl()
#27 0x55aa9c56a5dc ChromeBrowserMainParts::PreMainMessageLoopRun()
#28 0x7f08f12591e4 content::BrowserMainLoop::PreMainMessageLoopRun()
#29 0x7f08f0140cfd _ZN4base8internal13FunctorTraitsIMN7content14NetworkContext11DiskCheckerEFvvEvE6InvokeIPS4_JEEEvS6_OT_DpOT0_
#30 0x7f08f0140c74 _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIMN7content14NetworkContextEFvvEJPS5_EEEvOT_DpOT0_
#31 0x7f08f0140c25 _ZN4base8internal7InvokerINS0_9BindStateIMN7content14NetworkContext11DiskCheckerEFvvEJNS0_17UnretainedWrapperIS5_EEEEEFvvEE7RunImplIRKS7_RKNSt3__15tupleIJS9_EEEJLm0EEEEvOT_OT0_NSG_16integer_sequenceImJXspT1_EEEE
#32 0x7f08f01469dc _ZN4base8internal7InvokerINS0_9BindStateIMN7content14NetworkContext11DiskCheckerEFvvEJNS0_17UnretainedWrapperIS5_EEEEEFvvEE3RunEPNS0_13BindStateBaseE
#33 0x7f08f010150d _ZNKR4base17RepeatingCallbackIFvvEE3RunEv
#34 0x7f08f1ebeedd content::StartupTaskRunner::RunAllTasksNow()
#35 0x7f08f1254a67 content::BrowserMainLoop::CreateStartupTasks()
#36 0x7f08f126360d content::BrowserMainRunnerImpl::Initialize()
#37 0x7f08f124d644 content::BrowserMain()
#38 0x7f08f2e1b9b8 content::RunNamedProcessTypeMain()
#39 0x7f08f2e1e5aa content::ContentMainRunnerImpl::Run()
#40 0x7f08f2e14a6d content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
#41 0x7f08f775689d service_manager::Main()
#42 0x7f08f2e1a7ff content::ContentMain()
#43 0x55aa9ad4d23e ChromeMain
#44 0x55aa9ad4d152 main
#45 0x7f08de135f45 __libc_start_main
#46 0x55aa9ad4d02a _start

BuildServiceInstanceFor AppShortcutManager

#9 0x55aa9b11a513 AppShortcutManager::AppShortcutManager()
#10 0x55aa9b11be82 AppShortcutManagerFactory::BuildServiceInstanceFor()
#11 0x7f08eb2b605a BrowserContextKeyedServiceFactory::BuildServiceInstanceFor()
#12 0x7f08ec03d727 KeyedServiceFactory::GetServiceForContext()
#13 0x7f08ec03ea52 KeyedServiceFactory::CreateServiceNow()

AppShortcutManagerFactory::GetInstance

#2 0x7f5a9625a2d6 DependencyGraph::AddNode()
#3 0x7f5a96269e3c DependencyManager::AddComponent()
#4 0x7f5a9626cdab KeyedServiceBaseFactory::KeyedServiceBaseFactory()
#5 0x7f5a9626d88a KeyedServiceFactory::KeyedServiceFactory()
#6 0x7f5a954e6d7a BrowserContextKeyedServiceFactory::BrowserContextKeyedServiceFactory()
#7 0x5635734e7de3 AppShortcutManagerFactory::AppShortcutManagerFactory()
#8 0x5635734e7fc0 base::DefaultSingletonTraits<>::New()
#9 0x5635734e7f36 base::Singleton<>::get()
#10 0x5635734e7da9 AppShortcutManagerFactory::GetInstance()
#11 0x5635734e3f92 chrome_apps::EnsureBrowserContextKeyedServiceFactoriesBuilt()
#12 0x563574ccc9f8 ChromeBrowserMainExtraPartsProfiles::EnsureBrowserContextKeyedServiceFactoriesBuilt()
#13 0x563574cccdf1 ChromeBrowserMainExtraPartsProfiles::PreProfileInit()
#14 0x5635749387b5 ChromeBrowserMainParts::PreProfileInit()
#15 0x56357492ef9c ChromeBrowserMainPartsLinux::PreProfileInit()
#16 0x5635749371e0 ChromeBrowserMainParts::PreMainMessageLoopRunImpl()
#17 0x5635749365dc ChromeBrowserMainParts::PreMainMessageLoopRun()
#18 0x7f5a9b48a1e4 content::BrowserMainLoop::PreMainMessageLoopRun()

Summary

each KeyedService, such as AppShortcutManager, has a KeyedServiceFactory which are derived from KeyedServiceBaseFactory.
each KeyedServiceFactory must implement BuildServiceInstanceFor interface.
When new instance for each KeyedServiceFactory, it will be added to DependencyManager as a component.
Chromium will call DependencyManager::CreateContextServices at the initial state.
Then traverse all node in DependencyGraph and call each BuildServiceInstanceFor to create the real KeyedService.

chromium : extensions UI(chrome://extensions) create back trace

#2 0x561c61ba4b95 (anonymous namespace)::GetWebUIFactoryFunction()
#3 0x561c61ba35b2 ChromeWebUIControllerFactory::GetWebUIType()
#4 0x561c61ba5962 ChromeWebUIControllerFactory::UseWebUIForURL()
#5 0x7fe6df4aa299 content::WebUIControllerFactoryRegistry::UseWebUIForURL()
#6 0x7fe6df4aa3f5 content::WebUIControllerFactoryRegistry::IsURLAcceptableForWebUI()
#7 0x7fe6df4b2147 content::WebUIImpl::OnWebUISend()
#8 0x7fe6df4b59ef _ZN3IPC20DispatchToMethodImplIN7content9WebUIImplEMS2_FvPNS1_15RenderFrameHostERK4GURLRKNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEERKN4base9ListValueEES3_NS8_5tupleIJS5_SE_SI_EEEJLm0ELm1ELm2EEEEvPT_T0_PT1_OT2_NS8_16integer_sequenceImJXspT3_EEEE
#9 0x7fe6df4b58d0 _ZN3IPC16DispatchToMethodIN7content9WebUIImplENS1_15RenderFrameHostEJRK4GURLRKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKN4base9ListValueEENS7_5tupleIJS4_SD_SH_EEEEENS7_9enable_ifIXeqsZT1_sr3std10tuple_sizeINS7_5decayIT2_E4typeEEE5valueEvE4typeEPT_MST_FvPT0_DpT1_ESW_OSO_
#10 0x7fe6df4b5780 _ZN3IPC8MessageTI27FrameHostMsg_WebUISend_MetaNSt3__15tupleIJ4GURLNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEN4base9ListValueEEEEvE8DispatchIN7content9WebUIImplESH_NSG_15RenderFrameHostEMSH_FvPSI_RKS4_RKSA_RKSC_EEEbPKNS_7MessageEPT_PT0_PT1_T2_
#11 0x7fe6df4b207c content::WebUIImpl::OnMessageReceived()
#12 0x7fe6df43d18e content::WebContentsImpl::OnMessageReceived()
#13 0x7fe6deb9864a content::RenderFrameHostImpl::OnMessageReceived()
#14 0x7fe6df126861 content::RenderProcessHostImpl::OnMessageReceived()
#15 0x7fe6e28ffbc8 IPC::ChannelProxy::Context::OnDispatchMessage()
#16 0x7fe6e290603f _ZN4base8internal13FunctorTraitsIMN3IPC12ChannelProxy7ContextEFvRKNS2_7MessageEEvE6InvokeIRK13scoped_refptrIS4_EJS7_EEEvS9_OT_DpOT0_
#17 0x7fe6e2905f9f _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIRKMN3IPC12ChannelProxy7ContextEFvRKNS4_7MessageEEJRK13scoped_refptrIS6_ES9_EEEvOT_DpOT0_
#18 0x7fe6e2905f2d _ZN4base8internal7InvokerINS0_9BindStateIMN3IPC12ChannelProxy7ContextEFvRKNS3_7MessageEEJ13scoped_refptrIS5_ES6_EEEFvvEE7RunImplIRKSA_RKNSt3__15tupleIJSC_S6_EEEJLm0ELm1EEEEvOT_OT0_NSJ_16integer_sequenceImJXspT1_EEEE
#19 0x7fe6e2905e3c _ZN4base8internal7InvokerINS0_9BindStateIMN3IPC12ChannelProxy7ContextEFvRKNS3_7MessageEEJ13scoped_refptrIS5_ES6_EEEFvvEE3RunEPNS0_13BindStateBaseE
#20 0x7fe6e43eb061 _ZNO4base12OnceCallbackIFvvEE3RunEv
#21 0x7fe6e44451ca base::debug::TaskAnnotator::RunTask()
#22 0x7fe6e44e6105 base::internal::IncomingTaskQueue::RunTask()
#23 0x7fe6e44ef05a base::MessageLoop::RunTask()
#24 0x7fe6e44ef306 base::MessageLoop::DeferOrRunPendingTask()
#25 0x7fe6e44ef650 base::MessageLoop::DoWork()
#26 0x7fe6e44f2e36 base::MessagePumpGlib::Run()
#27 0x7fe6e44ee7dc base::MessageLoop::Run()
#28 0x7fe6e459b79b base::RunLoop::Run()
#29 0x561c5e0fad2d ChromeBrowserMainParts::MainMessageLoopRun()
#30 0x7fe6de75fb56 content::BrowserMainLoop::RunMainMessageLoopParts()
#31 0x7fe6de76995f content::BrowserMainRunnerImpl::Run()
#32 0x7fe6de7536ab content::BrowserMain()
#33 0x7fe6e03219b8 content::RunNamedProcessTypeMain()
#34 0x7fe6e03245aa content::ContentMainRunnerImpl::Run()
#35 0x7fe6e031aa6d content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
#36 0x7fe6e4c5c89d service_manager::Main()
#37 0x7fe6e03207ff content::ContentMain()
#38 0x561c5c8da23e ChromeMain
#39 0x561c5c8da152 main
#40 0x7fe6cb63bf45 __libc_start_main
#41 0x561c5c8da02a _start

chromium : extensions RendererStartupHelper InitializeProcess back trace

#2 0x561c5ce30032 extensions::RendererStartupHelper::InitializeProcess()
#3 0x561c5ce2f331 extensions::RendererStartupHelper::Observe()
#4 0x7fe6def2a33f content::NotificationServiceImpl::Notify()
#5 0x7fe6df12ebac content::RenderProcessHostImpl::OnProcessLaunched()
#6 0x7fe6de83aebc content::ChildProcessLauncher::Notify()
#7 0x7fe6de83da40 content::internal::ChildProcessLauncherHelper::PostLaunchOnClientThread()
#8 0x7fe6de83e529 _ZN4base8internal13FunctorTraitsIMN7content8internal26ChildProcessLauncherHelperEFvNS4_7ProcessEiEvE6InvokeI13scoped_refptrIS4_EJS5_iEEEvS7_OT_DpOT0_
#9 0x7fe6de83e43a _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIMN7content8internal26ChildProcessLauncherHelperEFvNS6_7ProcessEiEJ13scoped_refptrIS6_ES7_iEEEvOT_DpOT0_
#10 0x7fe6de83e3a3 _ZN4base8internal7InvokerINS0_9BindStateIMN7content8internal26ChildProcessLauncherHelperEFvNS5_7ProcessEiEJ13scoped_refptrIS5_ENS0_13PassedWrapperIS6_EEiEEEFvvEE7RunImplIS8_NSt3__15tupleIJSA_SC_iEEEJLm0ELm1ELm2EEEEvOT_OT0_NSH_16integer_sequenceImJXspT1_EEEE
#11 0x7fe6de83e279 _ZN4base8internal7InvokerINS0_9BindStateIMN7content8internal26ChildProcessLauncherHelperEFvNS5_7ProcessEiEJ13scoped_refptrIS5_ENS0_13PassedWrapperIS6_EEiEEEFvvEE7RunOnceEPNS0_13BindStateBaseE
#12 0x7fe6e43eb061 _ZNO4base12OnceCallbackIFvvEE3RunEv
#13 0x7fe6e44451ca base::debug::TaskAnnotator::RunTask()
#14 0x7fe6e44e6105 base::internal::IncomingTaskQueue::RunTask()
#15 0x7fe6e44ef05a base::MessageLoop::RunTask()
#16 0x7fe6e44ef306 base::MessageLoop::DeferOrRunPendingTask()
#17 0x7fe6e44ef650 base::MessageLoop::DoWork()
#18 0x7fe6e44f2cfc base::MessagePumpGlib::HandleDispatch()
#19 0x7fe6e44f34a1 base::(anonymous namespace)::WorkSourceDispatch()
#20 0x7fe6cd155e04 g_main_context_dispatch
#21 0x7fe6cd156048 <unknown>
#22 0x7fe6cd1560ec g_main_context_iteration
#23 0x7fe6e44f2dff base::MessagePumpGlib::Run()
#24 0x7fe6e44ee7dc base::MessageLoop::Run()
#25 0x7fe6e459b79b base::RunLoop::Run()
#26 0x561c5e0fad2d ChromeBrowserMainParts::MainMessageLoopRun()
#27 0x7fe6de75fb56 content::BrowserMainLoop::RunMainMessageLoopParts()
#28 0x7fe6de76995f content::BrowserMainRunnerImpl::Run()
#29 0x7fe6de7536ab content::BrowserMain()
#30 0x7fe6e03219b8 content::RunNamedProcessTypeMain()
#31 0x7fe6e03245aa content::ContentMainRunnerImpl::Run()
#32 0x7fe6e031aa6d content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
#33 0x7fe6e4c5c89d service_manager::Main()
#34 0x7fe6e03207ff content::ContentMain()
#35 0x561c5c8da23e ChromeMain
#36 0x561c5c8da152 main
#37 0x7fe6cb63bf45 __libc_start_main
#38 0x561c5c8da02a _start

chromium : extensions::Extension construction back trace in Browser process

#2 0x55aaedfdafa6 extensions::Extension::Create()
#3 0x55aaedfdaf22 extensions::Extension::Create()
#4 0x55aaeec372eb extensions::ComponentLoader::CreateExtension()
#5 0x55aaeec34321 extensions::ComponentLoader::Load()
#6 0x55aaeec34100 extensions::ComponentLoader::LoadAll()
#7 0x55aaeecc028c ExtensionService::Init()
#8 0x55aaeecffa72 extensions::ExtensionSystemImpl::Shared::Init()
#9 0x55aaeed00452 extensions::ExtensionSystemImpl::InitForRegularProfile()
#10 0x55aaec95317a ProfileManager::DoFinalInitForServices()
#11 0x55aaec952fb3 ProfileManager::DoFinalInit()
#12 0x55aaec954d53 ProfileManager::AddProfile()
#13 0x55aaec9466b2 ProfileManager::CreateAndInitializeProfile()
#14 0x55aaec946207 ProfileManager::GetProfile()
#15 0x55aaf00ba618 GetStartupProfile()
#16 0x55aaec4ca65f (anonymous namespace)::CreatePrimaryProfile()
#17 0x55aaec4c8346 ChromeBrowserMainParts::PreMainMessageLoopRunImpl()
#18 0x55aaec4c75ac ChromeBrowserMainParts::PreMainMessageLoopRun()
#19 0x7f1d0223d1e4 content::BrowserMainLoop::PreMainMessageLoopRun()
#20 0x7f1d01124cfd _ZN4base8internal13FunctorTraitsIMN7content14NetworkContext11DiskCheckerEFvvEvE6InvokeIPS4_JEEEvS6_OT_DpOT0_
#21 0x7f1d01124c74 _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIMN7content14NetworkContextEFvvEJPS5_EEEvOT_DpOT0_
#22 0x7f1d01124c25 _ZN4base8internal7InvokerINS0_9BindStateIMN7content14NetworkContext11DiskCheckerEFvvEJNS0_17UnretainedWrapperIS5_EEEEEFvvEE7RunImplIRKS7_RKNSt3__15tupleIJS9_EEEJLm0EEEEvOT_OT0_NSG_16integer_sequenceImJXspT1_EEEE
#23 0x7f1d0112a9dc _ZN4base8internal7InvokerINS0_9BindStateIMN7content14NetworkContext11DiskCheckerEFvvEJNS0_17UnretainedWrapperIS5_EEEEEFvvEE3RunEPNS0_13BindStateBaseE
#24 0x7f1d010e550d _ZNKR4base17RepeatingCallbackIFvvEE3RunEv
#25 0x7f1d02ea2edd content::StartupTaskRunner::RunAllTasksNow()
#26 0x7f1d02238a67 content::BrowserMainLoop::CreateStartupTasks()
#27 0x7f1d0224760d content::BrowserMainRunnerImpl::Initialize()
#28 0x7f1d02231644 content::BrowserMain()
#29 0x7f1d03dff9b8 content::RunNamedProcessTypeMain()
#30 0x7f1d03e025aa content::ContentMainRunnerImpl::Run()
#31 0x7f1d03df8a6d content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
#32 0x7f1d0873a89d service_manager::Main()
#33 0x7f1d03dfe7ff content::ContentMain()
#34 0x55aaeacaa23e ChromeMain
#35 0x55aaeacaa152 main
#36 0x7f1cef119f45 __libc_start_main

chromium : extensions::Extension construction back trace in Render process

extensions/renderer/dispatcher.cc
extensions::Dispatcher receive ExtensionMsg_Loaded from
extensions/browser/renderer_startup_helper.cc
RendererStartupHelper::InitializeProcess

  // Loaded extensions.
  std::vector<ExtensionMsg_Loaded_Params> loaded_extensions;
  BrowserContext* renderer_context = process->GetBrowserContext();
  const ExtensionSet& extensions =
      ExtensionRegistry::Get(browser_context_)->enabled_extensions();
  for (const auto& ext : extensions) {
    // OnLoadedExtension should have already been called for the extension.
    DCHECK(base::ContainsKey(extension_process_map_, ext->id()));
    DCHECK(!base::ContainsKey(extension_process_map_[ext->id()], process));

    if (!IsExtensionVisibleToContext(*ext, renderer_context))
      continue;

    // TODO(kalman): Only include tab specific permissions for extension
    // processes, no other process needs it, so it's mildly wasteful.
    // I am not sure this is possible to know this here, at such a low
    // level of the stack. Perhaps site isolation can help.
    bool include_tab_permissions = true;
    loaded_extensions.push_back(
        ExtensionMsg_Loaded_Params(ext.get(), include_tab_permissions));
    extension_process_map_[ext->id()].insert(process);
  }

  // Activate pending extensions.
  process->Send(new ExtensionMsg_Loaded(loaded_extensions));

#2 0x55717e31dfa6 extensions::Extension::Create()
#3 0x55717e369acb ExtensionMsg_Loaded_Params::ConvertToExtension()
#4 0x55717c503dc5 extensions::Dispatcher::OnLoaded()
#5 0x55717b464a9d _ZN4base20DispatchToMethodImplIPN10extensions22ExtensionMessageFilterEMS2_FvRKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEENS4_5tupleIJSA_EEEJLm0EEEEvRKT_T0_OT1_NS4_16integer_sequenceImJXspT2_EEEE
#6 0x55717b4649f8 _ZN4base16DispatchToMethodIPN10extensions22ExtensionMessageFilterEMS2_FvRKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEENS4_5tupleIJSA_EEEEEvRKT_T0_OT1_
#7 0x55717b464987 _ZN3IPC16DispatchToMethodIN10extensions22ExtensionMessageFilterEMS2_FvRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEEvNS3_5tupleIJS9_EEEEEvPT_T0_PT1_OT2_
#8 0x55717c509c75 _ZN3IPC8MessageTI24ExtensionMsg_Loaded_MetaNSt3__15tupleIJNS2_6vectorI26ExtensionMsg_Loaded_ParamsNS2_9allocatorIS5_EEEEEEEvE8DispatchIN10extensions10DispatcherESD_vMSD_FvRKS8_EEEbPKNS_7MessageEPT_PT0_PT1_T2_
#9 0x55717c502bc9 extensions::Dispatcher::OnControlMessageReceived()
#10 0x7f342b8fda03 content::RenderThreadImpl::OnControlMessageReceived()
#11 0x7f34292185a3 content::ChildThreadImpl::OnMessageReceived()
#12 0x7f342b8fc2d8 content::RenderThreadImpl::OnMessageReceived()
#13 0x7f342e3c8bc8 IPC::ChannelProxy::Context::OnDispatchMessage()
#14 0x7f342e3cf03f _ZN4base8internal13FunctorTraitsIMN3IPC12ChannelProxy7ContextEFvRKNS2_7MessageEEvE6InvokeIRK13scoped_refptrIS4_EJS7_EEEvS9_OT_DpOT0_
#15 0x7f342e3cef9f _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIRKMN3IPC12ChannelProxy7ContextEFvRKNS4_7MessageEEJRK13scoped_refptrIS6_ES9_EEEvOT_DpOT0_
#16 0x7f342e3cef2d _ZN4base8internal7InvokerINS0_9BindStateIMN3IPC12ChannelProxy7ContextEFvRKNS3_7MessageEEJ13scoped_refptrIS5_ES6_EEEFvvEE7RunImplIRKSA_RKNSt3__15tupleIJSC_S6_EEEJLm0ELm1EEEEvOT_OT0_NSJ_16integer_sequenceImJXspT1_EEEE
#17 0x7f342e3cee3c _ZN4base8internal7InvokerINS0_9BindStateIMN3IPC12ChannelProxy7ContextEFvRKNS3_7MessageEEJ13scoped_refptrIS5_ES6_EEEFvvEE3RunEPNS0_13BindStateBaseE
#18 0x7f342feb4061 _ZNO4base12OnceCallbackIFvvEE3RunEv
#19 0x7f342ff0e1ca base::debug::TaskAnnotator::RunTask()
#20 0x7f341d17b429 blink::scheduler::TaskQueueManager::ProcessTaskFromWorkQueue()
#21 0x7f341d175ef9 blink::scheduler::TaskQueueManager::DoWork()
#22 0x7f341d184287 _ZN4base8internal13FunctorTraitsIMN5blink9scheduler16TaskQueueManagerEFvbEvE6InvokeIRKNS_7WeakPtrIS4_EEJRKbEEEvS6_OT_DpOT0_
#23 0x7f341d1841e5 _ZN4base8internal12InvokeHelperILb1EvE8MakeItSoIRKMN5blink9scheduler16TaskQueueManagerEFvbERKNS_7WeakPtrIS6_EEJRKbEEEvOT_OT0_DpOT1_
#24 0x7f341d18415d _ZN4base8internal7InvokerINS0_9BindStateIMN5blink9scheduler16TaskQueueManagerEFvbEJNS_7WeakPtrIS5_EEbEEEFvvEE7RunImplIRKS7_RKNSt3__15tupleIJS9_bEEEJLm0ELm1EEEEvOT_OT0_NSG_16integer_sequenceImJXspT1_EEEE
#25 0x7f341d18406c _ZN4base8internal7InvokerINS0_9BindStateIMN5blink9scheduler16TaskQueueManagerEFvbEJNS_7WeakPtrIS5_EEbEEEFvvEE3RunEPNS0_13BindStateBaseE
#26 0x7f342feb4061 _ZNO4base12OnceCallbackIFvvEE3RunEv
#27 0x7f342ff0e1ca base::debug::TaskAnnotator::RunTask()
#28 0x7f342ffaf105 base::internal::IncomingTaskQueue::RunTask()
#29 0x7f342ffb805a base::MessageLoop::RunTask()
#30 0x7f342ffb8306 base::MessageLoop::DeferOrRunPendingTask()
#31 0x7f342ffb8650 base::MessageLoop::DoWork()
#32 0x7f342ffbb19a base::MessagePumpDefault::Run()
#33 0x7f342ffb77dc base::MessageLoop::Run()
#34 0x7f343006479b base::RunLoop::Run()
#35 0x7f342b962e2b content::RendererMain()
#36 0x7f342bde9e84 content::RunZygote()
#37 0x7f342bdeab61 content::RunNamedProcessTypeMain()
#38 0x7f342bded5aa content::ContentMainRunnerImpl::Run()
#39 0x7f342bde3a6d content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
#40 0x7f343072589d service_manager::Main()
#41 0x7f342bde97ff content::ContentMain()
#42 0x55717afed23e ChromeMain
#43 0x55717afed152 main
#44 0x7f3417104f45 __libc_start_main
#45 0x55717afed02a _start

nginx : set up http/https conf for your server(Ghost)

Let me use cluster.errong.win as a example.
All you need to do is replace the server name and port.
All reqest to cluster.errong.win will be proxyed by http://127.0.0.1:6666

http conf

server {
    listen 80;
    listen [::]:80;

    server_name cluster.errong.win;
    root /home/errong_leng/www/cluster/system/nginx-root;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:6666;
        
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

enable http server to nginx

ln -sf /home/errong_leng/www/cluster/system/files/cluster.errong.win.conf /etc/nginx/sites-available/cluster.errong.win.conf
ln -sf /etc/nginx/sites-available/cluster.errong.win.conf
/etc/nginx/sites-enabled/cluster.errong.win.conf

Use Let's Encrypt

Let's Encrypt is a free, automated, and open Certificate Authority.
/etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --domain cluster.errong.win --webroot /home/errong_leng/www/cluster/system/nginx-root --reloadcmd "nginx -s reload" --accountemail errong.leng@gmail.com

https conf

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name cluster.errong.win;
    root /home/errong_leng/www/cluster/system/nginx-root;

    ssl_certificate /etc/letsencrypt/cluster.errong.win/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/cluster.errong.win/cluster.errong.win.key;
    include /etc/nginx/snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:6666;
        
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

enable https server to nginx

ln -sf /home/errong_leng/www/cluster/system/files/cluster.errong.win-ssl.conf /etc/nginx/sites-available/cluster.errong.win-ssl.conf
ln -sf /etc/nginx/sites-available/cluster.errong.win-ssl.conf
/etc/nginx/sites-enabled/cluster.errong.win-ssl.conf

restart nginx service

service nginx restart

android studio : CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running

Error

CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher
notmatch

Solution I

Your sdk location not match, select the real sdk location
Someone says it works, but not for me.
solution

Solution II

REASON

This happens because for now they only ship 64bit JRE with Android Studio for Windows which produces glitches in 32 bit systems.

SOLUTION

do not use the embedded JDK: Go to File -> Project Structure dialog, uncheck "Use embedded JDK" and select the 32-bit JRE you've installed separately in your system
decrease the memory footprint for Gradle in gradle.properties(Project Properties), for eg set it to -Xmx768m.
For more details: https://code.google.com/p/android/issues/detail?id=219524

Recommend : Recorder Tools for Windows

SRecorder

Screentogif

No Image, No Truth

screentogit recorder how SRecorder working
srecorder-stg

react-native : navigate/load url via WebView

No Image, No Truth

webview-load

use WebView component in reactnative.

var {   ....,   WebView, } = React; 

initial state give a default url

getInitialState: function() {  return {   url: '', // or default url  }; }, 

render with state url

<WebView ....your styles, properties   url={this.state.url} /> 

Navigate/load codes

load() {  this.setState({url:'http://google.com'}); } 

Full Sample Codes

import React, { Component } from 'react';
import {
Button,
Modal,
Image,
Keyboard,
NativeModules,
Platform,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
View,
WebView,
} from 'react-native';

const { WeChat } = NativeModules;

const SHARE_TO_WXTIMELINE = 0;
const SHARE_TO_WXSESSION = 1;
const webview = "webview";
const HOME_URL = "https://errong.win";

export default class App extends Component<{}> {

componentWillMount () {
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {this.keyboardDidHide()});
}

componentWillUnmount () {
this.keyboardDidHideListener.remove();
}

keyboardDidHide () {
console.log( this.urlText );
if (this.urlText != null) {
this.setState({url:this.urlText});
}
}

constructor(props) {
super(props);
this.state = {shareModalVisible : false, url : HOME_URL, urlBarVisible : true};
}

setShareModalVisible(visible) {
this.setState({shareModalVisible : visible});
}

onShare(scene) {
this.setShareModalVisible(false);
this.scene = scene;
if (this.shareMsg == null)
return;
if (WeChat.shareToTimeline)
WeChat.shareToTimeline(this.shareMsg, this.scene, null);
}

onWebViewMessage(event) {
console.warn(event.nativeEvent.data);
let msg;
try {
msg = JSON.parse(event.nativeEvent.data);
} catch (err) {
console.warn(err);
return;
}
if (msg.id == "ABSTRACT_FETCHED")
this.shareMsg = msg;
}

genAbstractJS() {
const genAbstractFunction = function() {
try {
let title;
let description;
let imageUrl;
let msg;
let n = document.querySelector('head title');
if (n)
title = n.innerText;
n = document.querySelector('p');
if (n)
description = n.innerText;
n = document.querySelector('p img');
if (n)
imageUrl = n.src;
if (description && imageUrl) {
msg = { 'id' : 'ABSTRACT_FETCHED',
'type' : 'textimage',
'description' : description,
'imageUrl': imageUrl
};
} else {
msg = { 'id' : 'ABSTRACT_FETCHED',
'type' : 'news',
'webpageUrl' : window.location.href
};
}
window.postMessage(JSON.stringify(msg), "*");
} catch (err) {
console.warn(err);
}
}
let js = "(" + String(genAbstractFunction) + ")();";
console.log(js);
return js;
}

onLoadEnd() {
this.refs[webview].injectJavaScript(this.genAbstractJS());
}

onUrlBar() {
}

renderUrlBar() {
if (this.state.urlBarVisible) {
return (
<TouchableOpacity style={styles.urlbar} onPress={() => {this.onUrlBar()}}>
<TextInput
style={styles.urlentry}
placeholder="search or input url"
onChangeText={(text) => {this.urlText = text}}
/>

)
} else {
return null;
}
}

render() {
return (

{this.renderUrlBar()}
<WebView
ref={webview}
style={{flex:1}}
javaScriptEnabled={true}
onMessage={(event) => {this.onWebViewMessage(event)}}
onLoadEnd={this.onLoadEnd.bind(this)}
source={{uri:this.state.url}}
/>
<Button
onPress={() => {this.setShareModalVisible(true)}}
title="Share"
color="#841584"
accessibilityLabel="Social Share"
/>



<TouchableOpacity style={styles.sharebutton} onPress={() => {this.onShare(SHARE_TO_WXTIMELINE)}}>
<Image
source={require('./res/img/wxtimeline.png')}
/>

<TouchableOpacity style={styles.sharebutton} onPress={() => {this.onShare(SHARE_TO_WXSESSION)}}>
<Image
source={require("./res/img/wxsession.png")}
/>





);
}
}

const styles = StyleSheet.create({
urlbar:{
backgroundColor:'#fafad2',
borderTopLeftRadius:4,
borderTopRightRadius:4,
borderBottomLeftRadius:4,
borderBottomRightRadius:4,
boderColor : '#C0C0C0',
borderWidth: 1
},
urlentry:{
height: 40
},
sgc:{
height:100,
width:300,
borderTopLeftRadius:10,
borderTopRightRadius:10,
borderBottomLeftRadius:10,
borderBottomRightRadius:10,
alignSelf: 'center',
top:400,
backgroundColor:'#fafad2'
},
sharegroup: {
flex:1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-around',
},
sharebutton: {
width:64,
height:64
}
})

react-native : Modal example, share to WeChat

Refer

https://facebook.github.io/react-native/docs/modal.html

No Image, No Truth

modal-share

Full Codes

import React, { Component } from 'react'; import {     Button, 	Modal,     Image,     Keyboard,     NativeModules,     Platform,     StyleSheet,     Text,     TextInput,     TouchableOpacity,     View,     WebView, } from 'react-native';  const { WeChat } = NativeModules;  const SHARE_TO_WXTIMELINE = 0; const SHARE_TO_WXSESSION = 1; const webview = "webview"; const HOME_URL = "https://errong.win";  export default class App extends Component<{}> {    componentWillMount () {     this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {this.keyboardDidHide()});   }    componentWillUnmount () {     this.keyboardDidHideListener.remove();   }    keyboardDidHide () {     console.log( this.urlText );     if (this.urlText != null) {       this.setState({url:this.urlText});     }   }    constructor(props) {     super(props);     this.state = {shareModalVisible : false, url : HOME_URL, urlBarVisible : true};   }    setShareModalVisible(visible) {     this.setState({shareModalVisible : visible});   }    onShare(scene) {     this.setShareModalVisible(false); 	this.scene = scene;     if (this.shareMsg == null)       return;     if (WeChat.shareToTimeline)       WeChat.shareToTimeline(this.shareMsg, this.scene, null);   }    onWebViewMessage(event) {     console.warn(event.nativeEvent.data);     let msg;     try {       msg = JSON.parse(event.nativeEvent.data);     } catch (err) {       console.warn(err);       return;     }     if (msg.id == "ABSTRACT_FETCHED")       this.shareMsg = msg;   }    genAbstractJS() {     const genAbstractFunction = function() {       try {         let title;         let description;         let imageUrl;         let msg;         let n = document.querySelector('head title');         if (n)             title = n.innerText;         n = document.querySelector('p');         if (n)             description = n.innerText;         n = document.querySelector('p img');         if (n)             imageUrl = n.src;         if (description && imageUrl) {             msg = { 'id' : 'ABSTRACT_FETCHED',                     'type' : 'textimage',                     'description' : description,                     'imageUrl': imageUrl                   };         } else {            msg = { 'id' : 'ABSTRACT_FETCHED',                    'type' : 'news',                    'webpageUrl' : window.location.href                  };         }         window.postMessage(JSON.stringify(msg), "*");       } catch (err) {         console.warn(err);       }     }     let js = "(" + String(genAbstractFunction) + ")();";     console.log(js);     return js;   }    onLoadEnd() {     this.refs[webview].injectJavaScript(this.genAbstractJS());   }    onUrlBar() {   }    renderUrlBar() {     if (this.state.urlBarVisible) {       return (         <TouchableOpacity style={styles.urlbar} onPress={() => {this.onUrlBar()}}>           <TextInput             style={styles.urlentry}             placeholder="search or input url"             onChangeText={(text) => {this.urlText = text}}           />         </TouchableOpacity>       )     } else {       return null;     }   }    render() {     return (     <View style={{flex:1}}>       {this.renderUrlBar()}       <WebView         ref={webview}         style={{flex:1}}         javaScriptEnabled={true}         onMessage={(event) => {this.onWebViewMessage(event)}}         onLoadEnd={this.onLoadEnd.bind(this)}         source={{uri:this.state.url}}       />       <Button         onPress={() => {this.setShareModalVisible(true)}}         title="Share"         color="#841584"         accessibilityLabel="Social Share"       /> 	  <Modal 		transparent={true} 		visible={this.state.shareModalVisible} 		> 		<View style={styles.sgc}>           <View style={styles.sharegroup}>             <TouchableOpacity style={styles.sharebutton} onPress={() => {this.onShare(SHARE_TO_WXTIMELINE)}}>               <Image                 source={require('./res/img/wxtimeline.png')}               />             </TouchableOpacity>             <TouchableOpacity style={styles.sharebutton} onPress={() => {this.onShare(SHARE_TO_WXSESSION)}}>               <Image                 source={require("./res/img/wxsession.png")}               />             </TouchableOpacity>           </View> 		</View> 	  </Modal>     </View>     );   } }  const styles = StyleSheet.create({   urlbar:{   	backgroundColor:'#fafad2',     borderTopLeftRadius:4,     borderTopRightRadius:4,     borderBottomLeftRadius:4,     borderBottomRightRadius:4,     boderColor : '#C0C0C0',     borderWidth: 1   },   urlentry:{     height: 40   },   sgc:{   	height:100,     width:300,     borderTopLeftRadius:10,     borderTopRightRadius:10,     borderBottomLeftRadius:10,     borderBottomRightRadius:10,     alignSelf: 'center',   	top:400,   	backgroundColor:'#fafad2'   },   sharegroup: {   	flex:1, 	flexDirection: 'row',   	alignItems: 'center',   	justifyContent: 'space-around',   },   sharebutton: {     width:64,     height:64   } }) 

react-native : How to create Image Button

Solution

Use TouchableOpacity, Image and Styles.

Key codes

import React, { Component } from 'react'; import {         Image,     StyleSheet,        TouchableOpacity, } from 'react-native';  <TouchableOpacity     style={styles.sharebutton}     onPress={() => {this.onShare(SHARE_TO_WXTIMELINE)}} >     <Image         source={require('./res/img/wxtimeline.png')}     /> </TouchableOpacity>          

No Image, No Truth

modal-share
See Full sample codes Share to WeXin via Modal

react-natvie run-android --variant=release uncompiled PNG file passed as argument. Must be compiled first into .flat file..

C:\Users\lenger\Desktop\webrowser\android\app\build\intermediates\res\merged\release\drawable-mdpi\res_icon64_appwx_logo
.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file..
error: failed parsing overlays.

Task :app:processReleaseResources
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt

workaround

android\gradle.properties
android.enableAapt2=false

refer

https://github.com/react-navigation/react-navigation/issues/3097

wechat share for react native app on android platform

Register App on weixin open platform

Register your on https://open.weixin.qq.com

While registering your app, you will need app sign signature,
you can refer sign your app for weixin.

You will get your APPID after your app registered.
please keep it.
appsign

prepare wechat sdk for you app

add wechat sdk in android/app/build.gradle

dependencies {     compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+' } 

set up AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

build native wechat to react native JS

I export wechat as "NativeModules.WeChat" follow below examples
https://facebook.github.io/react-native/docs/native-modules-android.html

The main java codes:

  1. WeChatModule, extends ReactContextBaseJavaModule, implements IWXAPIEventHandler
  2. WeChatPackage, new WeChatModule as NativeModules
  3. MainApplication::getPackages(), new WeChatPackage

Important:
To expose a method to JavaScript a Java method must be annotated using @ReactMethod. The return type of bridge methods is always void. React Native bridge is asynchronous, so the only way to pass a result to JavaScript is by using callbacks or emitting events (see below).

public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEventHandler {     // ReactContextBaseJavaModule implementation     @Override     public String getName() {         return "RCTWeChat";     }          // IWXAPIEventHandler implementation     @Override     public void onReq(BaseReq baseReq) {     }      @Override     public void onResp(BaseResp baseResp) {     }               @ReactMethod     public void shareToTimeline(ReadableMap data, Callback callback) {     } } public class WeChatPackage implements ReactPackage {    @Override   public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {     return Collections.emptyList();   }    @Override   public List<NativeModule> createNativeModules(                               ReactApplicationContext reactContext) {     List<NativeModule> modules = new ArrayList<>();      modules.add(new WeChatModule(reactContext));      return modules;   }  } public class MainApplication extends Application implements ReactApplication {    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {     @Override     public boolean getUseDeveloperSupport() {       return BuildConfig.DEBUG;     }      @Override     protected List<ReactPackage> getPackages() {       return Arrays.<ReactPackage>asList(           new MainReactPackage(),           new WeChatPackage()       );     } 

Use in react native JS

import { NativeModules, } from 'react-native'; const { WeChat } = NativeModules; 

Pease avoid RCT prefix issue.

You can get all codes by downloading my example app wechat-share-example.
It is a zip file, after you download it, Remember:

1. replace app id in .\android\app\src\main\java\com\wx\react\WeChatModule.java 2. replace package name to your package name. 3. run npm install before react-native run-android 

The package name in the example is "com.errong.webrowser".
./android/app/BUCK:48: package = "com.errong.webrowser",
./android/app/BUCK:53: package = "com.errong.webrowser",
./android/app/build.gradle:100: applicationId "com.errong.webrowser"
./android/app/src/main/AndroidManifest.xml:2: package="com.errong.webrowser"
./android/app/src/main/java/com/webrowser/MainActivity.java:1:package com.errong.webrowser;
./android/app/src/main/java/com/webrowser/MainApplication.java:1:package com.errong.webrowser;

app id and package name should exactly same to the one you applied at
open.weixin.com which was mentioned at the beginning of this post.
otherwist, share feature maynot work well.

register app id to wechat

let's refer to offical guide

.\android\app\src\main\java\com\wx\react\WeChatModule.java

public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEventHandler {     private IWXAPI api = null;      public WeChatModule(ReactApplicationContext context) {         super(context);         String appId = "YOURAPPID";         api = WXAPIFactory.createWXAPI(this.getReactApplicationContext().getBaseContext(), appId, true);         if (api != null)             api.registerApp(appId);     } 

Share to wechat time line

let's refer to offical guide

.\android\app\src\main\java\com\wx\react\WeChatModule.java

   @ReactMethod    public void shareToTimeline(ReadableMap data, Callback callback) {        if (api == null) {            Toast.makeText(getReactApplicationContext(), "App not registered to WeChat", Toast.LENGTH_SHORT).show();            return;        }        WXMediaMessage.IMediaObject mediaObject = _jsonToTextMedia(data);        WXMediaMessage message = new WXMediaMessage();        message.mediaObject = mediaObject;        if (data.hasKey("title"))            message.title = data.getString("title");        if (data.hasKey("description"))            message.description = data.getString("description");        SendMessageToWX.Req req = new SendMessageToWX.Req();        req.message = message;        req.scene = SendMessageToWX.Req.WXSceneTimeline;        req.transaction = UUID.randomUUID().toString();        api.sendReq(req);    } 

App.js

import { NativeModules, } from 'react-native'; const { WeChat } = NativeModules; var msg = {'id' : 'ABSTRACT_FETCHED', 'url' : window.location.href, 'title' : title, 'description' : desc, 'imgurl' : imgurl}; WeChat.shareToTimeline(msg, null); 

Key points

  1. APPID and package name should same to the one you applied at open.weixin.qq.com
    sign your app for weixin
  2. sign your apk with your keystore file before you release.
    Generate Signed android APK for react-native app
  3. all sample codes download here

react-native : Native Modules, name prefix "RCT"works for android too

I tried to export wechat sdk as a native module.
I copied some codes here:
public class WeChatModule extends ReactContextBaseJavaModule implements IWXAPIEventHandler {
  private String appId; 
  public WeChatModule(ReactApplicationContext context) { 
    super(context); 
  @Override     public String getName() { 
    return "RCTWeChat"; 
} 
I used "RCTWeChat" as the module name, I did not know the "RCT" prefix meanings.

ReactContextBaseJavaModule requires that a method called getName is implemented. The purpose of this method is to return the string name of the NativeModule which represents this class in JavaScript.

Then I encountered error in my react-native JS codes.
import {NativeModules} from 'react-native'; const { RCTWeChat } = NativeModules; 
WeChat or NativeModules.RCTWeChat always undefined.

Cause

RCT is a prefix used in react native, it will be removed when exported to JS.
React Native uses RCT as a prefix. In order to avoid name collisions, we recommend using a three-letter prefix other than RCT in your own classes.

Solution

The correct JS codes:
const { WeChat } = NativeModules;

react-native run-android : No connected devices!

  • What went wrong:
    Execution failed for task ':app:installDebug'.

com.android.builder.testing.api.DeviceException: No connected devices!

Cause

ADB driver is not ready

Solution

Install correct driver
adb

Search the heart and Examine the mind

我—耶和华是鉴察人心、试验人肺腑的,要照各人所行的和他作事的结果报应他。 (耶利米书 17:10 和合本)
"I the Lord search the heart and examine the mind, to reward each person according to their conduct, according to what their deeds deserve." (Jeremiah 17:10 NIV)


Photo by Max Bender / Unsplash

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

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 sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.
java:1385)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413
)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397
)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:
559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect
(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLCo
nnection.java:1564)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Http
sURLConnectionImpl.java:263)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:59)
at org.gradle.wrapper.Install$1.call(Install.java:46)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:46)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find vali
d certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:397)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.jav
a:302)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.j
ava:324)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerIm
pl.java:229)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustMan
agerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.
java:1496)
... 20 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBu
ilder.java:141)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCert
PathBuilder.java:126)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392)
... 26 more
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

Cause

java client try to downloading https resources without valid certification.

Solution

  1. Downloading <a href="http://pwpan.com/fs/4leeng7er4ro9ng0e57/" target="_blank">InstallCert.java</a>
  2. Compile
    javac InstallCert.java
  3. Run InstallCert and get certs from the host.
    my failed resource is
    https://services.gradle.org/distributions/gradle-4.1-all.zip
    the host is services.gradle.org
    java InstallCert services.gradle.org
    If everything works well, you will get a file named jssecacerts.
c:\Users\Administrator\Desktop>java InstallCert services.gradle.org
Loading KeyStore C:\Program Files\Java\jdk1.8.0_152\jre\lib\security\cacerts...
Opening connection to services.gradle.org:443...
Starting SSL handshake...
......
Server sent 3 certificate(s):
1 Subject CN=ssl473435.cloudflaressl.com, OU=PositiveSSL Multi-Domain, OU=Domain Control Validated
Issuer CN=COMODO ECC Domain Validation Secure Server CA 2, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB
sha1 d4 e8 9d a9 2c 27 22 1f 63 a9 33 d8 ca 98 01 3d 02 6c 59 ea
md5 ba 64 ca 8d 7f ab d8 8e f2 e0 d3 79 79 51 96 30
2 Subject CN=COMODO ECC Domain Validation Secure Server CA 2, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB
Issuer CN=COMODO ECC Certification Authority, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB
sha1 75 cf d9 bc 5c ef a1 04 ec c1 08 2d 77 e6 33 92 cc ba 52 91
md5 5e 0e 41 9b 20 ea 57 54 77 f1 1b 52 e2 c8 18 e0
3 Subject CN=COMODO ECC Certification Authority, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB
Issuer CN=AddTrust External CA Root, OU=AddTrust External TTP Network, O=AddTrust AB, C=SE
sha1 ae 22 3c bf 20 19 1b 40 d7 ff b4 ea 57 01 b6 5f dc 68 a1 ca
md5 c7 90 a5 6c 69 cb af 0b f3 f3 0a 40 d0 a2 ae cc
Enter certificate to add to trusted keystore or 'q' to quit: [1]
1 // enter 1 here
......
Added certificate to keystore 'jssecacerts' using alias 'services.gradle.org-1'
  1. copy jssecacerts to jre security folder
    cp jssecacerts $JAVA_HOME/jre/lib/security/jssecacerts

Issue fiexed

gradle-4.1-all.zip is downloading
downloadinggradle

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

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 

Capture

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

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<{}> {
  constructor(props) {
    super(props);
    this.onWebViewMessage = this.onWebViewMessage.bind(this);
    this.onShare = this.onShare.bind(this);
  }

  onWebViewMessage(event) {
    console.warn(event.nativeEvent.data);
    let msg;
    try {
      msg = JSON.parse(event.nativeEvent.data);
    } catch (err) {
      console.warn(err);
      return;
    }
    console.log(msg);
  }

  onShare() {
    var fetchAbstractJS = "(" + this.fetchAbstract.toString() + "());";
    console.log(fetchAbstractJS);
    this.refs[WEBVIEW_REF].injectJavaScript(fetchAbstractJS);
  }

  // function called in WebView via injectJavaScript
  fetchAbstract() {
    try {
      var title = document.querySelector('head title').innerText;
      var desc = document.querySelector('p').innerText;
      var imgurl = document.querySelector('p img').src;
      // post Message to react-native JS
      window.postMessage(JSON.stringify({'id' : 'ABSTRACT_FETCHED', 'url' : window.location.href, 'title' : title, 'desc' : desc, 'imgurl' : imgurl}), "*");
    } catch (err) {
      console.warn(err);
      return;
    }
  }

  render() {
    return (
    <View style={{flex:1}}>
      <WebView
        ref={WEBVIEW_REF}
        style={{flex:1}}
        onMessage={this.onWebViewMessage}
        source={{uri: 'https://manna.errong.win/let-s-growing-up-in-jesus/'}}
      />
      <Button
        onPress={this.onShare}
        title="Share"
        color="#841584"
        accessibilityLabel="Social Share"
      />
    </View>
    );
  }
}

react-native log-android

log-android

Refer

https://facebook.github.io/react-native/docs/webview.html#onmessage
https://facebook.github.io/react-native/docs/webview.html#injectjavascript
https://facebook.github.io/react-native/docs/webview.html#injectedjavascript

Let's Growing up in Jesus

看你们学习的工夫,本该作师傅,谁知还得有人将 神圣言小学的开端另教导你们,并且成了那必须吃奶、不能吃干粮的人。 (希伯来书 5:12 和合本)
In fact, though by this time you ought to be teachers, you need someone to teach you the elementary truths of God's word all over again. You need milk, not solid food! (Hebrews 5:12 NIV)
凡只能吃奶的都不熟练仁义的道理,因为他是婴孩; (希伯来书 5:13 和合本)
Anyone who lives on milk, being still an infant, is not acquainted with the teaching about righteousness. (Hebrews 5:13 NIV)
惟独长大成人的才能吃干粮;他们的心窍习练得通达,就能分辨好歹了。 (希伯来书 5:14 和合本)
But solid food is for the mature, who by constant use have trained themselves to distinguish good from evil. (Hebrews 5:14 NIV)


Photo by Milos Prelevic / Unsplash

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

Generate Signed android APK for react-native app

Refer:
https://facebook.github.io/react-native/docs/signed-apk-android.html

create your own key store file

https://errong.win/generate-keystore/

modifications

signed-apk

error INSTALL_FAILED_UPDATE_INCOMPATIBLE

https://errong.win/react-native-run-android-variant-release/

java.lang.NullPointerException (no error message)

When I set below values to true, I encountered NullPointerException.
so my reset them to false again.

+ def enableSeparateBuildPerCPUArchitecture = true + universalApk true  // If true, also generate a universal APK + def enableProguardInReleaseBuilds = true 

error can't delete/read lint-results-release-fatal.html

kill all java.exe via task manager

set up proxy for android emulator

c:\Users\lenger\AppData\Local\Android\Sdk\tools>emulator.exe -http-proxy ip:port -avd Nexus_5X_API_23

c:\Users\lenger\AppData\Local\Android\Sdk\tools>bin\avdmanager.bat list avd

    Name: Nexus_5X_API_23   Device: Nexus 5X (Google)     Path: C:\Users\lenger\.android\avd\Nexus_5X_API_23.avd   Target: Google APIs (Google Inc.)           Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86_64     Skin: nexus_5x   Sdcard: 100M ---------     Name: Nexus_5X_API_23_2   Device: Nexus 5X (Google)     Path: C:\Users\lenger\.android\avd\Nexus_5X_API_23_2.avd   Target: Google APIs (Google Inc.)           Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/armeabi-v7a     Skin: nexus_5x   Sdcard: 100M ---------     Name: Nexus_5X_API_27_x86   Device: Nexus 5X (Google)     Path: C:\Users\lenger\.android\avd\Nexus_5X_API_27_x86.avd   Target: Google APIs (Google Inc.)           Based on: Android API 27 Tag/ABI: google_apis/x86     Skin: nexus_5x   Sdcard: 800M Snapshot: no 

react-native run-android --variant=release INSTALL_FAILED_UPDATE_INCOMPATIBLE

Task :app:installRelease
Installing APK 'app-release.apk' on 'Nexus_5X_API_23(AVD) - 6.0' for app:release
Unable to install C:\Users\lenger\Desktop\webrowser\android\app\build\outputs\apk\release\app-release.apk
com.android.ddmlib.InstallException: INSTALL_FAILED_UPDATE_INCOMPATIBLE
at com.android.ddmlib.Device.installRemotePackage(Device.java:1004)
at com.android.ddmlib.Device.installPackage(Device.java:911)
at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:122)
at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:171)
at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:105)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:731)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:705)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:installRelease'.

com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_UPDATE_INCOMPATIBLE

Cause

the application which you want to install is already installed.

Solution

uninstall the old one and try again.
adb uninstall xxx

fixed: embedded-redis: Unable to run on macOS Sonoma

Issue you might see below error while trying to run embedded-redis for your testing on your macOS after you upgrade to Sonoma. java.la...