Android Studio使用react本机应用程序构建错误

时间:2018-04-13 08:37:59

标签: react-native android-gradle build.gradle react-native-android android-studio-3.1

我一直在尝试使用expo工具xde使用react native创建一个应用程序,然后使用exp detach将其分离,当我在Android Studio中打开时,我在构建时会遇到很多错误:

Using incompatible plugins for the annotation processing

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


The specified Android SDK Build Tools version (23.0.1) is ignored,
as it is below the minimum supported version (27.0.3) for Android
Gradle Plugin 3.1.1. Android SDK Build Tools 27.0.3 will be used. To
suppress this warning, remove "buildToolsVersion '23.0.1'" from your
build.gradle file, as each version of the Android Gradle Plugin now
has a default version of the build tools. Update Build Tools version
and sync project Open File


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


Configuration 'testCompile' is obsolete and has been replaced with
'testImplementation' and 'testApi'. It will be removed at the end of
2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


Configuration 'testApi' is obsolete and has been replaced with
'testImplementation'.

这是正常的吗?你可以问我为什么要分开,因为我有理由。

如何在Android工作室中编译构建应用程序时,如何创建一个以原生为基础的分离应用程序并获得更顺畅的体验?

ps:我正在使用Android Studio 3.1.1而且我似乎在使用最新版本的Gradle [https://services.gradle.org/distributions/gradle-4.4-all.zip] [1],idk如果这是来自反应应用程序或我通过Android工作室以某种方式更新。

此外,我似乎还没有对app.build.graddle中的依赖项进行编译,并且它仍在抱怨我已经用实现替代了

2 个答案:

答案 0 :(得分:2)

如错误所述,您必须在依赖项中将compile替换为implementation,因为编译已过时。

实施例

dependencies {
    implementation 'com.android.support:support-v4:25.4.0'
    implementation 'com.android.support:recyclerview-v7:25.4.0'
    implementation 'com.android.support:design:25.4.0'
    ....
}

答案 1 :(得分:-3)

请注意:

如果您使用 create-react-native-app 创建应用,然后分离,您仍然可以使用Expo的大部分功能,例如地图。

但是如果您使用 react-native init 创建一个react本机项目,您将无法使用任何expo的功能。