gpt4 book ai didi

Java 包不公开,包外无法访问

转载 作者:行者123 更新时间:2023-11-30 00:08:20 24 4
gpt4 key购买 nike

您好,我不是专业的 Java 开发人员,但我正在尝试为 React Native 编写一个 Android native 组件,但在编写时遇到以下错误日志。

/Users/waqas.bhatti/Projects/es-tracker/mobile/tracker/custom_modules/custom-react-native-app-auth/android/src/main/java/com/reactlibrary/RNCustomAppAuthModule.java:27: error: AdditionalParamsProcessor is not public in net.openid.appauth; cannot be accessed from outside package
import static net.openid.appauth.AdditionalParamsProcessor.builtInParams;
^
/Users/waqas.bhatti/Projects/es-tracker/mobile/tracker/custom_modules/custom-react-native-app-auth/android/src/main/java/com/reactlibrary/RNCustomAppAuthModule.java:27: error: static import only from classes and interfaces
import static net.openid.appauth.AdditionalParamsProcessor.builtInParams;
^
/Users/waqas.bhatti/Projects/es-tracker/mobile/tracker/custom_modules/custom-react-native-app-auth/android/src/main/java/com/reactlibrary/RNCustomAppAuthModule.java:28: error: AdditionalParamsProcessor is not public in net.openid.appauth; cannot be accessed from outside package
import static net.openid.appauth.AdditionalParamsProcessor.checkAdditionalParams;
^
/Users/waqas.bhatti/Projects/es-tracker/mobile/tracker/custom_modules/custom-react-native-app-auth/android/src/main/java/com/reactlibrary/RNCustomAppAuthModule.java:28: error: static import only from classes and interfaces
import static net.openid.appauth.AdditionalParamsProcessor.checkAdditionalParams;
^
/Users/waqas.bhatti/Projects/es-tracker/mobile/tracker/custom_modules/custom-react-native-app-auth/android/src/main/java/com/reactlibrary/RNCustomAppAuthModule.java:106: error: cannot find symbol
.setCodeVerifier(CodeVerifierUtil.generateRandomCodeVerifier())
^
symbol: variable CodeVerifierUtil
5 errors

知道如何导入它吗?或者有什么解决办法吗?

您可以通过以下 URL 检查此库: https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationServiceConfiguration.java#L102

最佳答案

调用包保护方法的一个丑陋的解决方法是在该包中放置一个自己的类,其中包含一个转发方法调用的公共(public)方法。

例如:

public class net.openid.appauth.PublicWorkarround {
public static Set<String> buildInParams(Set<String> params) {
return net.openid.appauth.AdditionalParamsProcessor.builtInParams(params);
}
}

关于Java 包不公开,包外无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48595790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com