小编Vin*_*k B的帖子

错误:无法解析模块 `buffer` React Native

在 Android 上构建项目时出现错误

错误:捆绑失败:错误:无法bufferE:\SUNNYCLOCK-MOBILE\node_modules\safe-buffer\index.js以下位置解析模块:模块 buffer在 Haste 模块映射中不存在

这可能与 https://github.com/facebook/react-native/issues/4968要解决尝试以下操作: 1. 清除守望者手表:watchman watch-del-all。2. 删除node_modules文件夹:rm -rf node_modules && npm install。3. 重置 Metro Bundler 缓存:rm -rf /tmp/metro-bundler-cache-*npm start -- --reset-cache。4. 移除急速缓存:rm -rf /tmp/haste-map-react-native-packager-*. 在 ModuleResolver.resolveDependency (E:\SUNNYCLOCK-MOBILE\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:161:1460) 在 ResolutionRequest.resolveDependency (E:\SUNNYCLOCK-MOBILE\node_modules\metro\ node-haste\DependencyGraph\ResolutionRequest.js:91:16) at DependencyGraph.resolveDependency (E:\SUNNYCLOCK-MOBILE\node_modules\metro\src\node-haste\DependencyGraph.js:272:4579) at dependencies.map.relativePath (E:\SUNNYCLOCK-MOBILE\node_modules\metro\src\DeltaBundler\traverseDependencies.js:376:19) 在 Array.map () 在 resolveDependencies (E:\SUNNYCLOCK-MOBILE\node_modules\metro\src\DeltaBundler\traverseDependencies。 js:374:16) 在 E:\SUNNYCLOCK-MOBILE\node_modules\metro\src\DeltaBundler\traverseDependencies.js:212:33 在 Generator.next () 在步骤 (E: \SUNNYCLOCK-MOBILE\node_modules\metro\src\DeltaBundler\traverseDependencies.js:297:313) 在 E:\SUNNYCLOCK-MOBILE\node_modules\metro\src\DeltaBundler\traverseDependencies.js:297:473 BUNDLE [android, …

reactjs react-native

16
推荐指数
1
解决办法
9764
查看次数

无法解决:com.facebook.android:facebook-android-sdk:[4,5)

我在我的项目中使用facebook sdk.Facebook SDK直到昨天仍然有效.但今天当我打开我的项目时,构建失败并显示错误如下

 Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
   > Could not resolve com.facebook.android:facebook-android-sdk:[4,5).
     Required by:
         project :app
      > Could not resolve com.facebook.android:facebook-android-sdk:[4,5).
         > Failed to list versions for com.facebook.android:facebook-android-sdk.
            > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml.
               > Could not GET 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml'.
                  > jcenter.bintray.com
      > Could not resolve com.facebook.android:facebook-android-sdk:[4,5).
         > Failed to list versions for com.facebook.android:facebook-android-sdk.
            > Unable to load Maven meta-data from https://jitpack.io/com/facebook/android/facebook-android-sdk/maven-metadata.xml.
               > Could not GET 'https://jitpack.io/com/facebook/android/facebook-android-sdk/maven-metadata.xml'.
                  > …
Run Code Online (Sandbox Code Playgroud)

android facebook android-gradle-plugin

10
推荐指数
6
解决办法
1万
查看次数

React native overflow visible not working in android even after updated to RN 0.58.4

According to this RN release , now on we can use overflow:'visible' in android . But still React Native Android clipping its Children view. consider the below code

import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, ScrollView,FlatList } from 'react-native';


type Props = {};
export default class App extends Component<Props> {
  objectValues = {
    one: 'one',
    two: 'one',
    three: 'one',
    four: 'one',
    five: 'one',
    six: 'one',
    seven: 'one',
    eight: 'one',
    nine: 'one',
    ten: 'one',
    eleven: …
Run Code Online (Sandbox Code Playgroud)

android react-native react-native-android

7
推荐指数
1
解决办法
1078
查看次数

操作栏(工具栏)和状态栏的通用背景图片

我需要用透明工具栏设计这样的东西

这个

但我得到了这样的东西

这个

设计就像

  • 带有背景图像的透明状态栏和操作栏
  • 操作栏必须在状态栏下方

这是我的代码

应用主题

  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

v21

 <style name="AppTheme.TransparentStatusBar" parent="AppTheme">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>

</style>
Run Code Online (Sandbox Code Playgroud)

XML

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include
    layout="@layout/app_bar_home"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_home"
    app:menu="@menu/activity_home_drawer" />
Run Code Online (Sandbox Code Playgroud)

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"

tools:context="activities.HomeActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/float_transparent"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/float_transparent"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout> …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-toolbar

6
推荐指数
1
解决办法
5524
查看次数

确定片段重启是否是由于屏幕旋转或Viewpager滑动造成的?

我有一个ActivityViewPager.在ViewPager有很多的网页,就像一本书.每个片段都有RecyclerViews很多内容.以下是我的用例

1 - 当我滑动页面时,RecyclerView必须从列表的开头开始.2.如果我旋转设备,它应该从旋转之前离开的位置的确切位置读取.

如果我不使用任何逻辑,第二种情况可以完美运行.即旋转.但不是第一种情况.

如果我做一些如下的逻辑.有助于实现第一种情况,但不是第二种情况.

  @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    if (savedInstanceState==null) {
        mIsFirstTime = true;
    }
}

@Override
public void onResume() {
    super.onResume();
    try {
        getActivity().invalidateOptionsMenu();
            if (!mIsFirstTime) {
                mListView.scrollToPosition(0);                
            }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
Run Code Online (Sandbox Code Playgroud)

所以我的问题是

如何确定片段重启是由于屏幕旋转还是Viewpager滑动?

我已经试过了onConfigurationChanged(Configuration newConfig).但它对我没有帮助.请你帮助我好吗

android rotation android-configchanges android-viewpager android-recyclerview

6
推荐指数
1
解决办法
296
查看次数

进度警报并未从Swift 3中消失

我正在尝试创建一个函数来显示和解除Swift 3中的ProgressDialog.但在此代码中,对话框不会从视图控制器中消失.

func showLoadingDialog(show : Bool)  {
    if show {
        self.alert = UIAlertController(title: nil, message: "Please wait...", preferredStyle: .alert)
        let loadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
        loadingIndicator.hidesWhenStopped = true
        loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.gray
        loadingIndicator.startAnimating()
        self.alert.view.addSubview(loadingIndicator)
        self.present(self.alert, animated: true, completion: nil)
    }else{
        self.dismiss(animated: false, completion: nil)
    }
}
Run Code Online (Sandbox Code Playgroud)

我也尝试了以下方法来关闭此对话框,但它们都没有工作:

self.alert.view.removeFromSuperview()

self.alert.view.alpha = 0
self.presentingViewController?.dismiss(animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

请帮我.如果你们有任何替代解决方案,请提出建议.

ios swift3

5
推荐指数
1
解决办法
1095
查看次数

LinkedIn身份验证无法在Android中使用Fragment

我正在创建一个拥有LinkedIn登录的应用程序.我正在关注文档.但是当我点击登录按钮时,应用程序会重定向到LinkedIn应用程序并要求登录.成功登录后,它会重定向到我的应用程序.但没有任何反应.什么onActivityResult也没发生.以下是我的代码.登录在片段上实现

 LISessionManager.getInstance(getActivity()).init(getActivity(), buildScope(), new AuthListener() {
            @Override
            public void onAuthSuccess() {
                getLinkedInProfile();
                Toast.makeText(getApplicationContext(), "success" , Toast.LENGTH_LONG).show();
            }
            @Override
            public void onAuthError(LIAuthError error) {
                Toast.makeText(getApplicationContext(), "failed " + error.toString(), Toast.LENGTH_LONG).show();
            }
        }, true);
Run Code Online (Sandbox Code Playgroud)

//

private static Scope buildScope() {
    return Scope.build(Scope.R_BASICPROFILE, Scope.R_EMAILADDRESS);
}
Run Code Online (Sandbox Code Playgroud)

和onActivityResult如下:

     @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        LISessionManager.getInstance(getActivity()).onActivityResult(getActivity(), requestCode, resultCode, data);
}
Run Code Online (Sandbox Code Playgroud)

已经在LinkedIn开发者控制台上添加了哈希和包名称.我错过了什么吗?请帮忙

java authentication android linkedin

5
推荐指数
1
解决办法
473
查看次数

如何在 React Native 中备份/恢复 SQLite 数据库

我正在使用andpor/react-native-sqlite-storage在 React Native 中管理 SQLite 数据库。现在我想将我的所有数据库备份到一个加密文件中,然后在以后恢复它。我知道如何在 android 中做到这一点,但不知道如何在 react native 中实现这一点。

如果它在android中,下面的代码可以帮助我在不加密的情况下备份数据库。

 final String inFileName = "/data/data/<your.app.package>/databases/foo.db";
File dbFile = new File(inFileName);
FileInputStream fis = new FileInputStream(dbFile);

String outFileName = Environment.getExternalStorageDirectory()+"/database_copy.db";

// Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);

// Transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer))>0){
    output.write(buffer, 0, length);
}

// Close the streams
output.flush();
output.close();
fis.close();
Run Code Online (Sandbox Code Playgroud)

所以我的问题是如何在 React …

sqlite react-native react-native-android react-native-ios

5
推荐指数
1
解决办法
1695
查看次数

如何使用Espresso测试在选项卡布局中选择特定的选项卡位置

我有一个带有View pager的选项卡布局。我正在使用Espresso 来测试我的Android应用程序。在我以前的项目中,我使用标签标题执行单击以选择标签位置,如下所示。

    Espresso.onView(ViewMatchers.withText("MAP"))
            .perform(ViewActions.click());
Run Code Online (Sandbox Code Playgroud)

现在我有114个标签。因此,我无法使用上述方法随机选择这些选项卡进行测试。有什么办法可以按其位置选择选项卡。我已经检查了其他解决方案,但没有一个对我有帮助。

android automated-tests android-espresso

4
推荐指数
3
解决办法
1477
查看次数

如何在节点中将 Hex 转换为 Unit8Array?

我可以使用下面的代码将 Unit8Array 转换为十六进制

 var bkh = {
    publicKey: new Uint8Array([91, 221, 234, 40, 144, 246, 91, 187, 154, 76,
        60, 178, 204, 81, 35, 195, 254, 114, 246, 88, 90, 170, 68, 97, 199,
        170, 72, 36, 107, 66, 206, 9]
    ),

    secretKey: new Uint8Array([64, 68, 196, 103, 210, 179, 166, 40, 187,
        150, 167, 233, 144, 206, 64, 26, 77, 133, 70, 238, 232, 227, 133,
        83, 149, 202, 213, 41, 152, 243, 237, 41]
    )
}

let hex …
Run Code Online (Sandbox Code Playgroud)

javascript node.js

3
推荐指数
1
解决办法
1988
查看次数

Ionic 2中来自画廊的图像未显示在img标签上

我正在尝试显示图像从画廊到img标签。但是图像未显示在img标签上。但是它正在与PhotoViewer。下面是我的代码。

 options: CameraOptions = {
    quality: 100,
    destinationType: this.camera.DestinationType.FILE_URI,
    encodingType: this.camera.EncodingType.JPEG,
    sourceType: this.camera.PictureSourceType.PHOTOLIBRARY
   //mediaType: this.camera.MediaType.PICTURE
  }
Run Code Online (Sandbox Code Playgroud)

用拍摄的图像

this.camera.getPicture(this.options).then((imageData) => {

  alert(imageData)
  this.photoViewer.show(imageData);
  this.captureDataUrl=imageData;

 }, (err) => {
  // Handle error
 });
Run Code Online (Sandbox Code Playgroud)

在HTML中

<img [src]="captureDataUrl" *ngIf="captureDataUrl"/>
Run Code Online (Sandbox Code Playgroud)

如果我将sourceType用作相机(sourceType: this.camera.PictureSourceType.CAMERA),它也可以工作,它将在img标签上显示图像,但是如果我将sourceType用作,则无法正常工作sourceType: this.camera.PictureSourceType.PHOTOLIBRARY 。请帮忙

android image ionic-framework ionic2 angular

2
推荐指数
1
解决办法
1721
查看次数