Не удается найти символ: метод getPackages () при использовании response-native-navigation - PullRequest
0 голосов
/ 16 сентября 2018

Я настроил новый проект RN, он работал отлично, пока я не добавил response-native-navigation. Я выполнил все шаги, представленные здесь Даже после того, как я попробовал несколько решений, которые я нашел, похоже, ничего не работает.

Полная трассировка стека :

react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Configure project :app 
WARNING: The specified Android SDK Build Tools version (25.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.4.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-navigation 
downloadRobolectricDependencies /Users/shubhamaneja/shubham/workspace/projects/react/react-native/PROJECT_DIRECTORY/android/build/robolectric-dependencies
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
WARNING: 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
WARNING: Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.4.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Task :app:compileDebugJavaWithJavac FAILED
/Users/shubhamaneja/shubham/workspace/projects/react/react-native/PROJ_NAME/android/app/src/main/java/com/PROJ_NAME/MainApplication.java:57: error: cannot find symbol
        return getPackages();
               ^
  symbol:   method getPackages()
  location: class MainApplication
1 error


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 0s
28 actionable tasks: 1 executed, 27 up-to-date
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

Шаги для воспроизведения

  1. npm install --save response-native-navation
  2. Выполните эти шаги
  3. реакция-нативный запуск-android

Окружающая среда

  • React Native Navigation версия: 1.1.486
  • React Собственная версия: 0.57.0
  • Платформа (ы) (iOS, Android или оба?): Android Информация об устройстве (Simulator / Device? Версия ОС? Debug / Release?): Simulater | Отладка | Pixel2 Android 6.0 API уровень 23

андроида / settings.gredle:

rootProject.name = PROJECT_NAME

include ':app'
 include ':react-native-navigation'
 project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app/')

Android / приложение / build.gradle:

Заменены

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

с

 android {
     compileSdkVersion 25
     buildToolsVersion "25.0.1"
     ...
 }

И обновлены зависимости до:

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
    implementation project(':react-native-navigation')
}

MainActivity.java

    package com.PROJECT_NAME;

    import com.facebook.react.ReactActivity;
    import com.reactnativenavigation.controllers.SplashActivity;


    public class MainActivity extends SplashActivity {

        /**
         * Returns the name of the main component registered from JavaScript.
         * This is used to schedule rendering of the component.
         */
        protected String getMainComponentName() {
            return "PROJ_NAME";
        }
    }


> MainApplication.java

package com.PROJECT_NAME;

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;
import com.reactnativenavigation.NavigationApplication;


public class MainApplication extends NavigationApplication 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);
    }

    @Override
    public boolean isDebug() {
        // Make sure you are using BuildConfig from your own application
        return BuildConfig.DEBUG;
    }


    @Override
    public List < ReactPackage > createAdditionalReactPackages() {
        return getPackages();
    }

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