[英]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. 我犯了一个错误,那就是构建我的React Native项目并仅在IOS模拟器上进行测试。 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.
我已经解决了我最终尝试在Android Studio中构建项目时抛出的大多数错误,但是仍然有三个错误使我发疯。
1) 1)
Error:(38, 3) error: method does not override or implement a method from a supertype
2) 2)
Error:(41, 12) error: cannot find symbol method onRequestPermissionsResult(int,String[],int[])
3) 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
我认为前两个错误是在
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. 我已经研究并尝试调试3天的第三个错误,但没有取得任何进展。 If anyone has any input I would be forever grateful!
如果有人有任何意见,我将永远感激不已!
onRequestPermissionsResult is not available for the Application class. onRequestPermissionsResult不适用于Application类。 You have to override it in the Activity class.
您必须在Activity类中覆盖它。 Please check out the docs.
请检查文档。
Also here you can get a sample implementation. 同样在这里,您可以获得示例实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.