Java 将本机集成到现有的android项目

Java 将本机集成到现有的android项目,java,android,react-native,android-studio,Java,Android,React Native,Android Studio,我正在尝试将本机集成到现有的android项目中,但在android studio中构建项目时出现以下异常 原因:java.lang.Exception:React Native CLI无法确定Android项目配置。这可能是由于配置错误。配置输出: [root:/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/android,reactNativePath:/Users/muratoner/De

我正在尝试将本机集成到现有的android项目中,但在android studio中构建项目时出现以下异常

原因:java.lang.Exception:React Native CLI无法确定Android项目配置。这可能是由于配置错误。配置输出: [root:/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/android,reactNativePath:/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/node_modules/react-native,依赖项:[:],命令:[],资产:[],平台:[:],haste providesmodulenodemodulenodemodulenodemodule:[],平台:[:],项目:[:] 位于ReactNativeModules.getReactNativeConfig(/Users/muratone/Desktop/backup/Sabanci.Projects/Mobile/hrweb react-native/node_-modules/@react-native-community/cli平台android/native_-modules.gradle:212) 位于ReactNativeModules$getReactNativeConfig.callCurrent(未知源) 在react-NativeModule上。(/Users/muratone/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/node_-modules/@react-native-community/cli平台android/native_-modules.gradle:84) 在本机模块上运行8dnp0y65ugw2tp4vo89t6lw0x.run(/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb react native/node_modules/@react native community/cli platform android/native_modules.gradle:244) 位于org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91) ... 148多

React native package.json

{
  "name": "MyApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "yarn react-native start"
  },
  "dependencies": {
    "@react-native-community/cli-platform-android": "^3.0.3",
    "react": "^16.9.0",
    "react-native": "^0.61.5"
  }
}
android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        // Add Maven repo
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        //classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()
        maven { url 'https://jitpack.io' }
        maven { 
            // All of React Native (JS, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
         }
         maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
include ':app'

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings);
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }

    dependencies {
    }
}

apply plugin: 'com.android.application'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)


repositories {
    maven { url 'https://maven.google.com' }
}

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'

    defaultConfig {
        applicationId "com.myapp.android"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 111
        versionName "1.1.1"
        multiDexEnabled true
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'

    implementation "com.facebook.react:react-native:+" // From node_modules
    implementation "org.webkit:android-jsc:+"
}
android/settings.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        // Add Maven repo
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        //classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()
        maven { url 'https://jitpack.io' }
        maven { 
            // All of React Native (JS, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
         }
         maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
include ':app'

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings);
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }

    dependencies {
    }
}

apply plugin: 'com.android.application'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)


repositories {
    maven { url 'https://maven.google.com' }
}

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'

    defaultConfig {
        applicationId "com.myapp.android"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 111
        versionName "1.1.1"
        multiDexEnabled true
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'

    implementation "com.facebook.react:react-native:+" // From node_modules
    implementation "org.webkit:android-jsc:+"
}
android/app/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        // Add Maven repo
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        //classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()
        maven { url 'https://jitpack.io' }
        maven { 
            // All of React Native (JS, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
         }
         maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
include ':app'

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings);
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }

    dependencies {
    }
}

apply plugin: 'com.android.application'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)


repositories {
    maven { url 'https://maven.google.com' }
}

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'

    defaultConfig {
        applicationId "com.myapp.android"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 111
        versionName "1.1.1"
        multiDexEnabled true
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'

    implementation "com.facebook.react:react-native:+" // From node_modules
    implementation "org.webkit:android-jsc:+"
}

我尝试了不同的方法,但仍然抛出了相同的异常。

是否可以这样做,例如运行
纱线安装
,我尝试了多次“纱线安装”命令,但都不起作用。