compilePdkVersion for Android P Developer Preview的价值

时间:2018-03-08 22:16:53

标签: android android-studio gradle build android-p-developer-preview

应该是什么价值:

compileSdkVersion
targetSdkVersion

我已经下载并安装了Android P Developer Preview SDK,系统映像和构建工具。

我试过" 28"但是它显示了这个错误:

enter image description here

3 个答案:

答案 0 :(得分:12)

使用P预览:

@Configuration
@EnableWebSecurity
@Order(1)
public class SecurityJavaConfig extends WebSecurityConfigurerAdapter {

@Value("${yourapp.http.auth-token-header-name}")
private String principalRequestHeader;

@Value("${yourapp.http.auth-token}")
private String principalRequestValue;

@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
    APIKeyAuthFilter filter = new APIKeyAuthFilter(principalRequestHeader);
    filter.setAuthenticationManager(new AuthenticationManager() {

        @Override
        public Authentication authenticate(Authentication authentication) throws AuthenticationException {
            String principal = (String) authentication.getPrincipal();
            if (!principalRequestValue.equals(principal))
            {
                throw new BadCredentialsException("The API key was not found or not the expected value.");
            }
            authentication.setAuthenticated(true);
            return authentication;
        }
    });
    httpSecurity.           
       antMatcher("/api/**").
        csrf().disable().
        sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).
        and().

        addFilter(filter).authorizeRequests().anyRequest().authenticated();

}

请参阅:https://developer.android.com/preview/setup-sdk.html

答案 1 :(得分:6)

targetSdkVersion 'P'

gsub

答案 2 :(得分:0)

compileSdkVersion 'android-P'

targetSdkVersion 28

为我工作!