npm run android commad дает не может найти ошибки символа - PullRequest
0 голосов
/ 22 сентября 2018

Хотя я смог создать свое приложение с CRNA и извлечь его с помощью npm run eject, и запустить его с помощью npm run android, через три недели это произошло.За последние 20 часов я удалил узел, android studio, android sdk и снова загрузил их все.Все еще такие же ошибки происходят.Я совершенно не понимаю, если это происходит из-за gradle или java или android.У меня два вопроса.

Вопросы

1.Как я могу решить эту проблему?

2.

a) crna myApp -> cd myApp -> npm run eject -> npm run android |

б) реактивный нативный init myApp -> cd myApp -> реактивный нативный run-android

Второй работает хорошо, но я не люблю expo.Кажется, он компилируется и работает медленнее и создает много ошибок с помощью ссылки «родной».Я хочу знать, при каких обстоятельствах я должен использовать один из них в связи с этим.Я собираюсь убить себя, поэтому любая помощь будет оценена с лучшей стороны.

:app:compileDebugJavaWithJavac

:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).

\android\app\src\main\java\com\biktim\MainApplication.java:5: error: cannot find symbol
import com.facebook.react.ReactApplication;
                     ^
symbol:   class ReactApplication
location: package com.facebook.react

\android\app\src\main\java\com\biktim\MainApplication.java:6: error: cannot find symbol
import com.facebook.react.ReactNativeHost;
                     ^
symbol:   class ReactNativeHost
location: package com.facebook.react

\android\app\src\main\java\com\biktim\MainApplication.java:14: error: cannot find symbol
public class MainApplication extends Application implements ReactApplication 
{
                                                        ^
symbol: class ReactApplication

\android\app\src\main\java\com\biktim\MainApplication.java:16: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
            ^
symbol:   class ReactNativeHost
location: class MainApplication

\android\app\src\main\java\com\biktim\MainApplication.java:36: error: cannot find symbol
public ReactNativeHost getReactNativeHost() {
     ^
symbol:   class ReactNativeHost
location: class MainApplication

\android\app\src\main\java\com\biktim\MainActivity.java:5: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity
public class MainActivity extends ReactActivity {
   ^
\android\app\src\main\java\com\biktim\MainApplication.java:16: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
                                                   ^
symbol:   class ReactNativeHost
location: class MainApplication

\android\app\src\main\java\com\biktim\MainApplication.java:35: error: method does not override or implement a method from a supertype
 @Override
  ^
8 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

MainApplication.java

 package com.biktim;

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 java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

MainActivity.java

package com.biktim;

import com.facebook.react.ReactActivity;

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 "biktim";
}

} ​​

android / build.gradle

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

android / app / build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile



project.ext.react = [
   entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
* Set this to true to create two separate APKs instead of one:
*   - An APK that only works on ARM devices
*   - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false

/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
    applicationId "com.biktim2"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + 
defaultConfig.versionCode
        }
    }
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat- 
 v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

package.json

{
  "name": "biktim2",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.5.0",
    "react-native": "0.57.1"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.45.6",
    "react-test-renderer": "16.5.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

1 Ответ

0 голосов
/ 22 сентября 2018

Проверьте вашу реактивную версию в package.json и android / app / build.gradle.

...