React Native Project无法在EXPO或AVD上构建

时间:2019-02-27 03:57:00

标签: react-native expo

我刚得到一个React本机项目,并且我正在尝试运行它。当我跑步时: react-native run-android ,这是我的输出。

Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Checking the license for package Android SDK Platform 27 in C:\Users\oriont\AppData\Local\Android\Sdk\licenses
Warning: License for package Android SDK Platform 27 not accepted.


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     platforms;android-27 Android SDK Platform 27
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

  Using Android SDK: C:\Users\oriont\AppData\Local\Android\Sdk

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

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
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/getting-started.html

Command failed: gradlew.bat installDebug

Error: Command failed: gradlew.bat installDebug
    at checkExecSyncError (child_process.js:637:11)
    at Object.execFileSync (child_process.js:655:13)
    at runOnAllDevices (C:\Users\oriont\dev\proj\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
    at buildAndRun (C:\Users\oriont\dev\proj\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
    at isPackagerRunning.then.result (C:\Users\oriont\dev\proj\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

我已经按照facebook入门页面上的所有指示进行操作,但是此错误不断弹出。当我运行它时,我在AVD 9上运行了我的AVD。从那里开始,我尝试接受许可证。

C:\Users\oriont\AppData\Local\Android\Sdk\tools\bin>sdkmanager.bat --licenses
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
        ... 5 more

我不知道该怎么办。我尝试过世博会,那是另一个兔子洞...请有人帮忙!谢谢!

2 个答案:

答案 0 :(得分:1)

Android Studio>首选项>外观和行为>系统设置> Android SDK

勾选最新的Android版本,然后单击“应用”。

此时,Android会要求您同意其许可证并安装更新的版本。

From Here GitHub

答案 1 :(得分:1)

我读了一个答案(谢谢),可惜它没有用。我现在认为许可证不再是问题。我已经意识到该项目需要android 27,并且我已经安装了android 28,所以我尝试降级为android27。这没有用,所以我只是通过更改android / build中的ext将项目升级到android 28。 .gradle至:

ext {
    buildToolsVersion = "28.0.0"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 26
    supportLibVersion = "28.0.0"
}

并将其添加到android / app / build.gradle中的

packagingOptions {
   pickFirst 'lib/x86/libc++_shared.so'
   pickFirst 'lib/x86_64/libjsc.so'
   pickFirst 'lib/arm64-v8a/libjsc.so'
   pickFirst 'lib/arm64-v8a/libc++_shared.so'
   pickFirst 'lib/x86_64/libc++_shared.so'
   pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}

我还安装了Java 10.0.2,并降级为Java8。(不确定是否有所作为)

无论如何,我希望这可以帮助人们更新他们的旧项目!

相关问题