首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在React Native Android中使用Auth0-lock构建失败

在React Native Android中使用Auth0-lock构建失败
EN

Stack Overflow用户
提问于 2016-03-22 23:12:31
回答 1查看 449关注 0票数 0

我正在尝试将Auth0锁与我的Android React-Native应用程序一起使用。我按照here的设置说明进行了操作,但在构建时出现以下错误:

代码语言:javascript
复制
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

我注意到以下几行:

代码语言:javascript
复制
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模块,而它应该查看react-native-lock-android内部。这可能是gradle配置的问题。关于如何解决这个问题,有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2016-03-23 05:02:42

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

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

代码语言:javascript
复制
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
        );
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36158199

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档