简体   繁体   中英

React Native - Execution failed for task ':app:compileDebugJavaWithJavac'

I made the mistake of building my React Native project and only testing on the IOS simulator. I've tackled most of the bugs that where thrown when I finally tried to build the project in Android Studio but there are still three errors that are driving me insane.

1)

Error:(38, 3) error: method does not override or implement a method from a supertype

2)

Error:(41, 12) error: cannot find symbol method onRequestPermissionsResult(int,String[],int[])

3)

 Error:Execution failed for task :app:compileDebugJavaWithJavac.
> Compilation failed; see the compiler error output for details.

I think the first two errors are referring to this subclass in my MainApplication.java

 @Override
  public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
      CalendarEventsPackage.onRequestPermissionsResult(requestCode, permissions, grantResults);
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  }

Here is the rest of the file for context:

package com.fit.fitmobile;

import android.support.multidex.MultiDexApplication;

import com.facebook.react.ReactPackage;

import java.util.Arrays;
import java.util.List;

// Needed for `react-native link`
// import com.facebook.react.ReactApplication;
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import com.calendarevents.CalendarEventsPackage;
import com.airbnb.android.react.maps.MapsPackage;

public class MainApplication extends MultiDexApplication {

  // Needed for `react-native link`
  public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        // Add your own packages here!
        // TODO: add cool native modules

        // Needed for `react-native link`
//         new MainReactPackage(),
            new ReactNativeOneSignalPackage(),
            new CalendarEventsPackage(),
            new MapsPackage(),
            new CalendarEventsPackage(),
            new ReactNativeOneSignalPackage()
    );
  }

  // Code for target SDK versions 23 and over.
  @Override
  public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
      CalendarEventsPackage.onRequestPermissionsResult(requestCode, permissions, grantResults);
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  }
}

The third error I've researched and tried debugging for 3 days now, but haven't made any progress. If anyone has any input I would be forever grateful!

onRequestPermissionsResult is not available for the Application class. You have to override it in the Activity class. Please check out the docs.

Also here you can get a sample implementation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM