React Native Navigation Error building Android,:app@debug/compileClasspath': 无法解析项目:react-native-navigation
React Native Navigation Error building Android,:app@debug/compileClasspath': Could not resolve project :react-native-navigation
我正在尝试安装 react-native-navigation(wix) 包,我正在按照 android(https://wix.github.io/react-native-navigation/#/installation-android) 上的步骤操作,但在 android studio 中构建消息失败。 Gradle 4.1(不知道有没有关系)
Could not resolve project :react-native-navigation.
Required by:
project :app
Unable to find a matching configuration of project :react-native-navigation: None of the consumable configurations have attributes.
Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :react-native-navigation.
Open File
Show Details
Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :react-native-navigation.
Open File
Show Details
Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :react-native-navigation.
Open File
Show Details
Error:Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :react-native-navigation.
Open File
Show Details
Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :react-native-navigation.
我在下面留下详细信息(我的用户叫家,不是错字):
问题描述
local.properties 文件
sdk.dir=/home/home/Android/Sdk
settings.gradle
include ':app'
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app/')
App gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
defaultConfig {
applicationId "com.example.home.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:25.0.1"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//tried implementation as well here instead of compile but didn't work either
compile project(':react-native-navigation')
}
环境
- React Native Navigation 版本:“1.1.370”
- React Native 版本:“0.52.0”
- 平台(iOS、Android 或两者?):Android
- 设备信息(Simulator/Device?OS版本?Debug/Release?):Android工作室
我应该将 gradle 和 android api 的哪个版本与 React Native 一起使用?有什么办法可以解决这个问题吗?我看到我的应用程序 gradle 文件与说明完全不同,编译项目语句在我的 gradle 版本中无效。任何的想法?也许 local.settings 是错误的并且没有找到文件?...任何帮助将不胜感激
问题是最后一个 gradle 版本与我怀疑的包不兼容。最后我不得不使用 gradle 3 并且一切正常
环境
React Native Navigation version: "2.0.2502"
React Native version: "0.56.0"
Platform(s) (iOS, Android, or both?): Android
Device info (Simulator/Device? OS version? Debug/Release?): Android Studio
我关注了official documentation,然后遇到了同样的问题。在我的情况下,我将 'RNN' 文件夹移动到我的 react-native 项目的 node_modules
中,然后 Gradle 工作了。
We also get the same problem on my android app, Here is the solution.
Follow the steps to overcome this error.
Step 1:
Requirements
node >= 8
react-native >= 0.51
Step 2:
npm install --save react-native-navigation
Step 3:
Add the following in android/settings.gradle:
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
Step 4:
Make sure you're using the new gradle plugin, edit android/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Step 5:
Update android/build.gradle:
buildscript {
repositories {
+ google()
+ mavenLocal()
+ mavenCentral()
+ jcenter()
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
}
dependencies {
+ classpath 'com.android.tools.build:gradle:3.0.1'
- classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
+ google()
+ mavenCentral()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
+ maven { url 'https://jitpack.io' }
}
}
ext {
- buildToolsVersion = "26.0.3"
+ buildToolsVersion = "27.0.3"
- minSdkVersion = 16
+ minSdkVersion = 19
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
Step 6:
Update project dependencies in android/app/build.gradle.
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.yourproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
...
}
dependencies {
- compile fileTree(dir: "libs", include: ["*.jar"])
- compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
- compile "com.facebook.react:react-native:+" // From node_modules
+ implementation fileTree(dir: "libs", include: ["*.jar"])
+ implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
+ implementation "com.facebook.react:react-native:+" // From node_modules
+ implementation project(':react-native-navigation')
}
Step 7:
Update MainActivity.java
MainActivity.java should extend com.reactnativenavigation.NavigationActivity instead of ReactActivity.
This file is located in android/app/src/main/java/com/<yourproject>/MainActivity.java.
-import com.facebook.react.ReactActivity;
+import com.reactnativenavigation.NavigationActivity;
-public class MainActivity extends ReactActivity {
+public class MainActivity extends NavigationActivity {
- @Override
- protected String getMainComponentName() {
- return "yourproject";
- }
}
Step 7:
Update MainApplication.java
This file is located in android/app/src/main/java/com/<yourproject>/MainApplication.java.
...
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
+import com.reactnativenavigation.NavigationApplication;
+import com.reactnativenavigation.react.NavigationReactNativeHost;
+import com.reactnativenavigation.react.ReactGateway;
import java.util.Arrays;
import java.util.List;
-public class MainApplication extends Application implements ReactApplication {
+public class MainApplication extends NavigationApplication {
+
+ @Override
+ protected ReactGateway createReactGateway() {
+ ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
+ @Override
+ protected String getJSMainModuleName() {
+ return "index";
+ }
+ };
+ return new ReactGateway(this, isDebug(), host);
+ }
+
+ @Override
+ public boolean isDebug() {
+ return BuildConfig.DEBUG;
+ }
+
+ protected List<ReactPackage> getPackages() {
+ // Add additional packages you require here
+ // No need to add RnnPackage and MainReactPackage
+ return Arrays.<ReactPackage>asList(
+ // eg. new VectorIconsPackage()
+ );
+ }
+
+ @Override
+ public List<ReactPackage> createAdditionalReactPackages() {
+ return getPackages();
+ }
- ...
+}
Step 8:
RNN and React Native version
react-native-navigation supports multiple React Native versions. Target the React Native version required by your project by specifying the RNN build flavor in android/app/build.gradle.
android {
...
defaultConfig {
applicationId "com.yourproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
+ missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57" // See note below!
versionCode 1
versionName "1.0"
...
}
...
}
更多详情可以关注这个link
enter link description here
您是否安装了 Android SDK 27?在 Android Studio 中打开您的 Android SDK 管理器,并确保您在那里安装了该版本。还尝试创建一个基于该版本的模拟器。
我正在尝试安装 react-native-navigation(wix) 包,我正在按照 android(https://wix.github.io/react-native-navigation/#/installation-android) 上的步骤操作,但在 android studio 中构建消息失败。 Gradle 4.1(不知道有没有关系)
Could not resolve project :react-native-navigation.
Required by:
project :app
Unable to find a matching configuration of project :react-native-navigation: None of the consumable configurations have attributes.
Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :react-native-navigation.
Open File
Show Details
Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :react-native-navigation.
Open File
Show Details
Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :react-native-navigation.
Open File
Show Details
Error:Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :react-native-navigation.
Open File
Show Details
Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :react-native-navigation.
我在下面留下详细信息(我的用户叫家,不是错字):
问题描述 local.properties 文件
sdk.dir=/home/home/Android/Sdk
settings.gradle
include ':app'
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app/')
App gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
defaultConfig {
applicationId "com.example.home.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:25.0.1"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//tried implementation as well here instead of compile but didn't work either
compile project(':react-native-navigation')
}
环境
- React Native Navigation 版本:“1.1.370”
- React Native 版本:“0.52.0”
- 平台(iOS、Android 或两者?):Android
- 设备信息(Simulator/Device?OS版本?Debug/Release?):Android工作室
我应该将 gradle 和 android api 的哪个版本与 React Native 一起使用?有什么办法可以解决这个问题吗?我看到我的应用程序 gradle 文件与说明完全不同,编译项目语句在我的 gradle 版本中无效。任何的想法?也许 local.settings 是错误的并且没有找到文件?...任何帮助将不胜感激
问题是最后一个 gradle 版本与我怀疑的包不兼容。最后我不得不使用 gradle 3 并且一切正常
环境
React Native Navigation version: "2.0.2502"
React Native version: "0.56.0"
Platform(s) (iOS, Android, or both?): Android
Device info (Simulator/Device? OS version? Debug/Release?): Android Studio
我关注了official documentation,然后遇到了同样的问题。在我的情况下,我将 'RNN' 文件夹移动到我的 react-native 项目的 node_modules
中,然后 Gradle 工作了。
We also get the same problem on my android app, Here is the solution.
Follow the steps to overcome this error.
Step 1:
Requirements
node >= 8
react-native >= 0.51
Step 2:
npm install --save react-native-navigation
Step 3:
Add the following in android/settings.gradle:
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
Step 4:
Make sure you're using the new gradle plugin, edit android/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Step 5:
Update android/build.gradle:
buildscript {
repositories {
+ google()
+ mavenLocal()
+ mavenCentral()
+ jcenter()
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
}
dependencies {
+ classpath 'com.android.tools.build:gradle:3.0.1'
- classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
+ google()
+ mavenCentral()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
+ maven { url 'https://jitpack.io' }
}
}
ext {
- buildToolsVersion = "26.0.3"
+ buildToolsVersion = "27.0.3"
- minSdkVersion = 16
+ minSdkVersion = 19
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
Step 6:
Update project dependencies in android/app/build.gradle.
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.yourproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
...
}
dependencies {
- compile fileTree(dir: "libs", include: ["*.jar"])
- compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
- compile "com.facebook.react:react-native:+" // From node_modules
+ implementation fileTree(dir: "libs", include: ["*.jar"])
+ implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
+ implementation "com.facebook.react:react-native:+" // From node_modules
+ implementation project(':react-native-navigation')
}
Step 7:
Update MainActivity.java
MainActivity.java should extend com.reactnativenavigation.NavigationActivity instead of ReactActivity.
This file is located in android/app/src/main/java/com/<yourproject>/MainActivity.java.
-import com.facebook.react.ReactActivity;
+import com.reactnativenavigation.NavigationActivity;
-public class MainActivity extends ReactActivity {
+public class MainActivity extends NavigationActivity {
- @Override
- protected String getMainComponentName() {
- return "yourproject";
- }
}
Step 7:
Update MainApplication.java
This file is located in android/app/src/main/java/com/<yourproject>/MainApplication.java.
...
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
+import com.reactnativenavigation.NavigationApplication;
+import com.reactnativenavigation.react.NavigationReactNativeHost;
+import com.reactnativenavigation.react.ReactGateway;
import java.util.Arrays;
import java.util.List;
-public class MainApplication extends Application implements ReactApplication {
+public class MainApplication extends NavigationApplication {
+
+ @Override
+ protected ReactGateway createReactGateway() {
+ ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
+ @Override
+ protected String getJSMainModuleName() {
+ return "index";
+ }
+ };
+ return new ReactGateway(this, isDebug(), host);
+ }
+
+ @Override
+ public boolean isDebug() {
+ return BuildConfig.DEBUG;
+ }
+
+ protected List<ReactPackage> getPackages() {
+ // Add additional packages you require here
+ // No need to add RnnPackage and MainReactPackage
+ return Arrays.<ReactPackage>asList(
+ // eg. new VectorIconsPackage()
+ );
+ }
+
+ @Override
+ public List<ReactPackage> createAdditionalReactPackages() {
+ return getPackages();
+ }
- ...
+}
Step 8:
RNN and React Native version
react-native-navigation supports multiple React Native versions. Target the React Native version required by your project by specifying the RNN build flavor in android/app/build.gradle.
android {
...
defaultConfig {
applicationId "com.yourproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
+ missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57" // See note below!
versionCode 1
versionName "1.0"
...
}
...
}
更多详情可以关注这个link enter link description here
您是否安装了 Android SDK 27?在 Android Studio 中打开您的 Android SDK 管理器,并确保您在那里安装了该版本。还尝试创建一个基于该版本的模拟器。