【问题标题】:Build Failed with Auth0-lock in React Native Android在 React Native Android 中使用 Auth0-lock 构建失败
【发布时间】:2016-07-09 13:33:43
【问题描述】:

我正在尝试将 Auth0 Lock 与我的 Android React-Native 应用程序一起使用。我遵循了设置说明here,但在构建时出现以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find any matches for com.auth0.android:lock-react-native:+ as no versions of com.auth0.android:lock-react-native are available.
     Searched in the following locations:
         file:/Users/m/.m2/repository/com/auth0/android/lock-react-native/maven-metadata.xml
         file:/Users/m/.m2/repository/com/auth0/android/lock-react-native/
         https://jcenter.bintray.com/com/auth0/android/lock-react-native/maven-metadata.xml
         https://jcenter.bintray.com/com/auth0/android/lock-react-native/
         file:/Users/m/git/this-or-that-app/node_modules/react-native/android/com/auth0/android/lock-react-native/maven-metadata.xml
         file:/Users/m/git/this-or-that-app/node_modules/react-native/android/com/auth0/android/lock-react-native/
         file:/usr/local/opt/android-sdk/extras/android/m2repository/com/auth0/android/lock-react-native/maven-metadata.xml
         file:/usr/local/opt/android-sdk/extras/android/m2repository/com/auth0/android/lock-react-native/
     Required by:
         thisOrThatApp:app:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 16.332 secs
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

我注意到以下几行:

file:/Users/m/git/this-or-that-app/node_modules/react-native/android/com/auth0/android/lock-react-native/maven-metadata.xml
file:/Users/m/git/this-or-that-app/node_modules/react-native/android/com/auth0/android/lock-react-native/

我有一种预感,应该安装它的正确位置是 node_modules 文件夹,但是当 gradle 应该在 react-native-lock-android 内部查找时,它会在 react-native 模块内部查找。这可能是 gradle 配置的问题。有关如何解决此问题的任何提示?

【问题讨论】:

    标签: android gradle android-gradle-plugin react-native auth0


    【解决方案1】:

    原来 Auth0 网站上的 react-native-android 文档已经过时了。使用 github repo 上的设置说明:https://github.com/auth0/react-native-lock-android

    但是 repo 仍然有点过时,并且不完全清楚如何修改 MainActivity.java。所以,对于以后来看这篇文章的人来说,这是我的 MainActivity.java 文件:

    package com.thisorthatapp;
    
    import com.auth0.core.Strategies;
    import com.auth0.facebook.FacebookIdentityProvider;
    import com.auth0.lock.react.LockReactPackage;
    import com.facebook.react.ReactActivity;
    import com.facebook.react.ReactInstanceManager;
    import com.facebook.react.ReactPackage;
    import com.facebook.react.shell.MainReactPackage;
    
    import java.util.Arrays;
    import java.util.List;
    
    public class MainActivity extends ReactActivity {
    
        /**
         * Returns the name of the main component registered from JavaScript.
         * This is used to schedule rendering of the component.
         */
        @Override
        protected String getMainComponentName() {
            return "thisOrThatApp";
        }
    
        /**
         * Returns whether dev mode should be enabled.
         * This enables e.g. the dev menu.
         */
        @Override
        protected boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }
    
        /**
         * A list of packages used by the app. If the app uses additional views
         * or modules besides the default ones, add more packages here.
         */
        @Override
        protected List<ReactPackage> getPackages() {
            LockReactPackage lockReactPackage = new LockReactPackage();
            lockReactPackage.addIdentityProvider(Strategies.Facebook, new FacebookIdentityProvider(this));
            return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                lockReactPackage
            );
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-03-08
      • 2019-03-21
      • 1970-01-01
      • 2020-08-12
      • 2016-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-07
      相关资源
      最近更新 更多