小编daw*_*ski的帖子

导入android项目时出错("Gradle location not incorrect"或"Cause:block data of block data")

我想在Android Studio中导入Android项目,这就是问题的开始:1)如果我将Gradle设置为Home并单击OK,我会得到以下信息: 在此输入图像描述

2)其次,如果我尝试运行项目,我会收到消息: 在此输入图像描述

尝试两种方式都会导致显示上面的消息.我正确设置了GRADLE_HOME,JAVA_HOME,并且ANDROID_HOME指向android-studio目录中的"sdk"目录.非常感谢您对解决方案的回答.

android android-studio

14
推荐指数
2
解决办法
3万
查看次数

WebSecurityConfigurers上的@Order必须是唯一的

我正面临着我的Spring应用程序的多个入口点的问题.我粘贴在我的配置之下.

@Configuration 
@EnableWebMvcSecurity 
public class EntryPointsConfiguration {

@Configuration
@ComponentScan(basePackages = {"com.springapp.mvc"})
@Order(1)
public static class ApiWebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {

    @Autowired
    private ApplicationAuthenticationProvider authenticationProvider;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .httpBasic()
                .and()
                .antMatcher("/api/**")
                .authorizeRequests()
                    .anyRequest().hasAnyRole(Role.USER, Role.ADMIN);
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authenticationProvider);
    }
}

@Configuration
@ComponentScan(basePackages = {"com.springapp.mvc"})
@Order(2)
public static class FormLoginConfigurationAdapter extends WebSecurityConfigurerAdapter {

    @Autowired
    private ApplicationAuthenticationProvider authenticationProvider;

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http
                .csrf()
                .disable();
        http
                .authorizeRequests()
                .antMatchers("/", …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc spring-security

9
推荐指数
0
解决办法
8593
查看次数

Android应用程序更新问题

最近我一直面临着我的Android应用更新过程的问题.

简而言之,应用程序能够检查是否在服务器上上载了更高版本代码的更新.如果是,则用户决定是否更新.加载该应用程序并开始标准安装后:

final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(PATH_TO_APK)), "application/vnd.android.package-archive");
startActivity(intent)
Run Code Online (Sandbox Code Playgroud)

问题是当android Intent完成安装时,"理论上"活动信息"Application was installed"和2个按钮"Done","Open".我写了"理论上",因为到目前为止我遇到过以下情况:

  1. 安装了应用程序,显示"已安装应用程序"消息的活动,用户单击"打开"但没有任何反应(Android 2.3.*)或应用程序确实正确打开 - 此行为是随机的.

  2. 已安装应用程序,显示"已安装应用程序"消息的活动但突然消失.

试图绕过这个bug(?)我找到了http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REPLACED.我实现的BroadcastReceiver启动了Launch Activity,让我们说这是一个合适的解决方案.

         <receiver android:name=\".MyReceiver\" >
          <intent-filter>
              <action android:name="android.intent.action.ACTION_PACKAGE_REPLACED" />
              //Or from API 12 <action android:name="android.intent.action.ACTION_MY_PACKAGE_REPLACED" />
           </intent-filter>
         </receiver>
Run Code Online (Sandbox Code Playgroud)

必须修改此解决方案,因为具有较低API(低于12)的应用程序无法处理ACTION_MY_PACKAGE_REPLACED,因此我实现了依赖于API的行为:

  • 允许正常安装udpate app并使用"Done"/"Open"按钮从Activity启动应用程序(API <12)

  • 在ACTION_MY_PACKAGE_REPLACED注意到后,通过MyReceiver启动了更新应用程序.

这是我目前的解决方案.

我的问题是:

  • 为什么更新的应用程序在安装到Android的API低于12后单击"打开"后随机打开?

  • 为什么带有"Done"/"Open"按钮的活动会在具有更高API的设备上消失?

我试图在安装之前完成应用程序,但它没有帮助.

我的解释是,在安装过程之后,新包必须覆盖旧包,因此必须简单地删除旧包,这是消除启动活动的主要原因.

正如我写的,这是我目前的解决方案,我不满意.如果有人能澄清此事,我将非常感激.

谢谢阅读.

编辑:

好的,解决方案非常简单:要成功更新,您需要启动Intent作为新任务(arrrgh ...):

final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(PATH_TO_APK)), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

android intentfilter android-intent android-activity

8
推荐指数
1
解决办法
3418
查看次数

使用多个库模块聚合Javadoc for Android项目

我已经浏览了几乎整个互联网,寻找一种方法,如何将包含单独库模块的项目中的Javadoc聚合到单个Javadoc中.

有一个插件显然允许这样做:https: //github.com/nebula-plugins/gradle-aggregate-javadocs-plugin

但是,如果我运行插件指定的命令,Gradle会找到该任务并执行它但不会生成输出目录.

任何帮助如何从多个模块构建单个Javadoc非常感谢.

android javadoc gradle

6
推荐指数
1
解决办法
1427
查看次数

OAuth2 - Spring 安全性:ClientCredentialsTokenEndpointFilter 不起作用

我正在实施 OAuth2 身份验证,但我完全不明白为什么我的 CustomCredentialsTokenEndpointFilter 不起作用。

当我在调试模式下启动应用程序时,没有一个调试检查点被命中。

我需要覆盖过滤器并更改身份验证尝试的实现。

我的配置有错误吗?

认证适配器:

@Configuration
@EnableWebSecurity
@ComponentScan("com.springapp.mvc")
@Order(3)
class OAuth2AuthenticationConfigurationAdapter extends WebSecurityConfigurerAdapter {

@Autowired
private OAuth2AccessDeniedHandler oAuth2AccessDeniedHandler;

@Autowired
@Qualifier("clientDetailsService")
private ClientDetailsService oauth2ClientDetailsService;

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
            .anonymous()
            .disable();
    http
            .requestMatchers()
            .antMatchers("/oauth/token")
        .and()
            .authorizeRequests()
            .anyRequest()
            .fullyAuthenticated();
    http
            .httpBasic()
            .authenticationEntryPoint(oAuth2AuthenticationEntryPoint())
        .and()
            .addFilterBefore(clientCredentialsTokenEndpointFilter(), BasicAuthenticationFilter.class)
            .sessionManagement()
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
        .and()
            .exceptionHandling()
            .accessDeniedHandler(oAuth2AccessDeniedHandler);
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .userDetailsService(clientDetailsUserDetailsService());
}

@Bean
ClientCredentialsTokenEndpointFilter clientCredentialsTokenEndpointFilter() {
    final ClientCredentialsTokenEndpointFilter tokenEndpointFilter = new CustomClientCredentialsTokenEndpointFilter();
    try { …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc spring-security oauth-2.0 spring-security-oauth2

5
推荐指数
1
解决办法
9493
查看次数

OAuth2 Spring Security - OAuth2AuthenticationProcessingFilter 不起作用

嘿,我正在使用 OAuth2 实现 Spring 应用程序。

根据spring 文档,为了启用具有 OAuth2 授权的资源请求,我需要添加 @EnableResourceServer 注释以包含 OAuth2AuthenticationProcessingFilter 。

我添加了这个注释,但不幸的是 Filter 在启动时没有在链中调用。

我可以使用 curl 命令获取访问令牌:

curl -X POST -H "Authorization: Basic **************************" -v -H "Accept: application/json" -d "username=my.user&password=pass&client_id=my.user&client_secret=4e1d635a-7c9d-426b-a942-cc166438f996&grant_type=password&scope=read write" http://localhost:8080/oauth/token
Run Code Online (Sandbox Code Playgroud)

但资源要求:

curl -v -H "Authorization : Bearer ecfa5bfb-c224-4b4a-abf4-cb4a828c2efb" -H "Accept: application/json" http://localhost:8443/oauth/api/meetings/9
Run Code Online (Sandbox Code Playgroud)

给出:

来自服务器的空回复

到主机 localhost 的连接 #0 保持不变

在我的资源配置下面:

@Configuration
@EnableWebSecurity
@ComponentScan("com.springapp.mvc")
@EnableResourceServer
@Order(4)
public class Oauth2ResourcesConfigurationAdapter extends ResourceServerConfigurerAdapter {

@Autowired
private OAuth2AuthenticationEntryPoint oAuth2AuthenticationEntryPoint;

@Autowired
private PreAuthUserDetailsService preAuthUserDetailsService;

@Autowired
private OAuth2AccessDeniedHandler accessDeniedHandler;

@Autowired …
Run Code Online (Sandbox Code Playgroud)

spring-mvc spring-security oauth-2.0 spring-security-oauth2

2
推荐指数
2
解决办法
8818
查看次数