小编Jim*_*tek的帖子

buildTypes不能应用于groovy.lang.Closure

我在项目gradle文件中收到此警告:

警告:(16,5)'buildTypes'不能应用于'(groovy.lang.Closure <com.android.build.gradle.internal.dsl.BuildType>)'

我的buildTypes部分是:

    buildTypes {
        debug {
            debuggable true
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
Run Code Online (Sandbox Code Playgroud)

我目前正在使用Android Studio 1.1.0,compileSdkVersion 22,buildToolsVersion 22.0.0和targetSdkVersion 22.我尝试退回到21但仍然收到警告.

导致此警告的原因是什么?

android-studio android-gradle-plugin

241
推荐指数
7
解决办法
5万
查看次数

Android Switch小部件textOn和textOff在Lollipop中不起作用

Lollipop(5.0)中切换小部件的行为已更改.

    <Switch
        android:id="@+id/switcher"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginBottom="16dp"
        android:layout_marginRight="8dp"
        android:layout_marginEnd="8dp"
        android:layout_toEndOf="@id/another_view"
        android:layout_toRightOf="@id/another_view"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:textOff="@string/disabled"
        android:textOn="@string/enabled"
        android:fontFamily="sans-serif-condensed"
        />
Run Code Online (Sandbox Code Playgroud)

targetSdkVersion = 19时渲染切换:

在此输入图像描述

targetSdkVersion = 21时渲染切换:

在此输入图像描述

请注意,Android Studio中的预览渲染仍会生成带文本的开关,但是当使用Lollipop(Nexus 5)在设备上运行使用targetSdkVersion = 21构建的apk时,开关会丢失文本.在同一个Lollipop设备上运行使用targetSdkVersion = 19构建的apk,可以按预期正确显示开关.

为什么?任何建议的解决方法?

android android-switch android-5.0-lollipop

52
推荐指数
1
解决办法
3万
查看次数

为什么某些广播接收器只能通过Code或AndroidManifest注册

某些广播接收器仅在通过代码注册而不是在AndroidManifest中定义时才起作用.

例如:

SCREEN_ON, SCREEN_OFF
Run Code Online (Sandbox Code Playgroud)

这些操作仅适用于在代码中注册的接收器.如果它们在清单中注册,则不会发生错误,但它们也永远不会被调用.

这种无证行为的原因是什么?安全?

android broadcastreceiver

16
推荐指数
1
解决办法
2044
查看次数

启动Launcher后,AppWidget PendingIntent无法正常工作

我有一个AppWidget有2个待定意图.他们大部分时间都在工作,但过了一段时间他们就停止了回应.我唯一能够确定的是,它们在Launcher重启后瘫痪,即我使用Launcher Pro,有时会调整设置并且必须重新启动它.之后他们根本不工作.

这里是我onRecieve()onUpdate()方法:

   public void onReceive(Context context, Intent intent)
{
    super.onReceive(context, intent);
    String action = intent.getAction();
    if(action.equals("android.tristan.widget.digiclock.CLICK"))
    {
        PackageManager packageManager = context.getPackageManager();
        Intent alarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);

        String clockImpls[][] = {
                {"HTC Alarm Clock", "com.htc.android.worldclock", "com.htc.android.worldclock.AlarmClock" },
                {"Standar Alarm Clock", "com.android.deskclock", "com.android.deskclock.AlarmClock"},
                {"Froyo Nexus Alarm Clock", "com.google.android.deskclock", "com.android.deskclock.DeskClock"},
                {"Moto Blur Alarm Clock", "com.motorola.blur.alarmclock",  "com.motorola.blur.alarmclock.AlarmClock"}
        };

        boolean foundClockImpl = false;

        for(int i=0; i<clockImpls.length; i++) {
            String vendor = clockImpls[i][0];
            String packageName = clockImpls[i][1];
            String className = clockImpls[i][2]; …
Run Code Online (Sandbox Code Playgroud)

android onclick android-intent android-pendingintent android-appwidget

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

窗口小部件未在启动器重启时更新

我有一个小部件,只要有配置更改(例如屏幕方向),每当手机解锁时,它都会自动更新.此过程涉及onClick为我的小部件上的按钮设置处理程序.这很好用,但是我发现有一个使用案例会导致我的应用无法响应onClick事件.这种特殊情况是每当启动器重新启动时.

有没有办法检测启动器何时重启,所以我可以手动更新我的小部件?或者还有另一种方法可以确保onClick处理程序不会丢失吗?

android widget launcher android-pendingintent

4
推荐指数
1
解决办法
3510
查看次数

在appengine-web.xml中显示"URI未注册"的Android Studio lint?

"App Engine Java Serlet模块"和"App Engine Java端点模块"的默认/webapp/WEB-INF/appengine-web.xml文件包含此命名空间:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
Run Code Online (Sandbox Code Playgroud)

此命名空间由lint标记,其中"URI未注册"消息.它提供了指向设置|项目设置|架构和DTD的指针,但修复不明显.

在此输入图像描述

此警告不会影响模块的构建或功能,但忽略它会感觉不对.该如何修复?

google-app-engine google-cloud-endpoints android-studio

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